Browse Source

Fixed naming of pitch, yaw, roll thing in rotation that was wrong. Now they are named xAngle, yAngle, zAngle in Spatial and Quaternion. Pitch , Yaw, Roll are just mentionned in the javadoc.
There has been several posts about that, the last in date is here http://jmonkeyengine.org/groups/general-2/forum/topic/confused-about-euler-axes-and-jme-axes/#post-169736

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9271 75d07b2b-3a1a-0410-a2c5-0572b91ccdca

rem..om 13 years ago
parent
commit
a4c1fd7670

+ 27 - 27
engine/src/core/com/jme3/math/Quaternion.java

@@ -233,45 +233,45 @@ public final class Quaternion implements Savable, Cloneable, java.io.Serializabl
 
     /**
      * <code>fromAngles</code> builds a Quaternion from the Euler rotation
-     * angles (y,r,p). Note that we are applying in order: roll, pitch, yaw but
+     * angles (x,y,z) aka (pitch, yaw, rall)). Note that we are applying in order: roll, yaw, pitch but
      * we've ordered them in x, y, and z for convenience.
      * @see <a href="http://www.euclideanspace.com/maths/geometry/rotations/conversions/eulerToQuaternion/index.htm">http://www.euclideanspace.com/maths/geometry/rotations/conversions/eulerToQuaternion/index.htm</a>
      * 
-     * @param yaw
-     *            the Euler yaw of rotation (in radians). (aka Bank, often rot
+     * @param xAngle
+     *            the Euler pitch of rotation (in radians). (aka Bank, often rot
      *            around x)
-     * @param roll
-     *            the Euler roll of rotation (in radians). (aka Heading, often
+     * @param yAngle
+     *            the Euler yaw of rotation (in radians). (aka Heading, often
      *            rot around y)
-     * @param pitch
-     *            the Euler pitch of rotation (in radians). (aka Attitude, often
+     * @param zAngle
+     *            the Euler roll of rotation (in radians). (aka Attitude, often
      *            rot around z)
      */
-    public Quaternion fromAngles(float yaw, float roll, float pitch) {
+    public Quaternion fromAngles(float xAngle, float yAngle, float zAngle) {
         float angle;
-        float sinRoll, sinPitch, sinYaw, cosRoll, cosPitch, cosYaw;
-        angle = pitch * 0.5f;
-        sinPitch = FastMath.sin(angle);
-        cosPitch = FastMath.cos(angle);
-        angle = roll * 0.5f;
-        sinRoll = FastMath.sin(angle);
-        cosRoll = FastMath.cos(angle);
-        angle = yaw * 0.5f;
-        sinYaw = FastMath.sin(angle);
-        cosYaw = FastMath.cos(angle);
+        float sinY, sinZ, sinX, cosY, cosZ, cosX;
+        angle = zAngle * 0.5f;
+        sinZ = FastMath.sin(angle);
+        cosZ = FastMath.cos(angle);
+        angle = yAngle * 0.5f;
+        sinY = FastMath.sin(angle);
+        cosY = FastMath.cos(angle);
+        angle = xAngle * 0.5f;
+        sinX = FastMath.sin(angle);
+        cosX = FastMath.cos(angle);
 
         // variables used to reduce multiplication calls.
-        float cosRollXcosPitch = cosRoll * cosPitch;
-        float sinRollXsinPitch = sinRoll * sinPitch;
-        float cosRollXsinPitch = cosRoll * sinPitch;
-        float sinRollXcosPitch = sinRoll * cosPitch;
+        float cosYXcosZ = cosY * cosZ;
+        float sinYXsinZ = sinY * sinZ;
+        float cosYXsinZ = cosY * sinZ;
+        float sinYXcosZ = sinY * cosZ;
 
-        w = (cosRollXcosPitch * cosYaw - sinRollXsinPitch * sinYaw);
-        x = (cosRollXcosPitch * sinYaw + sinRollXsinPitch * cosYaw);
-        y = (sinRollXcosPitch * cosYaw + cosRollXsinPitch * sinYaw);
-        z = (cosRollXsinPitch * cosYaw - sinRollXcosPitch * sinYaw);
+        w = (cosYXcosZ * cosX - sinYXsinZ * sinX);
+        x = (cosYXcosZ * sinX + sinYXsinZ * cosX);
+        y = (sinYXcosZ * cosX + cosYXsinZ * sinX);
+        z = (cosYXsinZ * cosX - sinYXcosZ * sinX);
 
-        normalize();
+        normalizeLocal();
         return this;
     }
 

+ 4 - 4
engine/src/core/com/jme3/scene/Spatial.java

@@ -983,15 +983,15 @@ public abstract class Spatial implements Savable, Cloneable, Collidable, Asset {
     }
 
     /**
-     * Rotates the spatial by the yaw, roll and pitch angles (in radians),
-     * in the local coordinate space.
+     * Rotates the spatial by the xAngle, yAngle and zAngle angles (in radians),
+     * (aka pitch, yaw, roll) in the local coordinate space.
      *
      * @return The spatial on which this method is called, e.g <code>this</code>.
      */
-    public Spatial rotate(float yaw, float roll, float pitch) {
+    public Spatial rotate(float xAngle, float yAngle, float zAngle) {
         TempVars vars = TempVars.get();
         Quaternion q = vars.quat1;
-        q.fromAngles(yaw, roll, pitch);
+        q.fromAngles(xAngle, yAngle, zAngle);
         rotate(q);
         vars.release();