summaryrefslogtreecommitdiffstats
path: root/src/javax
diff options
context:
space:
mode:
authorKevin Rushforth <[email protected]>2004-09-17 20:18:20 +0000
committerKevin Rushforth <[email protected]>2004-09-17 20:18:20 +0000
commit38ae2822545700c0615a84551d472fe847f19b70 (patch)
treec4b502ee3f9a08f96d07c112717b1ea95a1d351e /src/javax
parent30ccf3450a6b317dc4eda061df6b5647a1df9745 (diff)
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
Diffstat (limited to 'src/javax')
-rw-r--r--src/javax/vecmath/Quat4d.java10
-rw-r--r--src/javax/vecmath/Quat4f.java10
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;