aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/scattering.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/scattering.c b/src/scattering.c
index 5a7f7a9..c4babae 100644
--- a/src/scattering.c
+++ b/src/scattering.c
@@ -219,6 +219,10 @@ double get_probability(double beta, double cos_theta, double theta0)
* we are going to square it everywhere. */
sin_theta = sqrt(1-pow(cos_theta,2));
+ /* Make sure theta0 is less than MAX_THETA0, otherwise it's possible that
+ * gsl_spline2d_eval() will quit. */
+ if (theta0 > MAX_THETA0) theta0 = MAX_THETA0;
+
return gsl_spline2d_eval(spline, beta*cos_theta, beta*sin_theta*theta0, xacc, yacc)/(theta0*sin_theta);
}