diff options
author | Kevin Rushforth <[email protected]> | 2005-11-09 22:08:45 +0000 |
---|---|---|
committer | Kevin Rushforth <[email protected]> | 2005-11-09 22:08:45 +0000 |
commit | aaccc0e8b0a810bb3b71c76d6cf2c097468a9bb6 (patch) | |
tree | 9c93cb2bfba0d5b781aac6a8fd85648f27d66a39 /src | |
parent | 96e575b34c9f86538146608aa0426096b9c323e7 (diff) |
Issue number: 167
Fixed Issue 167 : Transform3D reports matrix with NaN to be affine
git-svn-id: https://svn.java.net/svn/j3d-core~svn/trunk@459 ba19aa83-45c5-6ac9-afd3-db810772062c
Diffstat (limited to 'src')
-rw-r--r-- | src/classes/share/javax/media/j3d/Transform3D.java | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/src/classes/share/javax/media/j3d/Transform3D.java b/src/classes/share/javax/media/j3d/Transform3D.java index 99920d4..2a069b6 100644 --- a/src/classes/share/javax/media/j3d/Transform3D.java +++ b/src/classes/share/javax/media/j3d/Transform3D.java @@ -498,15 +498,20 @@ public class Transform3D { /** * Returns the sign of the determinant of this matrix; a return value - * of true indicates a positive determinant; a return value of false - * indicates a negative determinant. In general, an orthogonal matrix + * of true indicates a non-negative determinant; a return value of false + * indicates a negative determinant. A value of true will be returned if + * the determinant is NaN. In general, an orthogonal matrix * with a positive determinant is a pure rotation matrix; an orthogonal * matrix with a negative determinant is a both a rotation and a * reflection matrix. - * @return determinant sign : true means positive, false means negative + * @return determinant sign : true means non-negative, false means negative */ public final boolean getDeterminantSign() { - return (determinant() >= 0); + double det = determinant(); + if (Double.isNaN(det)) { + return true; + } + return det >= 0; } /** @@ -571,11 +576,23 @@ public class Transform3D { } } + // Fix for Issue 167 -- don't classify matrices with Infinity or NaN values + // as affine + private final boolean isInfOrNaN() { + for (int i = 0; i < 16; i++) { + if (Double.isNaN(mat[i]) || Double.isInfinite(mat[i])) { + return true; + } + } + return false; + } + private final void classifyAffine() { - if (almostZero(mat[12]) && - almostZero(mat[13]) && - almostZero(mat[14]) && - almostOne(mat[15])) { + if (!isInfOrNaN() && + almostZero(mat[12]) && + almostZero(mat[13]) && + almostZero(mat[14]) && + almostOne(mat[15])) { type |= AFFINE; } else { type &= ~AFFINE; |