public void ApplyQuaternion(Quaternion q) { Quaternion i = new Quaternion(); i.X = q.W * X + q.Y * Z - q.Z * Y; i.Y = q.W * Y + q.Z * X - q.X * Z; i.Z = q.W * Z + q.X * Y - q.Y * X; i.W = -q.X * X - q.Y * Y - q.Z * Z; X = i.X * q.W + i.W * -q.X + i.Y * -q.Z - i.Z * -q.Y; Y = i.Y * q.W + i.W * -q.Y + i.Z * -q.X - i.X * -q.Z; Z = i.Z * q.W + i.W * -q.Z + i.X * -q.Y - i.Y * -q.X; }
/// <summary> /// Creates a new quaternion that is the inverse of the specified quaternion. /// </summary> /// <param name="q">The quaternion to invert.</param> /// <returns>A new quaternion that is the inverse of the specified quaternion.</returns> public static Quaternion Invert(Quaternion q) { return new Quaternion(OTK.Quaternion.Invert(q.OpenTK)); }
/// <summary> /// Creates a new quaternion representing the spherical linear interpolation of two specified quaternions. /// </summary> /// <param name="a">The first quaternion.</param> /// <param name="b">The second quaternion.</param> /// <param name="blend">The degree of blending.</param> /// <returns>A new quaternion representing the slerp of the two specified quaternions.</returns> public static Quaternion Slerp(Quaternion a, Quaternion b, float blend) { return new Quaternion(OTK.Quaternion.Slerp(a.OpenTK, b.OpenTK, blend)); }
/// <summary> /// Creates a new quaternion representing the conjugate of the specified quaternion. /// </summary> /// <param name="q">The quaternion to conjugate.</param> /// <returns>A new quaternion representing the conjugate of the specified quaternion.</returns> public static Quaternion Conjugate(Quaternion q) { return new Quaternion(OTK.Quaternion.Conjugate(q.OpenTK)); }