/// <summary> /// Transforms a vector by a quaternion rotation. /// </summary> /// <param name="vec">The vector to transform.</param> /// <param name="quat">The quaternion to rotate the vector by.</param> /// <param name="result">The result of the operation.</param> public static void Transform(ref Vector2d vec, ref Quaterniond quat, out Vector2d result) { Quaterniond v = new Quaterniond(vec.X, vec.Y, 0, 0), i, t; Quaterniond.Invert(ref quat, out i); Quaterniond.Multiply(ref quat, ref v, out t); Quaterniond.Multiply(ref t, ref i, out v); result = new Vector2d(v.X, v.Y); }
public static void Transform(ref Vector2d vec, ref Quaterniond quat, out Vector2d result) { Quaterniond result1 = new Quaterniond(vec.X, vec.Y, 0.0, 0.0); Quaterniond result2; Quaterniond.Invert(ref quat, out result2); Quaterniond result3; Quaterniond.Multiply(ref quat, ref result1, out result3); Quaterniond.Multiply(ref result3, ref result2, out result1); result = new Vector2d(result1.X, result1.Y); }