packages/dev/core/src/Maths/math.vector.ts
public static RotationYawPitchRollToRef<T extends Quaternion>(yaw: number, pitch: number, roll: number, result: T): T {
// Produces a quaternion from Euler angles in the z-y-x orientation (Tait-Bryan angles)
const halfRoll = roll * 0.5;
const halfPitch = pitch * 0.5;
const halfYaw = yaw * 0.5;
const sinRoll = Math.sin(halfRoll);
const cosRoll = Math.cos(halfRoll);
const sinPitch = Math.sin(halfPitch);
const cosPitch = Math.cos(halfPitch);
const sinYaw = Math.sin(halfYaw);
const cosYaw = Math.cos(halfYaw);
result._x = cosYaw * sinPitch * cosRoll + sinYaw * cosPitch * sinRoll;
result._y = sinYaw * cosPitch * cosRoll - cosYaw * sinPitch * sinRoll;
result._z = cosYaw * cosPitch * sinRoll - sinYaw * sinPitch * cosRoll;
result._w = cosYaw * cosPitch * cosRoll + sinYaw * sinPitch * sinRoll;
result._isDirty = true;
return result;
}
Hi, in the source code I see this comment that claims z-y-x orientation but I think the math here indicates YXZ (which is what the docs say as well). Is the comment wrong or am I missing something?
q = (x,y,z,w) = ( cy*sx*cz + sy*cx*sz, sy*cx*cz - cy*sx*sz, cy*cx*sz - sy*sx*cz, cy*cx*cz + sy*sx*sz ) where sy=sin(yaw/2), cy=cos(yaw/2), sx=sin(pitch/2), cx=cos(pitch/2), sz=sin(roll/2), cz=cos(roll/2). extrinsic YXZ, intrinsic ZXY, not zyx