aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2011-10-12 12:26:11 +0200
committerThomas White <taw@physics.org>2012-02-22 15:27:39 +0100
commitd8a4f7509d0b5937bc56441e77e9343c84a3b38b (patch)
treea82530e6057f14a3659b8f6bbd32908ca2f05381
parent7fbf10ef647003fd33677dec9d7c00e24a5a6fe8 (diff)
Avoid NaN shifts of divergence
-rw-r--r--src/post-refinement.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/post-refinement.c b/src/post-refinement.c
index 81ca8c61..97957840 100644
--- a/src/post-refinement.c
+++ b/src/post-refinement.c
@@ -142,6 +142,7 @@ double gradient(struct image *image, int k, Reflection *refl, double r)
den = sqrt(1.0 - cos(image->div/2.0));
gr += (nom/den) * g;
}
+ if ( isnan(gr) ) gr = 0.0; /* FIXME: This isn't true (?) */
return gr / 4.0; /* FIXME: Shameless fudge factor */
case REF_R :
@@ -216,8 +217,12 @@ static void apply_shift(struct image *image, int k, double shift)
switch ( k ) {
case REF_DIV :
- image->div += shift;
- if ( image->div < 0.0 ) image->div = 0.0;
+ if ( isnan(shift) ) {
+ ERROR("NaN divergence shift\n");
+ } else {
+ image->div += shift;
+ if ( image->div < 0.0 ) image->div = 0.0;
+ }
break;
case REF_R :