aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2023-09-04 06:45:29 +0200
committerSven Gothel <[email protected]>2023-09-04 06:45:29 +0200
commite06d1d07125fb9489ea45d05fb40a562e2c4ca46 (patch)
treefc090c1dd6ae0d1e7a2dbb7be2dd7d2da458be77 /src/jogl/classes/com
parentba1c13b4eb4db2f15d2ee72d768748ab1f5d5639 (diff)
FloatUtil.abs(a): Mark as deprecated, use Math.abs(a) directly. We assume it is an intrinsic + branch-less implementation
Expected implementation is - return Float.intBitsToFloat(Float.floatToRawIntBits(a) & 0x7fffffff); replacing old implementation - return (a <= 0.0F) ? 0.0F - a : a; .. also market as @IntrinsicCandidate Hence we shall leave it to the JRE core-lib implementation...
Diffstat (limited to 'src/jogl/classes/com')
-rw-r--r--src/jogl/classes/com/jogamp/graph/geom/plane/AffineTransform.java10
-rw-r--r--src/jogl/classes/com/jogamp/graph/geom/plane/Crossing2F.java2
-rw-r--r--src/jogl/classes/com/jogamp/opengl/math/FloatUtil.java7
-rw-r--r--src/jogl/classes/com/jogamp/opengl/math/Quaternion.java14
4 files changed, 20 insertions, 13 deletions
diff --git a/src/jogl/classes/com/jogamp/graph/geom/plane/AffineTransform.java b/src/jogl/classes/com/jogamp/graph/geom/plane/AffineTransform.java
index 434746240..66d661990 100644
--- a/src/jogl/classes/com/jogamp/graph/geom/plane/AffineTransform.java
+++ b/src/jogl/classes/com/jogamp/graph/geom/plane/AffineTransform.java
@@ -276,11 +276,11 @@ public class AffineTransform implements Cloneable {
public final AffineTransform setToRotation(final float angle) {
float sin = FloatUtil.sin(angle);
float cos = FloatUtil.cos(angle);
- if (FloatUtil.abs(cos) < ZERO) {
+ if (Math.abs(cos) < ZERO) {
cos = 0.0f;
sin = sin > 0.0f ? 1.0f : -1.0f;
} else
- if (FloatUtil.abs(sin) < ZERO) {
+ if (Math.abs(sin) < ZERO) {
sin = 0.0f;
cos = cos > 0.0f ? 1.0f : -1.0f;
}
@@ -387,7 +387,7 @@ public class AffineTransform implements Cloneable {
public final AffineTransform createInverse() throws NoninvertibleTransformException {
final float det = getDeterminant();
- if (FloatUtil.abs(det) < ZERO) {
+ if (Math.abs(det) < ZERO) {
throw new NoninvertibleTransformException(determinantIsZero);
}
return new AffineTransform(
@@ -535,7 +535,7 @@ public class AffineTransform implements Cloneable {
*/
public final Vertex inverseTransform(final Vertex src, final Vertex dst) throws NoninvertibleTransformException {
final float det = getDeterminant();
- if (FloatUtil.abs(det) < ZERO) {
+ if (Math.abs(det) < ZERO) {
throw new NoninvertibleTransformException(determinantIsZero);
}
final float x = src.x() - m02;
@@ -548,7 +548,7 @@ public class AffineTransform implements Cloneable {
throws NoninvertibleTransformException
{
final float det = getDeterminant();
- if (FloatUtil.abs(det) < ZERO) {
+ if (Math.abs(det) < ZERO) {
throw new NoninvertibleTransformException(determinantIsZero);
}
diff --git a/src/jogl/classes/com/jogamp/graph/geom/plane/Crossing2F.java b/src/jogl/classes/com/jogamp/graph/geom/plane/Crossing2F.java
index 0cd4b66ff..7eb1d0bf0 100644
--- a/src/jogl/classes/com/jogamp/graph/geom/plane/Crossing2F.java
+++ b/src/jogl/classes/com/jogamp/graph/geom/plane/Crossing2F.java
@@ -106,7 +106,7 @@ import com.jogamp.opengl.math.FloatUtil;
res[rc++] = m * FloatUtil.cos(t - p) + n;
} else {
// Debug.println("R2 >= Q3 (" + R2 + "/" + Q3 + ")");
- float A = FloatUtil.pow(FloatUtil.abs(R) + FloatUtil.sqrt(R2 - Q3), 1.0f / 3.0f);
+ float A = FloatUtil.pow(Math.abs(R) + FloatUtil.sqrt(R2 - Q3), 1.0f / 3.0f);
if (R > 0.0) {
A = -A;
}
diff --git a/src/jogl/classes/com/jogamp/opengl/math/FloatUtil.java b/src/jogl/classes/com/jogamp/opengl/math/FloatUtil.java
index 901ed7181..c25abe188 100644
--- a/src/jogl/classes/com/jogamp/opengl/math/FloatUtil.java
+++ b/src/jogl/classes/com/jogamp/opengl/math/FloatUtil.java
@@ -1550,6 +1550,13 @@ public final class FloatUtil {
return Math.abs(a) < FloatUtil.EPSILON;
}
+ /**
+ * Invokes {@link Math#abs(float)}
+ * @param a float to process
+ * @return absolute value of {@code a}
+ * @deprecated use {@link Math#abs(float)} directly
+ */
+ @Deprecated
public static float abs(final float a) { return java.lang.Math.abs(a); }
public static float pow(final float a, final float b) { return (float) java.lang.Math.pow(a, b); }
diff --git a/src/jogl/classes/com/jogamp/opengl/math/Quaternion.java b/src/jogl/classes/com/jogamp/opengl/math/Quaternion.java
index be09d03af..0d04c69cc 100644
--- a/src/jogl/classes/com/jogamp/opengl/math/Quaternion.java
+++ b/src/jogl/classes/com/jogamp/opengl/math/Quaternion.java
@@ -1133,19 +1133,19 @@ public class Quaternion {
@Deprecated
public final boolean isRotationMatrix3f(final float[] m) {
final float epsilon = 0.01f; // margin to allow for rounding errors
- if (FloatUtil.abs(m[0] * m[3] + m[3] * m[4] + m[6] * m[7]) > epsilon)
+ if (Math.abs(m[0] * m[3] + m[3] * m[4] + m[6] * m[7]) > epsilon)
return false;
- if (FloatUtil.abs(m[0] * m[2] + m[3] * m[5] + m[6] * m[8]) > epsilon)
+ if (Math.abs(m[0] * m[2] + m[3] * m[5] + m[6] * m[8]) > epsilon)
return false;
- if (FloatUtil.abs(m[1] * m[2] + m[4] * m[5] + m[7] * m[8]) > epsilon)
+ if (Math.abs(m[1] * m[2] + m[4] * m[5] + m[7] * m[8]) > epsilon)
return false;
- if (FloatUtil.abs(m[0] * m[0] + m[3] * m[3] + m[6] * m[6] - 1) > epsilon)
+ if (Math.abs(m[0] * m[0] + m[3] * m[3] + m[6] * m[6] - 1) > epsilon)
return false;
- if (FloatUtil.abs(m[1] * m[1] + m[4] * m[4] + m[7] * m[7] - 1) > epsilon)
+ if (Math.abs(m[1] * m[1] + m[4] * m[4] + m[7] * m[7] - 1) > epsilon)
return false;
- if (FloatUtil.abs(m[2] * m[2] + m[5] * m[5] + m[8] * m[8] - 1) > epsilon)
+ if (Math.abs(m[2] * m[2] + m[5] * m[5] + m[8] * m[8] - 1) > epsilon)
return false;
- return (FloatUtil.abs(determinant3f(m) - 1) < epsilon);
+ return (Math.abs(determinant3f(m) - 1) < epsilon);
}
@Deprecated