summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--3dmath.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/3dmath.c b/3dmath.c
index 866af09..9e7f7a1 100644
--- a/3dmath.c
+++ b/3dmath.c
@@ -43,10 +43,10 @@ sphere_intersect(float* restrict y, float* restrict r,
n[i] = y[i] - c[i];
}
- normalize(n);
+ float two_dot_nd_div_sq_n_mag = 2.0f * dot(n, d) / dot(n, n);
- for(i = 0; i < 3; ++i)
- r[i] = d[i] - 2 * dot(n, d) * n[i];
+ for (i = 0; i < 3; ++i)
+ r[i] = d[i] - two_dot_nd_div_sq_n_mag * n[i];
return t;
}