/** Get the swing rotation and twist rotation for the specified axis. The twist rotation represents the rotation around the * specified axis. The swing rotation represents the rotation of the specified axis itself, which is the rotation around an * axis perpendicular to the specified axis. </p> The swing and twist rotation can be used to reconstruct the original * quaternion: this = swing * twist * * @param axisX the X component of the normalized axis for which to get the swing and twist rotation * @param axisY the Y component of the normalized axis for which to get the swing and twist rotation * @param axisZ the Z component of the normalized axis for which to get the swing and twist rotation * @param swing will receive the swing rotation: the rotation around an axis perpendicular to the specified axis * @param twist will receive the twist rotation: the rotation around the specified axis * @see <a href="http://www.euclideanspace.com/maths/geometry/rotations/for/decomposition">calculation</a> */ public void getSwingTwist (final float axisX, final float axisY, final float axisZ, final Quaternion swing, final Quaternion twist) { final float d = Vector3.dot(this.x, this.y, this.z, axisX, axisY, axisZ); twist.set(axisX * d, axisY * d, axisZ * d, this.w).nor(); if (d < 0) twist.mul(-1f); swing.set(twist).conjugate().mulLeft(this); }
/** Get the swing rotation and twist rotation for the specified axis. The twist rotation represents the rotation around the * specified axis. The swing rotation represents the rotation of the specified axis itself, which is the rotation around an * axis perpendicular to the specified axis. </p> The swing and twist rotation can be used to reconstruct the original * quaternion: this = swing * twist * * @param axisX the X component of the normalized axis for which to get the swing and twist rotation * @param axisY the Y component of the normalized axis for which to get the swing and twist rotation * @param axisZ the Z component of the normalized axis for which to get the swing and twist rotation * @param swing will receive the swing rotation: the rotation around an axis perpendicular to the specified axis * @param twist will receive the twist rotation: the rotation around the specified axis * @see <a href="http://www.euclideanspace.com/maths/geometry/rotations/for/decomposition">calculation</a> */ public void getSwingTwist (final float axisX, final float axisY, final float axisZ, final Quaternion swing, final Quaternion twist) { final float d = Vector3.dot(this.x, this.y, this.z, axisX, axisY, axisZ); twist.set(axisX * d, axisY * d, axisZ * d, this.w).nor(); if (d < 0) twist.mul(-1f); swing.set(twist).conjugate().mulLeft(this); }
@Override public void rotate(Quaternion q) { localRotation.mulLeft(q); }
@Override public void rotate(float x, float y, float z, float w) { localRotation.mulLeft(x, y, z, w); }
/** Get the swing rotation and twist rotation for the specified axis. The twist rotation represents the rotation around the * specified axis. The swing rotation represents the rotation of the specified axis itself, which is the rotation around an * axis perpendicular to the specified axis. * </p> * The swing and twist rotation can be used to reconstruct the original quaternion: this = swing * twist * * @param axisX the X component of the normalized axis for which to get the swing and twist rotation * @param axisY the Y component of the normalized axis for which to get the swing and twist rotation * @param axisZ the Z component of the normalized axis for which to get the swing and twist rotation * @param swing will receive the swing rotation: the rotation around an axis perpendicular to the specified axis * @param twist will receive the twist rotation: the rotation around the specified axis * @see <a href="http://www.euclideanspace.com/maths/geometry/rotations/for/decomposition">calculation</a> */ public void getSwingTwist (final float axisX, final float axisY, final float axisZ, final Quaternion swing, final Quaternion twist) { final float d = Vector3.dot(this.x, this.y, this.z, axisX, axisY, axisZ); twist.set(axisX * d, axisY * d, axisZ * d, this.w).nor(); swing.set(twist).conjugate().mulLeft(this); }
/** Get the swing rotation and twist rotation for the specified axis. The twist rotation represents the rotation around the * specified axis. The swing rotation represents the rotation of the specified axis itself, which is the rotation around an * axis perpendicular to the specified axis. </p> The swing and twist rotation can be used to reconstruct the original * quaternion: this = swing * twist * * @param axisX the X component of the normalized axis for which to get the swing and twist rotation * @param axisY the Y component of the normalized axis for which to get the swing and twist rotation * @param axisZ the Z component of the normalized axis for which to get the swing and twist rotation * @param swing will receive the swing rotation: the rotation around an axis perpendicular to the specified axis * @param twist will receive the twist rotation: the rotation around the specified axis * @see <a href="http://www.euclideanspace.com/maths/geometry/rotations/for/decomposition">calculation</a> */ public void getSwingTwist (final float axisX, final float axisY, final float axisZ, final Quaternion swing, final Quaternion twist) { final float d = Vector3.dot(this.x, this.y, this.z, axisX, axisY, axisZ); twist.set(axisX * d, axisY * d, axisZ * d, this.w).nor(); if (d < 0) twist.mul(-1f); swing.set(twist).conjugate().mulLeft(this); }