aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com/jogamp/opengl/math/Quaternion.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2023-09-03 08:31:24 +0200
committerSven Gothel <[email protected]>2023-09-03 08:31:24 +0200
commit47233ea7014e34adca8a5c1d2323a57e9de1c7fa (patch)
tree8911ce16673237d6c6c568a5e4a68874c4ccb877 /src/jogl/classes/com/jogamp/opengl/math/Quaternion.java
parente6087583dc06c823f54bb6206af2acb0e2119b4c (diff)
FloatUtil.isEqual(..): Rename raw {isEqual->isEqualRaw}(a,b) varianr w/o EPSILON; Add isEqual(a,b) w/ default EPSILON; Use it where applicable
Also add isEqual2(a,b) w/o corner cases (NaN, Inf) used for comparison in Graph Outline, OutlineShape and later GraphUI Shape.
Diffstat (limited to 'src/jogl/classes/com/jogamp/opengl/math/Quaternion.java')
-rw-r--r--src/jogl/classes/com/jogamp/opengl/math/Quaternion.java16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/math/Quaternion.java b/src/jogl/classes/com/jogamp/opengl/math/Quaternion.java
index 9548a160a..be09d03af 100644
--- a/src/jogl/classes/com/jogamp/opengl/math/Quaternion.java
+++ b/src/jogl/classes/com/jogamp/opengl/math/Quaternion.java
@@ -90,10 +90,10 @@ public class Quaternion {
*/
public final float magnitude() {
final float magnitudeSQ = magnitudeSquared();
- if ( FloatUtil.isZero(magnitudeSQ, FloatUtil.EPSILON) ) {
+ if ( FloatUtil.isZero(magnitudeSQ) ) {
return 0f;
}
- if ( FloatUtil.isEqual(1f, magnitudeSQ, FloatUtil.EPSILON) ) {
+ if ( FloatUtil.isEqual(1f, magnitudeSQ) ) {
return 1f;
}
return FloatUtil.sqrt(magnitudeSQ);
@@ -149,13 +149,13 @@ public class Quaternion {
* Returns <code>true</code> if this quaternion has identity.
* <p>
* Implementation uses {@link FloatUtil#EPSILON epsilon} to compare
- * {@link #w() W} {@link FloatUtil#isEqual(float, float, float) against 1f} and
+ * {@link #w() W} {@link FloatUtil#isEqual(float, float) against 1f} and
* {@link #x() X}, {@link #y() Y} and {@link #z() Z}
- * {@link FloatUtil#isZero(float, float) against zero}.
+ * {@link FloatUtil#isZero(float) against zero}.
* </p>
*/
public final boolean isIdentity() {
- return FloatUtil.isEqual(1f, w, FloatUtil.EPSILON) && VectorUtil.isZero(x, y, z, FloatUtil.EPSILON);
+ return FloatUtil.isEqual(1f, w) && VectorUtil.isZero(x, y, z);
// return w == 1f && x == 0f && y == 0f && z == 0f;
}
@@ -217,7 +217,7 @@ public class Quaternion {
*/
public final Quaternion invert() {
final float magnitudeSQ = magnitudeSquared();
- if ( FloatUtil.isEqual(1.0f, magnitudeSQ, FloatUtil.EPSILON) ) {
+ if ( FloatUtil.isEqual(1.0f, magnitudeSQ) ) {
conjugate();
} else {
final float invmsq = 1f/magnitudeSQ;
@@ -1025,12 +1025,12 @@ public class Quaternion {
public final float[] toMatrix(final float[] matrix) {
// pre-multiply scaled-reciprocal-magnitude to reduce multiplications
final float norm = magnitudeSquared();
- if ( FloatUtil.isZero(norm, FloatUtil.EPSILON) ) {
+ if ( FloatUtil.isZero(norm) ) {
// identity matrix -> srecip = 0f
return FloatUtil.makeIdentity(matrix);
}
final float srecip;
- if ( FloatUtil.isEqual(1f, norm, FloatUtil.EPSILON) ) {
+ if ( FloatUtil.isEqual(1f, norm) ) {
srecip = 2f;
} else {
srecip = 2.0f / norm;