diff options
author | Sven Göthel <[email protected]> | 2024-02-14 15:34:55 +0100 |
---|---|---|
committer | Sven Göthel <[email protected]> | 2024-02-14 15:34:55 +0100 |
commit | 716e59a9286ebf6c8a215957ab4a74a2a81315e4 (patch) | |
tree | 6d2a0be866f5c61612de60385e01d48db74a9c48 /src/jogl/classes/com | |
parent | d4d4a797ab0e53db59dac1ea915825845861667e (diff) |
Use FloatUtil.isZero(a) w/ build-in FloatUtil.EPSILON directly instead of passing FloatUtil.EPSILON to explicit isZero(a, epsilon)
Diffstat (limited to 'src/jogl/classes/com')
-rw-r--r-- | src/jogl/classes/com/jogamp/math/Quaternion.java | 18 | ||||
-rw-r--r-- | src/jogl/classes/com/jogamp/math/VectorUtil.java | 6 |
2 files changed, 12 insertions, 12 deletions
diff --git a/src/jogl/classes/com/jogamp/math/Quaternion.java b/src/jogl/classes/com/jogamp/math/Quaternion.java index 683c1fadc..038745a51 100644 --- a/src/jogl/classes/com/jogamp/math/Quaternion.java +++ b/src/jogl/classes/com/jogamp/math/Quaternion.java @@ -182,7 +182,7 @@ public class Quaternion { */ public final Quaternion normalize() { final float norm = magnitude(); - if ( FloatUtil.isZero(norm, FloatUtil.EPSILON) ) { + if ( FloatUtil.isZero(norm) ) { setIdentity(); } else { final float invNorm = 1f/norm; @@ -331,7 +331,7 @@ public class Quaternion { * @return this quaternion for chaining. */ public Quaternion rotateByAngleNormalAxis(final float angle, final float axisX, final float axisY, final float axisZ) { - if( VectorUtil.isZero(axisX, axisY, axisZ, FloatUtil.EPSILON) ) { + if( VectorUtil.isZero(axisX, axisY, axisZ) ) { // no change return this; } @@ -458,7 +458,7 @@ public class Quaternion { * @see #setFromEuler(float, float, float) */ public final Quaternion rotateByEuler(final float bankX, final float headingY, final float attitudeZ) { - if ( VectorUtil.isZero(bankX, headingY, attitudeZ, FloatUtil.EPSILON) ) { + if ( VectorUtil.isZero(bankX, headingY, attitudeZ) ) { return this; } else { // setFromEuler muls: ( 8 + 4 ) , + quat muls 24 = 36 @@ -659,7 +659,7 @@ public class Quaternion { */ public final Quaternion setFromVectors(final Vec3f v1, final Vec3f v2, final Vec3f tmpPivotVec, final Vec3f tmpNormalVec) { final float factor = v1.length() * v2.length(); - if ( FloatUtil.isZero(factor, FloatUtil.EPSILON ) ) { + if ( FloatUtil.isZero(factor) ) { return setIdentity(); } else { final float dot = v1.dot(v2) / factor; // normalize @@ -667,7 +667,7 @@ public class Quaternion { tmpPivotVec.cross(v1, v2); - if ( dot < 0.0f && FloatUtil.isZero( tmpPivotVec.length(), FloatUtil.EPSILON ) ) { + if ( dot < 0.0f && FloatUtil.isZero( tmpPivotVec.length() ) ) { // Vectors parallel and opposite direction, therefore a rotation of 180 degrees about any vector // perpendicular to this vector will rotate vector a onto vector b. // @@ -714,7 +714,7 @@ public class Quaternion { */ public final Quaternion setFromNormalVectors(final Vec3f v1, final Vec3f v2, final Vec3f tmpPivotVec) { final float factor = v1.length() * v2.length(); - if ( FloatUtil.isZero(factor, FloatUtil.EPSILON ) ) { + if ( FloatUtil.isZero(factor) ) { return setIdentity(); } else { final float dot = v1.dot(v2) / factor; // normalize @@ -722,7 +722,7 @@ public class Quaternion { tmpPivotVec.cross(v1, v2); - if ( dot < 0.0f && FloatUtil.isZero( tmpPivotVec.length(), FloatUtil.EPSILON ) ) { + if ( dot < 0.0f && FloatUtil.isZero( tmpPivotVec.length() ) ) { // Vectors parallel and opposite direction, therefore a rotation of 180 degrees about any vector // perpendicular to this vector will rotate vector a onto vector b. // @@ -809,7 +809,7 @@ public class Quaternion { public final float toAngleAxis(final Vec3f axis) { final float sqrLength = x*x + y*y + z*z; float angle; - if ( FloatUtil.isZero(sqrLength, FloatUtil.EPSILON) ) { // length is ~0 + if ( FloatUtil.isZero(sqrLength) ) { // length is ~0 angle = 0.0f; axis.set( 1.0f, 0.0f, 0.0f ); } else { @@ -869,7 +869,7 @@ public class Quaternion { * @see #toEuler(Vec3f) */ public final Quaternion setFromEuler(final float bankX, final float headingY, final float attitudeZ) { - if ( VectorUtil.isZero(bankX, headingY, attitudeZ, FloatUtil.EPSILON) ) { + if ( VectorUtil.isZero(bankX, headingY, attitudeZ) ) { return setIdentity(); } else { float angle = headingY * 0.5f; diff --git a/src/jogl/classes/com/jogamp/math/VectorUtil.java b/src/jogl/classes/com/jogamp/math/VectorUtil.java index af2951956..14f03ab93 100644 --- a/src/jogl/classes/com/jogamp/math/VectorUtil.java +++ b/src/jogl/classes/com/jogamp/math/VectorUtil.java @@ -125,7 +125,7 @@ public final class VectorUtil { */ public static float[] normalizeVec3(final float[] vector) { final float lengthSq = normSquareVec3(vector); - if ( FloatUtil.isZero(lengthSq, FloatUtil.EPSILON) ) { + if ( FloatUtil.isZero(lengthSq) ) { vector[0] = 0f; vector[1] = 0f; vector[2] = 0f; @@ -145,7 +145,7 @@ public final class VectorUtil { */ public static float[] normalizeVec3(final float[] vector, final int offset) { final float lengthSq = normSquareVec3(vector, offset); - if ( FloatUtil.isZero(lengthSq, FloatUtil.EPSILON) ) { + if ( FloatUtil.isZero(lengthSq) ) { vector[0+offset] = 0f; vector[1+offset] = 0f; vector[2+offset] = 0f; @@ -284,7 +284,7 @@ public final class VectorUtil { * @return true if collinear, false otherwise */ public static boolean isCollinear(final Vec3f v1, final Vec3f v2, final Vec3f v3) { - return FloatUtil.isZero( determinant(v1, v2, v3), FloatUtil.EPSILON ); + return FloatUtil.isZero( determinant(v1, v2, v3) ); } public static final double InCircleDThreshold = DoubleUtil.EPSILON; |