Permalink
Browse files

add workaround for issue #29

  • Loading branch information...
1 parent 7fc066f commit 03e0fcd7fa62f80da3abb7572c01192910a8da57 @Dav1dde committed Mar 1, 2014
Showing with 4 additions and 1 deletion.
  1. +4 −1 gl3n/interpolate.d
View
5 gl3n/interpolate.d
@@ -31,7 +31,10 @@ T interp_spherical(T)(T a, T b, float t) if(is_vector!T || is_quaternion!T) {
static if(is_vector!T) {
real theta = acos(dot(a, b));
} else {
- real theta = acos(a.w * b.w + a.x * b.x + a.y * b.y + a.z * b.z);
+ real theta = acos(
+ // this is a workaround, acos returning -nan on certain values near +/-1
+ clamp(a.w * b.w + a.x * b.x + a.y * b.y + a.z * b.z, -1, 1)
+ );
}
if(almost_equal(theta, 0)) {

0 comments on commit 03e0fcd

Please sign in to comment.