commit fb7894528c92bd5687412bfc8eb2daf908cbb3ba
parent 1717fd34e29665d3f29e8e4295521a87af4701a0
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Mon, 17 Jun 2024 16:10:32 +0200
Correction of a numerical problem when sampling a radiative path
The specular reflection of a ray direction on a boundary introduces a
numerical uncertainty that renders the ray non-normalized with respect
to the threshold used internally by Star3D to verify this precondition.
As a result, Star3D returns an error when sampling a radiative
trajectory. To avoid the resulting assertion, the direction is now
re-normalized after being reflected.
Diffstat:
1 file changed, 1 insertion(+), 0 deletions(-)
diff --git a/src/sdis_misc.h b/src/sdis_misc.h
@@ -93,6 +93,7 @@ reflect_3d(float res[3], const float V[3], const float N[3])
cos_V_N = f3_dot(V, N);
f3_mulf(tmp, N, 2*cos_V_N);
f3_sub(res, tmp, V);
+ f3_normalize(res, res); /* Handle numerical issue */
return res;
}