diff --git a/engine/src/core/com/jme3/math/Quaternion.java b/engine/src/core/com/jme3/math/Quaternion.java index 5a5a1c9bd..fd4dc7fdd 100644 --- a/engine/src/core/com/jme3/math/Quaternion.java +++ b/engine/src/core/com/jme3/math/Quaternion.java @@ -233,45 +233,45 @@ public final class Quaternion implements Savable, Cloneable, java.io.Serializabl /** * fromAngles 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 http://www.euclideanspace.com/maths/geometry/rotations/conversions/eulerToQuaternion/index.htm * - * @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; } diff --git a/engine/src/core/com/jme3/scene/Spatial.java b/engine/src/core/com/jme3/scene/Spatial.java index 3785d6ec9..14880607d 100644 --- a/engine/src/core/com/jme3/scene/Spatial.java +++ b/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 this. */ - 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();