star-sf

Set of surface and volume scattering functions
git clone git://git.meso-star.fr/star-sf.git
Log | Files | Refs | README | LICENSE

commit 5a40091b2ee0c091749c60e57d612939f1a32de0
parent b0517721d55aff895bdb70982d063b54aa7976d6
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Fri, 20 Jul 2018 13:54:23 +0200

Fix the HG test

Diffstat:
Msrc/test_ssf_phase_hg.c | 15+++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/src/test_ssf_phase_hg.c b/src/test_ssf_phase_hg.c @@ -56,27 +56,30 @@ main(int argc, char** argv) ssp_ran_sphere_uniform(rng, wo, NULL); FOR_EACH(isamp, 0, NSAMPS) { double wi[3]; + double w[3]; + double weight; double pdf; - double w; double r; double ref; ssf_phase_sample(phase, rng, wo, wi, &pdf); CHK(d3_is_normalized(wi)); CHK(eq_eps(ssf_phase_pdf(phase, wo, wi), pdf, 1.e-6)); - w = d3_dot(wo, wi); - sum_cos += w; - sum_cos_sqr += w*w; + d3_minus(w, wo); /* Match the convention */ + weight = d3_dot(w, wi); + sum_cos += weight; + sum_cos_sqr += weight*weight; /* HG(theta) = 1/(4*PI) * (1 - g^2) / (1 + g^2 - 2*g*cos(theta))^3/2 */ r = ssf_phase_eval(phase, wo, wi); - ref = 1/(4*PI) * (1-g*g) / pow(1+g*g-2*g*d3_dot(wi,d3_minus(wo,wo)), 1.5); + ref = 1/(4*PI) * (1-g*g) / pow(1+g*g-2*g*d3_dot(w,wi), 1.5); CHK(eq_eps(r, ref, 1.e-6)); + CHK(eq_eps(r, pdf, 1.e-6)); } /* On average cos(wo, wi) should be g */ E = sum_cos / NSAMPS; V = sum_cos_sqr / NSAMPS - E*E; SE = sqrt(V/NSAMPS); - CHK(eq_eps(sum_cos / NSAMPS, E, SE) == 1); + CHK(eq_eps(E, g, 3*SE)); } CHK(ssf_phase_ref_put(phase) == RES_OK);