Esempio n. 1
0
        public void SquadSetupTest()
        {
            Quaternion value1 = Utilities.GenerateQuaternion();
            Quaternion value2 = Utilities.GenerateQuaternion();
            Quaternion value3 = Utilities.GenerateQuaternion();
            Quaternion value4 = Utilities.GenerateQuaternion();

            Quaternion[] expected             = new Quaternion[3];
            Microsoft.DirectX.Quaternion outa = new Microsoft.DirectX.Quaternion();
            Microsoft.DirectX.Quaternion outb = new Microsoft.DirectX.Quaternion();
            Microsoft.DirectX.Quaternion outc = new Microsoft.DirectX.Quaternion();
            Microsoft.DirectX.Quaternion.SquadSetup(
                ref outa,
                ref outb,
                ref outc,
                Utilities.ConvertToMdx(value1),
                Utilities.ConvertToMdx(value2),
                Utilities.ConvertToMdx(value3),
                Utilities.ConvertToMdx(value4));
            expected[0] = Utilities.ConvertFrom(outa);
            expected[1] = Utilities.ConvertFrom(outb);
            expected[2] = Utilities.ConvertFrom(outc);

            Quaternion[] actual;
            actual = Quaternion.SquadSetup(value1, value2, value3, value4);

            Assert.IsNotNull(actual);
            Assert.IsTrue(expected.Length == actual.Length);

            for (int i = 0; i < expected.Length; ++i)
            {
                Utilities.AreEqual(expected[i], actual[i]);
            }
        }
Esempio n. 2
0
 public static Quaternion ConvertFrom(Microsoft.DirectX.Quaternion value)
 {
     return(new Quaternion()
     {
         X = value.X,
         Y = value.Y,
         Z = value.Z,
         W = value.W
     });
 }
Esempio n. 3
0
        private void TestRotations()
        {
            Matrix3 rotx = Matrix3.RotateX(Pitch);
            Matrix3 roty = Matrix3.RotateY(Yaw);
            Matrix3 rotz = Matrix3.RotateZ(Roll);
            DXMtx dxrotx = DXMtx.RotationX(Pitch);
            DXMtx dxroty = DXMtx.RotationY(Yaw);
            DXMtx dxrotz = DXMtx.RotationZ(Roll);

            BasicRotations = new Matrix3[2];
            BasicRotations[0] = rotz * rotx * roty;
            BasicRotations[1] = DXMtxToMtx3(DXMtx.Multiply(DXMtx.Multiply(dxrotz, dxrotx), dxroty));

            EulerRotations = new Matrix3[2];
            EulerRotations[0] = Matrix3.RotateEuler(Yaw, Pitch, Roll);
            EulerRotations[1] = DXMtxToMtx3(DXMtx.RotationYawPitchRoll(Yaw, Pitch, Roll));

            Matrix3.GetAxisAngle(EulerRotations[0], out RotationAxis, out RotationAngle);
            AxisAngleRotations = new Matrix3[2];
            AxisAngleRotations[0] = Matrix3.RotateAxisAngle(RotationAxis, RotationAngle);
            AxisAngleRotations[1] = DXMtxToMtx3(DXMtx.RotationAxis(new Microsoft.DirectX.Vector3(RotationAxis.x, RotationAxis.y, RotationAxis.z), RotationAngle));

            Quaternion quat = new Quaternion(RotationAngle, RotationAxis);
            Microsoft.DirectX.Quaternion dxquat = new Microsoft.DirectX.Quaternion(quat.x, quat.y, quat.z, quat.w);
            QuaternionRotations = new Matrix3[2];
            QuaternionRotations[0] = Matrix3.RotateQuaternion(quat);
            QuaternionRotations[1] = DXMtxToMtx3(DXMtx.RotationQuaternion(dxquat));
        }
Esempio n. 4
0
 /// <summary>
 /// Set the Rotation Parameters
 /// </summary>
 /// <param name="q"></param>
 public void SetRotation(Microsoft.DirectX.Quaternion q)
 {
     mset = false;
     r    = q;
 }
Esempio n. 5
0
 private Quaternion DXQToQ(DXQuat q)
 {
     return new Quaternion(q.W, q.X, q.Y, q.Z);
 }
Esempio n. 6
0
 private void TestNormalize()
 {
     Quaternion q = new Quaternion(1, 2, 3, 4);
     DXQuat dxq = new DXQuat(2, 3, 4, 1);
     q.Normalize();
     dxq.Normalize();
     NormalizeResults = new Quaternion[2];
     NormalizeResults[0] = q;
     NormalizeResults[1] = DXQToQ(dxq);
 }
Esempio n. 7
0
 /// <summary>
 /// Converts a <see cref="Microsoft.DirectX.Quaternion"/> to <see cref="Fusee.Math.Core.QuaternionF"/>.
 /// </summary>
 /// <param name="value">The matrix value to convert.</param>
 /// <returns>A <see cref="Fusee.Math.Core.QuaternionF"/> value.</returns>
 public static Fusee.Math.Core.QuaternionF FromDirectX(Microsoft.DirectX.Quaternion value)
 {
     return(new Fusee.Math.Core.QuaternionF(value.X, value.Y, value.Z, value.W));
 }