Skip to content

Commit ddf1460

Browse files
Fix the issue #1349 (#1573)
* Fix the issue #1349 * Unify the definition of y and z in the Spherical coordinates that using positive Z as up.
1 parent d5f74b9 commit ddf1460

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

jme3-core/src/main/java/com/jme3/math/FastMath.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -933,7 +933,7 @@ public static Vector3f cartesianToSpherical(Vector3f cartCoords,
933933
* Z as up) and stores the results in the store var.
934934
*
935935
* @param sphereCoords the input spherical coordinates: x=distance from
936-
* origin, y=longitude in radians, z=latitude in radians (not null,
936+
* origin, y=latitude in radians, z=longitude in radians (not null,
937937
* unaffected)
938938
* @param store storage for the result (modified if not null)
939939
* @return the Cartesian coordinates (either store or a new vector)
@@ -943,10 +943,10 @@ public static Vector3f sphericalToCartesianZ(Vector3f sphereCoords,
943943
if (store == null) {
944944
store = new Vector3f();
945945
}
946-
store.z = sphereCoords.x * FastMath.sin(sphereCoords.z);
947-
float a = sphereCoords.x * FastMath.cos(sphereCoords.z);
948-
store.x = a * FastMath.cos(sphereCoords.y);
949-
store.y = a * FastMath.sin(sphereCoords.y);
946+
store.y = sphereCoords.x * FastMath.sin(sphereCoords.y);
947+
float a = sphereCoords.x * FastMath.cos(sphereCoords.y);
948+
store.x = a * FastMath.cos(sphereCoords.z);
949+
store.z = a * FastMath.sin(sphereCoords.z);
950950

951951
return store;
952952
}

jme3-core/src/test/java/com/jme3/math/FastMathTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,6 @@ public void testCartesianToSpherical() {
227227
assertEquals(in0.z, out0.z, 1e-5f);
228228
}
229229

230-
@Ignore // test fails due to issue #1349
231230
@Test
232231
public void testCartesianZToSpherical() {
233232
final Vector3f cartCoords = new Vector3f(1.1f, 5.8f, 8.1f);

0 commit comments

Comments
 (0)