commit 1f42db3f055ebd8f8db174dd0f7ba2a6e8dc6360
parent 1eebd9a048c64a3b37a23d61cb8053beb1970f2b
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Fri, 5 Feb 2021 13:17:53 +0100
Check the phase function type in ssf_phase_rdgfa_setup
Diffstat:
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/src/ssf_phase_rdgfa.c b/src/ssf_phase_rdgfa.c
@@ -46,7 +46,7 @@ struct rdgfa {
/* Length of an angular interval for the tow angular domains */
double dtheta[2]; /* In rad */
- /* Limite angle that split the 2 angular domains */
+ /* Limit angle that splits the 2 angular domains */
double theta_limit; /* In rad */
};
@@ -138,12 +138,12 @@ eval2
const double cos_theta)
{
double f, cos2_theta, phase;
- ASSERT(rdgfa && eq_eps(cos_theta, cos(theta), 1.e-6));
+ ASSERT(rdgfa && eq_eps(cos_theta, cos(theta), fabs(cos_theta*1.e-6)));
/* Precompute values */
cos2_theta = cos_theta * cos_theta;
- /* Evaluate the phase(theta) */
+ /* Evaluate phase(theta) */
f = eval_f(rdgfa, theta);
phase = 3.0/(16*PI) * f / rdgfa->g * (1 + cos2_theta);
return phase;
@@ -250,6 +250,7 @@ rdgfa_eval(void* data, const double wo[3], const double wi[3])
const struct rdgfa* rdgfa = data;
const double cos_theta = d3_dot(wo, wi);
const double theta = acos(cos_theta);
+ ASSERT(d3_is_normalized(wo) && d3_is_normalized(wi));
return eval2(data, theta, cos_theta) * rdgfa->rcp_normalize_factor;
}
@@ -350,8 +351,10 @@ ssf_phase_rdgfa_setup
double lambda, Df, Rg, k, k2;
res_T res = RES_OK;
- if(!phase || !check_phase_rdgfa_setup_args(args)) {
- res = RES_OK;
+ if(!phase
+ || !PHASE_TYPE_EQ(&phase->type, &ssf_phase_rdgfa)
+ || !check_phase_rdgfa_setup_args(args)) {
+ res = RES_BAD_ARG;
goto error;
}