From 38ae2822545700c0615a84551d472fe847f19b70 Mon Sep 17 00:00:00 2001 From: Kevin Rushforth Date: Fri, 17 Sep 2004 20:18:20 +0000 Subject: Issue number: 73 Obtained from: herkules Submitted by: kcr Reviewed by: kcr Fix for Issue 73 (Quat4f#interpolate: incorrect when q1*q2<0) git-svn-id: https://svn.java.net/svn/vecmath~svn/trunk@17 dd45e54d-f42e-c781-df72-dca083a658b1 --- src/javax/vecmath/Quat4d.java | 10 ++++++---- src/javax/vecmath/Quat4f.java | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/javax/vecmath/Quat4d.java b/src/javax/vecmath/Quat4d.java index c6232f6..835e8e7 100644 --- a/src/javax/vecmath/Quat4d.java +++ b/src/javax/vecmath/Quat4d.java @@ -601,11 +601,12 @@ public class Quat4d extends Tuple4d implements java.io.Serializable { dot = x*q1.x + y*q1.y + z*q1.z + w*q1.w; if ( dot < 0 ) { - // switch the quaterion values + // negate quaternion q1.x = -q1.x; q1.y = -q1.y; q1.z = -q1.z; q1.w = -q1.w; + dot = -dot; } - if ( (1.0 - Math.abs(dot) ) > EPS ) { + if ( (1.0 - dot) > EPS ) { om = Math.acos(dot); sinom = Math.sin(om); s1 = Math.sin((1.0-alpha)*om)/sinom; @@ -640,11 +641,12 @@ public class Quat4d extends Tuple4d implements java.io.Serializable { dot = q2.x*q1.x + q2.y*q1.y + q2.z*q1.z + q2.w*q1.w; if ( dot < 0 ) { - // switch the quaterion values + // negate quaternion q1.x = -q1.x; q1.y = -q1.y; q1.z = -q1.z; q1.w = -q1.w; + dot = -dot; } - if ( (1.0 - Math.abs(dot) ) > EPS ) { + if ( (1.0 - dot) > EPS ) { om = Math.acos(dot); sinom = Math.sin(om); s1 = Math.sin((1.0-alpha)*om)/sinom; diff --git a/src/javax/vecmath/Quat4f.java b/src/javax/vecmath/Quat4f.java index f4fecfa..ecbef4b 100644 --- a/src/javax/vecmath/Quat4f.java +++ b/src/javax/vecmath/Quat4f.java @@ -606,11 +606,12 @@ public class Quat4f extends Tuple4f implements java.io.Serializable { dot = x*q1.x + y*q1.y + z*q1.z + w*q1.w; if ( dot < 0 ) { - // switch the quaterion values + // negate quaternion q1.x = -q1.x; q1.y = -q1.y; q1.z = -q1.z; q1.w = -q1.w; + dot = -dot; } - if ( (1.0 - Math.abs(dot) ) > EPS ) { + if ( (1.0 - dot) > EPS ) { om = Math.acos(dot); sinom = Math.sin(om); s1 = Math.sin((1.0-alpha)*om)/sinom; @@ -648,11 +649,12 @@ public class Quat4f extends Tuple4f implements java.io.Serializable { dot = q2.x*q1.x + q2.y*q1.y + q2.z*q1.z + q2.w*q1.w; if ( dot < 0 ) { - // switch the quaterion values + // negate quaternion q1.x = -q1.x; q1.y = -q1.y; q1.z = -q1.z; q1.w = -q1.w; + dot = -dot; } - if ( (1.0 - Math.abs(dot) ) > EPS ) { + if ( (1.0 - dot) > EPS ) { om = Math.acos(dot); sinom = Math.sin(om); s1 = Math.sin((1.0-alpha)*om)/sinom; -- cgit v1.2.3