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
3.0
rem..om 13 years ago
parent 3dc9a591b7
commit a4c1fd7670
  1. 54
      engine/src/core/com/jme3/math/Quaternion.java
  2. 8
      engine/src/core/com/jme3/scene/Spatial.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 * <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. * 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> * @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 * @param xAngle
* the Euler yaw of rotation (in radians). (aka Bank, often rot * the Euler pitch of rotation (in radians). (aka Bank, often rot
* around x) * around x)
* @param roll * @param yAngle
* the Euler roll of rotation (in radians). (aka Heading, often * the Euler yaw of rotation (in radians). (aka Heading, often
* rot around y) * rot around y)
* @param pitch * @param zAngle
* the Euler pitch of rotation (in radians). (aka Attitude, often * the Euler roll of rotation (in radians). (aka Attitude, often
* rot around z) * rot around z)
*/ */
public Quaternion fromAngles(float yaw, float roll, float pitch) { public Quaternion fromAngles(float xAngle, float yAngle, float zAngle) {
float angle; float angle;
float sinRoll, sinPitch, sinYaw, cosRoll, cosPitch, cosYaw; float sinY, sinZ, sinX, cosY, cosZ, cosX;
angle = pitch * 0.5f; angle = zAngle * 0.5f;
sinPitch = FastMath.sin(angle); sinZ = FastMath.sin(angle);
cosPitch = FastMath.cos(angle); cosZ = FastMath.cos(angle);
angle = roll * 0.5f; angle = yAngle * 0.5f;
sinRoll = FastMath.sin(angle); sinY = FastMath.sin(angle);
cosRoll = FastMath.cos(angle); cosY = FastMath.cos(angle);
angle = yaw * 0.5f; angle = xAngle * 0.5f;
sinYaw = FastMath.sin(angle); sinX = FastMath.sin(angle);
cosYaw = FastMath.cos(angle); cosX = FastMath.cos(angle);
// variables used to reduce multiplication calls. // variables used to reduce multiplication calls.
float cosRollXcosPitch = cosRoll * cosPitch; float cosYXcosZ = cosY * cosZ;
float sinRollXsinPitch = sinRoll * sinPitch; float sinYXsinZ = sinY * sinZ;
float cosRollXsinPitch = cosRoll * sinPitch; float cosYXsinZ = cosY * sinZ;
float sinRollXcosPitch = sinRoll * cosPitch; float sinYXcosZ = sinY * cosZ;
w = (cosRollXcosPitch * cosYaw - sinRollXsinPitch * sinYaw); w = (cosYXcosZ * cosX - sinYXsinZ * sinX);
x = (cosRollXcosPitch * sinYaw + sinRollXsinPitch * cosYaw); x = (cosYXcosZ * sinX + sinYXsinZ * cosX);
y = (sinRollXcosPitch * cosYaw + cosRollXsinPitch * sinYaw); y = (sinYXcosZ * cosX + cosYXsinZ * sinX);
z = (cosRollXsinPitch * cosYaw - sinRollXcosPitch * sinYaw); z = (cosYXsinZ * cosX - sinYXcosZ * sinX);
normalize(); normalizeLocal();
return this; return this;
} }

@ -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), * Rotates the spatial by the xAngle, yAngle and zAngle angles (in radians),
* in the local coordinate space. * (aka pitch, yaw, roll) in the local coordinate space.
* *
* @return The spatial on which this method is called, e.g <code>this</code>. * @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(); TempVars vars = TempVars.get();
Quaternion q = vars.quat1; Quaternion q = vars.quat1;
q.fromAngles(yaw, roll, pitch); q.fromAngles(xAngle, yAngle, zAngle);
rotate(q); rotate(q);
vars.release(); vars.release();

Loading…
Cancel
Save