diff --git a/src/main/java/com/github/stephengold/joltjni/Quat.java b/src/main/java/com/github/stephengold/joltjni/Quat.java index 6744c1fd..4f81fcb9 100644 --- a/src/main/java/com/github/stephengold/joltjni/Quat.java +++ b/src/main/java/com/github/stephengold/joltjni/Quat.java @@ -25,7 +25,6 @@ of this software and associated documentation files (the "Software"), to deal import com.github.stephengold.joltjni.readonly.QuatArg; import com.github.stephengold.joltjni.readonly.Vec3Arg; import com.github.stephengold.joltjni.std.RandomNumberEngine; -import com.github.stephengold.joltjni.std.Std; import com.github.stephengold.joltjni.std.UniformFloatDistribution; import java.nio.FloatBuffer; @@ -170,12 +169,12 @@ public static Quat sEulerAngles(Vec3 angles) { float halfY = 0.5f * angles.getY(); float halfZ = 0.5f * angles.getZ(); - float cx = Std.cos(halfX); - float cy = Std.cos(halfY); - float cz = Std.cos(halfZ); - float sx = Std.sin(halfX); - float sy = Std.sin(halfY); - float sz = Std.sin(halfZ); + float cx = Jolt.cos(halfX); + float cy = Jolt.cos(halfY); + float cz = Jolt.cos(halfZ); + float sx = Jolt.sin(halfX); + float sy = Jolt.sin(halfY); + float sz = Jolt.sin(halfZ); Quat result = new Quat( cz * sx * cy - sz * cx * sy, @@ -240,10 +239,10 @@ public static Quat sRandom(RandomNumberEngine engine) { float px = 2f * Jolt.JPH_PI * distro.nextFloat(engine); float py = 2f * Jolt.JPH_PI * distro.nextFloat(engine); - float x = r1 * Std.sin(px); - float y = r1 * Std.cos(px); - float z = r2 * Std.sin(py); - float w = r2 * Std.cos(py); + float x = r1 * Jolt.sin(px); + float y = r1 * Jolt.cos(px); + float z = r2 * Jolt.sin(py); + float w = r2 * Jolt.cos(py); Quat result = new Quat(x, y, z, w); return result; @@ -259,8 +258,8 @@ public static Quat sRandom(RandomNumberEngine engine) { public static Quat sRotation(Vec3 axis, float angle) { assert axis.isNormalized(); - float qw = Std.cos(0.5f * angle); - float s = Std.sin(0.5f * angle); + float qw = Jolt.cos(0.5f * angle); + float s = Jolt.sin(0.5f * angle); float qx = axis.getX() * s; float qy = axis.getY() * s; float qz = axis.getZ() * s; diff --git a/src/main/java/com/github/stephengold/joltjni/Vec3.java b/src/main/java/com/github/stephengold/joltjni/Vec3.java index 1fd39199..ac99ec52 100644 --- a/src/main/java/com/github/stephengold/joltjni/Vec3.java +++ b/src/main/java/com/github/stephengold/joltjni/Vec3.java @@ -26,7 +26,6 @@ of this software and associated documentation files (the "Software"), to deal import com.github.stephengold.joltjni.readonly.UVec4Arg; import com.github.stephengold.joltjni.readonly.Vec3Arg; import com.github.stephengold.joltjni.std.RandomNumberEngine; -import com.github.stephengold.joltjni.std.Std; import com.github.stephengold.joltjni.std.UniformFloatDistribution; import java.nio.FloatBuffer; import java.util.Objects; @@ -427,10 +426,10 @@ public static Vec3 sum(Vec3Arg... vArray) { * @return a new unit vector */ public static Vec3 sUnitSpherical(float theta, float phi) { - float sinTheta = Std.sin(theta); - float vx = sinTheta * Std.cos(phi); - float vy = sinTheta * Std.sin(phi); - float vz = Std.cos(theta); + float sinTheta = Jolt.sin(theta); + float vx = sinTheta * Jolt.cos(phi); + float vy = sinTheta * Jolt.sin(phi); + float vz = Jolt.cos(theta); Vec3 result = new Vec3(vx, vy, vz); return result; diff --git a/src/main/java/com/github/stephengold/joltjni/std/Std.java b/src/main/java/com/github/stephengold/joltjni/std/Std.java index 4888a682..f566c46c 100644 --- a/src/main/java/com/github/stephengold/joltjni/std/Std.java +++ b/src/main/java/com/github/stephengold/joltjni/std/Std.java @@ -69,36 +69,6 @@ private Std() { // ************************************************************************* // new methods exposed - /** - * Return the inverse cosine of the specified single-precision ratio. - * There's evidence this is faster than {@link java.lang.Math#acos(double)} - * on Linux and Windows. - * - * @param ratio the input cosine ratio (≥-1, ≤1) - * @return the angle (in radians) - */ - native public static float acos(float ratio); - - /** - * Return the inverse tangent of the specified single-precision ratio. - * There's evidence this is faster than {@link java.lang.Math#atan(double)} - * on Linux and Windows. - * - * @param ratio the input tangent ratio - * @return the angle (in radians) - */ - native public static float atan(float ratio); - - /** - * Return the cosine of the specified single-precision angle. There's - * evidence this is faster than {@link java.lang.Math#cos(double)} on Linux - * and Windows. - * - * @param angle the input angle (in radians) - * @return the cosine ratio - */ - native public static float cos(float angle); - /** * Return the exponential of the specified single-precision value. There's * evidence this is faster than {@link java.lang.Math#exp(double)}. @@ -171,15 +141,6 @@ public static void shuffle( } } - /** - * Return the sine of the specified single-precision angle. There's evidence - * this is faster than {@link java.lang.Math#sin(double)}. - * - * @param angle the input angle (in radians) - * @return the sine ratio - */ - native public static float sin(float angle); - /** * Count the number of elements in the specified array. * @@ -212,14 +173,6 @@ public static int strcmp(String lhs, String rhs) { int result = lhs.compareTo(rhs); return result; } - - /** - * Return the tangent ratio of the specified single-precision angle. - * - * @param angle the input angle (in radians) - * @return the tangent ratio - */ - native public static float tan(float angle); // ************************************************************************* // native private methods diff --git a/src/main/native/glue/st/Std.cpp b/src/main/native/glue/st/Std.cpp index 8b7c359e..ba23db65 100644 --- a/src/main/native/glue/st/Std.cpp +++ b/src/main/native/glue/st/Std.cpp @@ -26,39 +26,6 @@ SOFTWARE. #include "Jolt/Jolt.h" #include "auto/com_github_stephengold_joltjni_std_Std.h" -/* - * Class: com_github_stephengold_joltjni_std_Std - * Method: acos - * Signature: (F)F - */ -JNIEXPORT jfloat JNICALL Java_com_github_stephengold_joltjni_std_Std_acos - (JNIEnv *, jclass, jfloat ratio) { - const float result = std::acos(ratio); - return result; -} - -/* - * Class: com_github_stephengold_joltjni_std_Std - * Method: atan - * Signature: (F)F - */ -JNIEXPORT jfloat JNICALL Java_com_github_stephengold_joltjni_std_Std_atan - (JNIEnv *, jclass, jfloat ratio) { - const float result = std::atan(ratio); - return result; -} - -/* - * Class: com_github_stephengold_joltjni_std_Std - * Method: cos - * Signature: (F)F - */ -JNIEXPORT jfloat JNICALL Java_com_github_stephengold_joltjni_std_Std_cos - (JNIEnv *, jclass, jfloat angle) { - const float result = std::cos(angle); - return result; -} - /* * Class: com_github_stephengold_joltjni_std_Std * Method: exp @@ -103,17 +70,6 @@ JNIEXPORT jfloat JNICALL Java_com_github_stephengold_joltjni_std_Std_pow return result; } -/* - * Class: com_github_stephengold_joltjni_std_Std - * Method: sin - * Signature: (F)F - */ -JNIEXPORT jfloat JNICALL Java_com_github_stephengold_joltjni_std_Std_sin - (JNIEnv *, jclass, jfloat angle) { - const float result = std::sin(angle); - return result; -} - /* * Class: com_github_stephengold_joltjni_std_Std * Method: sqrt @@ -125,17 +81,6 @@ JNIEXPORT jfloat JNICALL Java_com_github_stephengold_joltjni_std_Std_sqrt return result; } -/* - * Class: com_github_stephengold_joltjni_std_Std - * Method: tan - * Signature: (F)F - */ -JNIEXPORT jfloat JNICALL Java_com_github_stephengold_joltjni_std_Std_tan - (JNIEnv *, jclass, jfloat value) { - const float result = std::tan(value); - return result; -} - /* * Class: com_github_stephengold_joltjni_std_Std * Method: shuffle diff --git a/src/test/java/testjoltjni/app/performancetest/ConvexVsMeshScene.java b/src/test/java/testjoltjni/app/performancetest/ConvexVsMeshScene.java index 42b99875..8d01febe 100644 --- a/src/test/java/testjoltjni/app/performancetest/ConvexVsMeshScene.java +++ b/src/test/java/testjoltjni/app/performancetest/ConvexVsMeshScene.java @@ -1,5 +1,5 @@ /* -Copyright (c) 2024 Stephen Gold +Copyright (c) 2024-2025 Stephen Gold Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -22,7 +22,7 @@ of this software and associated documentation files (the "Software"), to deal package testjoltjni.app.performancetest; import com.github.stephengold.joltjni.*; import com.github.stephengold.joltjni.enumerate.*; -import static com.github.stephengold.joltjni.std.Std.*; +import static com.github.stephengold.joltjni.Jolt.*; /** * A line-for-line Java translation of the Jolt Physics "convex vs mesh scene" performance test. diff --git a/src/test/java/testjoltjni/app/performancetest/LargeMeshScene.java b/src/test/java/testjoltjni/app/performancetest/LargeMeshScene.java index 576f4e48..966cc800 100644 --- a/src/test/java/testjoltjni/app/performancetest/LargeMeshScene.java +++ b/src/test/java/testjoltjni/app/performancetest/LargeMeshScene.java @@ -1,5 +1,5 @@ /* -Copyright (c) 2024 Stephen Gold +Copyright (c) 2024-2025 Stephen Gold Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -22,7 +22,7 @@ of this software and associated documentation files (the "Software"), to deal package testjoltjni.app.performancetest; import com.github.stephengold.joltjni.*; import com.github.stephengold.joltjni.enumerate.*; -import static com.github.stephengold.joltjni.std.Std.*; +import static com.github.stephengold.joltjni.Jolt.*; import static testjoltjni.app.performancetest.PerformanceTest.Trace; /** diff --git a/src/test/java/testjoltjni/app/samples/general/ChangeMotionTypeTest.java b/src/test/java/testjoltjni/app/samples/general/ChangeMotionTypeTest.java index 8e4c616d..c2d1324c 100644 --- a/src/test/java/testjoltjni/app/samples/general/ChangeMotionTypeTest.java +++ b/src/test/java/testjoltjni/app/samples/general/ChangeMotionTypeTest.java @@ -1,5 +1,5 @@ /* -Copyright (c) 2024 Stephen Gold +Copyright (c) 2024-2025 Stephen Gold Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -23,7 +23,7 @@ of this software and associated documentation files (the "Software"), to deal import com.github.stephengold.joltjni.*; import com.github.stephengold.joltjni.enumerate.*; import testjoltjni.app.samples.*; -import static com.github.stephengold.joltjni.std.Std.*; +import static com.github.stephengold.joltjni.Jolt.*; /** * A line-for-line Java translation of the Jolt Physics change motion-type test. *