/// <summary> /// Creates a rotation matrix from the provided euler angle (pitch/yaw/roll) rotation. /// </summary> /// <param name="xAngle">Pitch angle of rotation.</param> /// <param name="yAngle">Yar angle of rotation.</param> /// <param name="zAngle">Roll angle of rotation.</param> /// <param name="order">The order in which rotations will be applied. Different rotations can be created depending /// on the order.</param> /// <returns>Rotation matrix that can rotate an object to the specified angles.</returns> public static Matrix3 FromEuler(Radian xAngle, Radian yAngle, Radian zAngle, EulerAngleOrder order) { EulerAngleOrderData l = EA_LOOKUP[(int)order]; Matrix3[] mats = new Matrix3[3]; float cx = MathEx.Cos(xAngle); float sx = MathEx.Sin(xAngle); mats[0] = new Matrix3( 1.0f, 0.0f, 0.0f, 0.0f, cx, -sx, 0.0f, sx, cx); float cy = MathEx.Cos(yAngle); float sy = MathEx.Sin(yAngle); mats[1] = new Matrix3( cy, 0.0f, sy, 0.0f, 1.0f, 0.0f, -sy, 0.0f, cy); float cz = MathEx.Cos(zAngle); float sz = MathEx.Sin(zAngle); mats[2] = new Matrix3( cz, -sz, 0.0f, sz, cz, 0.0f, 0.0f, 0.0f, 1.0f); return(mats[l.a] * (mats[l.b] * mats[l.c])); }
/// <summary> /// Creates a quaternion from the provided euler angle (pitch/yaw/roll) rotation. /// </summary> /// <param name="xAngle">Pitch angle of rotation.</param> /// <param name="yAngle">Yar angle of rotation.</param> /// <param name="zAngle">Roll angle of rotation.</param> /// <param name="order">The order in which rotations will be applied. Different rotations can be created depending /// on the order.</param> /// <returns>Quaternion that can rotate an object to the specified angles.</returns> public static Quaternion FromEuler(Degree xAngle, Degree yAngle, Degree zAngle, EulerAngleOrder order = EulerAngleOrder.YXZ) { EulerAngleOrderData l = EA_LOOKUP[(int)order]; Radian halfXAngle = xAngle * 0.5f; Radian halfYAngle = yAngle * 0.5f; Radian halfZAngle = zAngle * 0.5f; float cx = MathEx.Cos(halfXAngle); float sx = MathEx.Sin(halfXAngle); float cy = MathEx.Cos(halfYAngle); float sy = MathEx.Sin(halfYAngle); float cz = MathEx.Cos(halfZAngle); float sz = MathEx.Sin(halfZAngle); Quaternion[] quats = new Quaternion[3]; quats[0] = new Quaternion(sx, 0.0f, 0.0f, cx); quats[1] = new Quaternion(0.0f, sy, 0.0f, cy); quats[2] = new Quaternion(0.0f, 0.0f, sz, cz); return((quats[l.a] * quats[l.b]) * quats[l.c]); }
/// <summary> /// Creates a rotation matrix from the provided euler angle (pitch/yaw/roll) rotation. /// </summary> /// <param name="euler">Euler angles in degrees.</param> /// <param name="order">The order in which rotations will be applied. Different rotations can be created depending /// on the order.</param> /// <returns>Rotation matrix that can rotate an object to the specified angles.</returns> public static Matrix3 FromEuler(Vector3 euler, EulerAngleOrder order) { return(FromEuler(new Degree(euler.x), new Degree(euler.y), new Degree(euler.y), order)); }
/// <summary> /// Creates a quaternion from the provided euler angle (pitch/yaw/roll) rotation. /// </summary> /// <param name="euler">Euler angles in degrees.</param> /// <param name="order">The order in which rotations will be applied. Different rotations can be created depending /// on the order.</param> /// <returns>Quaternion that can rotate an object to the specified angles.</returns> public static Quaternion FromEuler(Vector3 euler, EulerAngleOrder order = EulerAngleOrder.YXZ) { return(FromEuler((Degree)euler.x, (Degree)euler.y, (Degree)euler.z, order)); }
/// <summary> /// Constructor</summary> /// <param name="angles">Array of 3 floats to supply the Euler angles on /// the x, y, and z axes</param> /// <param name="order">Order that the rotations should be applied</param> public EulerAngles3F(float[] angles, EulerAngleOrder order) { m_Angles = new Vec3F(angles); m_Order = order; }
/// <summary> /// Creates a quaternion from the provided euler angle (pitch/yaw/roll) rotation. /// </summary> /// <param name="euler">Euler angles in degrees.</param> /// <param name="order">The order in which rotations will be applied. Different rotations can be created depending /// on the order.</param> /// <returns>Quaternion that can rotate an object to the specified angles.</returns> public static Quaternion FromEuler(Vector3 euler, EulerAngleOrder order = EulerAngleOrder.YXZ) { return FromEuler((Degree)euler.x, (Degree)euler.y, (Degree)euler.z, order); }
/// <summary> /// Constructor</summary> /// <param name="angles">Euler angles on the x, y, and z axes</param> /// <param name="order">Order that the rotations should be applied</param> public EulerAngles3F(Vec3F angles, EulerAngleOrder order) { m_Angles = angles; m_Order = order; }
/// <summary> /// Creates a quaternion from the provided euler angle (pitch/yaw/roll) rotation. /// </summary> /// <param name="xAngle">Pitch angle of rotation.</param> /// <param name="yAngle">Yar angle of rotation.</param> /// <param name="zAngle">Roll angle of rotation.</param> /// <param name="order">The order in which rotations will be applied. Different rotations can be created depending /// on the order.</param> /// <returns>Quaternion that can rotate an object to the specified angles.</returns> public static Quaternion FromEuler(Degree xAngle, Degree yAngle, Degree zAngle, EulerAngleOrder order = EulerAngleOrder.YXZ) { EulerAngleOrderData l = EA_LOOKUP[(int)order]; Radian halfXAngle = xAngle * 0.5f; Radian halfYAngle = yAngle * 0.5f; Radian halfZAngle = zAngle * 0.5f; float cx = MathEx.Cos(halfXAngle); float sx = MathEx.Sin(halfXAngle); float cy = MathEx.Cos(halfYAngle); float sy = MathEx.Sin(halfYAngle); float cz = MathEx.Cos(halfZAngle); float sz = MathEx.Sin(halfZAngle); Quaternion[] quats = new Quaternion[3]; quats[0] = new Quaternion(sx, 0.0f, 0.0f, cx); quats[1] = new Quaternion(0.0f, sy, 0.0f, cy); quats[2] = new Quaternion(0.0f, 0.0f, sz, cz); return (quats[l.a] * quats[l.b]) * quats[l.c]; }
private static extern QuaternionCurve Internal_eulerToQuaternionCurve(Vector3Curve eulerCurve, EulerAngleOrder order);
/// <summary>Converts a curve in euler angles (in degrees) into a curve using quaternions.</summary> public static QuaternionCurve EulerToQuaternionCurve(Vector3Curve eulerCurve, EulerAngleOrder order = EulerAngleOrder.YXZ) { return(Internal_eulerToQuaternionCurve(eulerCurve, order)); }