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 | |
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')
11 files changed, 23 insertions, 23 deletions
diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo20.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo20.java index dfd6f55e7..47c84c914 100644 --- a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo20.java +++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo20.java @@ -968,7 +968,7 @@ public class UISceneDemo20 implements GLEventListener { } else { System.err.println("Using default DPI of "+dpiV); } - if( 0 == renderModes && !FloatUtil.isZero(noAADPIThreshold, FloatUtil.EPSILON)) { + if( 0 == renderModes && !FloatUtil.isZero(noAADPIThreshold)) { final boolean noAA = dpiV >= noAADPIThreshold; final String noAAs = noAA ? " >= " : " < "; System.err.println("AUTO RenderMode: dpi "+dpiV+noAAs+noAADPIThreshold+" -> noAA "+noAA); diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UIShapeDemo01.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UIShapeDemo01.java index 834686bc2..a32606104 100644 --- a/src/demos/com/jogamp/opengl/demos/graph/ui/UIShapeDemo01.java +++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UIShapeDemo01.java @@ -424,7 +424,7 @@ public class UIShapeDemo01 implements GLEventListener { // final float[] translate = crossHair.getTranslate(); // final float[] objPosT = new float[] { objPosC[0]+translate[0], objPosC[1]+translate[1], objPosC[2]+translate[2] }; final Vec3f diff = winObjPos.minus(objPosC); - if( !FloatUtil.isZero(diff.x(), FloatUtil.EPSILON) || !FloatUtil.isZero(diff.y(), FloatUtil.EPSILON) ) { + if( !FloatUtil.isZero(diff.x()) || !FloatUtil.isZero(diff.y()) ) { System.err.println("CrossHair: Move.1: Win "+glWinX+"/"+glWinY+" -> Obj "+winObjPos+" -> diff "+diff); crossHair.move(diff.x(), diff.y(), 0f); } else { diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UITypeDemo01.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UITypeDemo01.java index bd36b7509..e016c002f 100644 --- a/src/demos/com/jogamp/opengl/demos/graph/ui/UITypeDemo01.java +++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UITypeDemo01.java @@ -482,7 +482,7 @@ public class UITypeDemo01 implements GLEventListener { // final float[] objPosT = new float[] { objPosC[0]+translate[0], objPosC[1]+translate[1], objPosC[2]+translate[2] }; final Vec3f diff = winObjPos.minus(objPosC); // final float dz = winObjPos[2] - objPosT[2]; - if( !FloatUtil.isZero(diff.x(), FloatUtil.EPSILON) || !FloatUtil.isZero(diff.y(), FloatUtil.EPSILON) ) { + if( !FloatUtil.isZero(diff.x()) || !FloatUtil.isZero(diff.y()) ) { System.err.println("CrossHair: Move.1: Win "+glWinX+"/"+glWinY+" -> Obj "+winObjPos+" -> diff "+diff); crossHair.move(diff.x(), diff.y(), 0f); } else { 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; diff --git a/src/newt/classes/jogamp/newt/MonitorModeProps.java b/src/newt/classes/jogamp/newt/MonitorModeProps.java index 06158a033..14d6cece4 100644 --- a/src/newt/classes/jogamp/newt/MonitorModeProps.java +++ b/src/newt/classes/jogamp/newt/MonitorModeProps.java @@ -470,7 +470,7 @@ public class MonitorModeProps { final MonitorDevice b = monitors.get(j); if( !b.isClone() ) { final float coverage = b.getViewport().coverage( a.getViewport() ); - if( FloatUtil.isZero( 1f - coverage, FloatUtil.EPSILON ) ) { + if( FloatUtil.isZero( 1f - coverage ) ) { ((MonitorDeviceImpl)b).setIsClone(true); if( Screen.DEBUG ) { System.err.printf("MonitorCloneTest[%d of %d]: %f -> _is_ covered%n", j, i, coverage); diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index ff333f720..fe92d9f38 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -2906,7 +2906,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer final float[] newPixelScale = new float[2]; final float[] maxPixelScale = new float[2]; { - if( FloatUtil.isZero(newPixelScaleRaw[0], FloatUtil.EPSILON) || FloatUtil.isZero(newPixelScaleRaw[1], FloatUtil.EPSILON) ) { + if( FloatUtil.isZero(newPixelScaleRaw[0]) || FloatUtil.isZero(newPixelScaleRaw[1]) ) { newPixelScale[0]= ScalableSurface.IDENTITY_PIXELSCALE; newPixelScale[1]= ScalableSurface.IDENTITY_PIXELSCALE; } else { diff --git a/src/newt/classes/jogamp/newt/driver/ios/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/ios/ScreenDriver.java index f617ffc04..b86b65dd5 100644 --- a/src/newt/classes/jogamp/newt/driver/ios/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/ios/ScreenDriver.java @@ -83,7 +83,7 @@ public class ScreenDriver extends ScreenImpl { for(int crtIdx=0; crtIdx<count; crtIdx++) { final int crt_id = crtIDs[crtIdx]; final float pixelScaleRaw = IOSUtil.GetScreenPixelScaleByScreenIdx(crt_id); - pixelScaleArray[crtIdx] = FloatUtil.isZero(pixelScaleRaw, FloatUtil.EPSILON) ? 1.0f : pixelScaleRaw; + pixelScaleArray[crtIdx] = FloatUtil.isZero(pixelScaleRaw) ? 1.0f : pixelScaleRaw; propsOrigArray[crtIdx] = getMonitorProps0(crt_id); if ( null == propsOrigArray[crtIdx] ) { throw new InternalError("Could not gather device props "+crtIdx+"/"+count+" -> "+Display.toHexString(crt_id)); diff --git a/src/newt/classes/jogamp/newt/driver/ios/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/ios/WindowDriver.java index 6aa4fdc9c..d6df3b2f1 100644 --- a/src/newt/classes/jogamp/newt/driver/ios/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/ios/WindowDriver.java @@ -66,10 +66,10 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl final float newPixelScaleRaw, final float maxPixelScaleRaw) { final float[] newPixelScale = new float[2]; { - final float _newPixelScale = FloatUtil.isZero(newPixelScaleRaw, FloatUtil.EPSILON) ? ScalableSurface.IDENTITY_PIXELSCALE : newPixelScaleRaw; + final float _newPixelScale = FloatUtil.isZero(newPixelScaleRaw) ? ScalableSurface.IDENTITY_PIXELSCALE : newPixelScaleRaw; newPixelScale[0]= _newPixelScale; newPixelScale[1]= _newPixelScale; - final float _maxPixelScale = FloatUtil.isZero(maxPixelScaleRaw, FloatUtil.EPSILON) ? ScalableSurface.IDENTITY_PIXELSCALE : maxPixelScaleRaw; + final float _maxPixelScale = FloatUtil.isZero(maxPixelScaleRaw) ? ScalableSurface.IDENTITY_PIXELSCALE : maxPixelScaleRaw; maxPixelScale[0]= _maxPixelScale; maxPixelScale[1]= _maxPixelScale; } diff --git a/src/newt/classes/jogamp/newt/driver/macosx/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/ScreenDriver.java index ec661e5f6..131de0d25 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/ScreenDriver.java @@ -89,7 +89,7 @@ public class ScreenDriver extends ScreenImpl { for(int crtIdx=0; crtIdx<count; crtIdx++) { final int crt_id = crtIDs[crtIdx]; final float pixelScaleRaw = OSXUtil.GetScreenPixelScaleByDisplayID(crt_id); - pixelScaleArray[crtIdx] = FloatUtil.isZero(pixelScaleRaw, FloatUtil.EPSILON) ? 1.0f : pixelScaleRaw; + pixelScaleArray[crtIdx] = FloatUtil.isZero(pixelScaleRaw) ? 1.0f : pixelScaleRaw; propsOrigArray[crtIdx] = getMonitorProps0(crt_id); if ( null == propsOrigArray[crtIdx] ) { throw new InternalError("Could not gather device props "+crtIdx+"/"+count+" -> "+Display.toHexString(crt_id)); diff --git a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java index e8383916e..fb1b483fc 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java @@ -73,10 +73,10 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl final float newPixelScaleRaw, final float maxPixelScaleRaw) { final float[] newPixelScale = new float[2]; { - final float _newPixelScale = FloatUtil.isZero(newPixelScaleRaw, FloatUtil.EPSILON) ? ScalableSurface.IDENTITY_PIXELSCALE : newPixelScaleRaw; + final float _newPixelScale = FloatUtil.isZero(newPixelScaleRaw) ? ScalableSurface.IDENTITY_PIXELSCALE : newPixelScaleRaw; newPixelScale[0]= _newPixelScale; newPixelScale[1]= _newPixelScale; - final float _maxPixelScale = FloatUtil.isZero(maxPixelScaleRaw, FloatUtil.EPSILON) ? ScalableSurface.IDENTITY_PIXELSCALE : maxPixelScaleRaw; + final float _maxPixelScale = FloatUtil.isZero(maxPixelScaleRaw) ? ScalableSurface.IDENTITY_PIXELSCALE : maxPixelScaleRaw; maxPixelScale[0]= _maxPixelScale; maxPixelScale[1]= _maxPixelScale; } |