- Fix to sphericalToCartesian and related methods that checks if store is null. If it is, store is created internally.

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10007 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
dan..om 12 years ago
parent 064908c69f
commit eea91e0b20
  1. 12
      engine/src/core/com/jme3/math/FastMath.java

@ -815,6 +815,9 @@ final public class FastMath {
*/
public static Vector3f sphericalToCartesian(Vector3f sphereCoords,
Vector3f store) {
if (store == null) {
store = new Vector3f();
}
store.y = sphereCoords.x * FastMath.sin(sphereCoords.z);
float a = sphereCoords.x * FastMath.cos(sphereCoords.z);
store.x = a * FastMath.cos(sphereCoords.y);
@ -830,6 +833,9 @@ final public class FastMath {
*/
public static Vector3f cartesianToSpherical(Vector3f cartCoords,
Vector3f store) {
if (store == null) {
store = new Vector3f();
}
float x = cartCoords.x;
if (x == 0) {
x = FastMath.FLT_EPSILON;
@ -851,6 +857,9 @@ final public class FastMath {
*/
public static Vector3f sphericalToCartesianZ(Vector3f sphereCoords,
Vector3f store) {
if (store == null) {
store = new Vector3f();
}
store.z = sphereCoords.x * FastMath.sin(sphereCoords.z);
float a = sphereCoords.x * FastMath.cos(sphereCoords.z);
store.x = a * FastMath.cos(sphereCoords.y);
@ -866,6 +875,9 @@ final public class FastMath {
*/
public static Vector3f cartesianZToSpherical(Vector3f cartCoords,
Vector3f store) {
if (store == null) {
store = new Vector3f();
}
float x = cartCoords.x;
if (x == 0) {
x = FastMath.FLT_EPSILON;

Loading…
Cancel
Save