示例#1
0
        public void BarycentricByRefTest()
        {
            Quaternion value1         = Utilities.GenerateQuaternion();
            Quaternion value1Expected = value1;
            Quaternion value2         = Utilities.GenerateQuaternion();
            Quaternion value2Expected = value2;
            Quaternion value3         = Utilities.GenerateQuaternion();
            Quaternion value3Expected = value3;
            float      amount1        = Utilities.GenerateFloat();
            float      amount2        = Utilities.GenerateFloat();
            Quaternion result;

            Quaternion resultExpected = Utilities.ConvertFrom(Microsoft.DirectX.Quaternion.BaryCentric(
                                                                  Utilities.ConvertToMdx(value1),
                                                                  Utilities.ConvertToMdx(value2),
                                                                  Utilities.ConvertToMdx(value3),
                                                                  amount1,
                                                                  amount2));

            Quaternion.Barycentric(ref value1, ref value2, ref value3, amount1, amount2, out result);
            Utilities.AreEqual(value1Expected, value1);
            Utilities.AreEqual(value2Expected, value2);
            Utilities.AreEqual(value3Expected, value3);
            Utilities.AreEqual(resultExpected, result);
        }
示例#2
0
        public void SquadByRefTest()
        {
            Quaternion value1         = Utilities.GenerateQuaternion();
            Quaternion value1Expected = value1;
            Quaternion value2         = Utilities.GenerateQuaternion();
            Quaternion value2Expected = value2;
            Quaternion value3         = Utilities.GenerateQuaternion();
            Quaternion value3Expected = value3;
            Quaternion value4         = Utilities.GenerateQuaternion();
            Quaternion value4Expected = value4;
            float      amount         = Utilities.GenerateFloat();
            Quaternion result;

            Quaternion resultExpected = Utilities.ConvertFrom(Microsoft.DirectX.Quaternion.Squad(
                                                                  Utilities.ConvertToMdx(value1),
                                                                  Utilities.ConvertToMdx(value2),
                                                                  Utilities.ConvertToMdx(value3),
                                                                  Utilities.ConvertToMdx(value4),
                                                                  amount));

            Quaternion.Squad(ref value1, ref value2, ref value3, ref value4, amount, out result);
            Utilities.AreEqual(value1Expected, value1);
            Utilities.AreEqual(value2Expected, value2);
            Utilities.AreEqual(value3Expected, value3);
            Utilities.AreEqual(value4Expected, value4);
            Utilities.AreEqual(resultExpected, result);
        }
示例#3
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]);
            }
        }
示例#4
0
        public void NormalizeTest()
        {
            Quaternion target = Utilities.GenerateQuaternion();

            Quaternion expected = Utilities.ConvertFrom(Microsoft.Xna.Framework.Quaternion.Normalize(
                                                            Utilities.ConvertToXna(target)));

            target.Normalize();
            Utilities.AreEqual(expected, target);
        }
示例#5
0
        public void NormalizeTest1()
        {
            Quaternion value = Utilities.GenerateQuaternion();

            Quaternion expected = Utilities.ConvertFrom(Microsoft.Xna.Framework.Quaternion.Normalize(
                                                            Utilities.ConvertToXna(value)));

            Quaternion actual;

            actual = Quaternion.Normalize(value);
            Utilities.AreEqual(expected, actual);
        }
示例#6
0
        public void LogarithmTest()
        {
            Quaternion value = Utilities.GenerateQuaternion();

            Quaternion expected = Utilities.ConvertFrom(Microsoft.DirectX.Quaternion.Ln(
                                                            Utilities.ConvertToMdx(value)));

            Quaternion actual;

            actual = Quaternion.Logarithm(value);
            Utilities.AreEqual(expected, actual);
        }
示例#7
0
        public void ExponentialTest()
        {
            Quaternion value = Utilities.GenerateQuaternion();

            Quaternion expected = Utilities.ConvertFrom(Microsoft.DirectX.Quaternion.Exp(
                                                            Utilities.ConvertToMdx(value)));

            Quaternion actual;

            actual = Quaternion.Exponential(value);
            Utilities.AreEqual(expected, actual);
        }
示例#8
0
        public void RotationMatrixTest()
        {
            Matrix matrix = Utilities.GenerateMatrix();

            Quaternion expected = Utilities.ConvertFrom(Microsoft.Xna.Framework.Quaternion.CreateFromRotationMatrix(
                                                            Utilities.ConvertToXna(matrix)));

            Quaternion actual;

            actual = Quaternion.RotationMatrix(matrix);
            Utilities.AreEqual(expected, actual);
        }
示例#9
0
        public void op_UnaryNegationTest()
        {
            Quaternion value = Utilities.GenerateQuaternion();

            Quaternion expected = Utilities.ConvertFrom(Microsoft.Xna.Framework.Quaternion.Negate(
                                                            Utilities.ConvertToXna(value)));

            Quaternion actual;

            actual = -(value);
            Utilities.AreEqual(expected, actual);
        }
示例#10
0
        public void RotationMatrixByRefTest()
        {
            Matrix     matrix         = Utilities.GenerateMatrix();
            Matrix     matrixExpected = matrix;
            Quaternion result;

            Quaternion resultExpected = Utilities.ConvertFrom(Microsoft.Xna.Framework.Quaternion.CreateFromRotationMatrix(
                                                                  Utilities.ConvertToXna(matrix)));

            Quaternion.RotationMatrix(ref matrix, out result);
            Utilities.AreEqual(matrixExpected, matrix);
            Utilities.AreEqual(resultExpected, result);
        }
示例#11
0
        public void NormalizeByRefTest()
        {
            Quaternion value         = Utilities.GenerateQuaternion();
            Quaternion valueExpected = value;
            Quaternion result;

            Quaternion resultExpected = Utilities.ConvertFrom(Microsoft.Xna.Framework.Quaternion.Normalize(
                                                                  Utilities.ConvertToXna(value)));

            Quaternion.Normalize(ref value, out result);
            Utilities.AreEqual(valueExpected, value);
            Utilities.AreEqual(resultExpected, result);
        }
示例#12
0
        public void LogarithmByRefTest()
        {
            Quaternion value         = Utilities.GenerateQuaternion();
            Quaternion valueExpected = value;
            Quaternion result;

            Quaternion resultExpected = Utilities.ConvertFrom(Microsoft.DirectX.Quaternion.Ln(
                                                                  Utilities.ConvertToMdx(value)));

            Quaternion.Logarithm(ref value, out result);
            Utilities.AreEqual(valueExpected, value);
            Utilities.AreEqual(resultExpected, result);
        }
示例#13
0
        public void RotationAxisTest()
        {
            Vector3 axis  = Utilities.GenerateVector3();
            float   angle = Utilities.GenerateFloat();

            Quaternion expected = Utilities.ConvertFrom(Microsoft.DirectX.Quaternion.RotationAxis(
                                                            Utilities.ConvertToMdx(axis),
                                                            angle));

            Quaternion actual;

            actual = Quaternion.RotationAxis(axis, angle);
            Utilities.AreEqual(expected, actual);
        }
示例#14
0
        public void MultiplyTest()
        {
            Quaternion left  = Utilities.GenerateQuaternion();
            Quaternion right = Utilities.GenerateQuaternion();

            Quaternion expected = Utilities.ConvertFrom(Microsoft.DirectX.Quaternion.Multiply(
                                                            Utilities.ConvertToMdx(left),
                                                            Utilities.ConvertToMdx(right)));

            Quaternion actual;

            actual = Quaternion.Multiply(left, right);
            Utilities.AreEqual(expected, actual);
        }
示例#15
0
        public void op_MultiplyTest()
        {
            float      scale = Utilities.GenerateFloat();
            Quaternion value = Utilities.GenerateQuaternion();

            Quaternion expected = Utilities.ConvertFrom(Microsoft.Xna.Framework.Quaternion.Multiply(
                                                            Utilities.ConvertToXna(value),
                                                            scale));

            Quaternion actual;

            actual = (scale * value);
            Utilities.AreEqual(expected, actual);
        }
示例#16
0
        public void SubtractTest()
        {
            Quaternion left  = Utilities.GenerateQuaternion();
            Quaternion right = Utilities.GenerateQuaternion();

            Quaternion expected = Utilities.ConvertFrom(Microsoft.Xna.Framework.Quaternion.Subtract(
                                                            Utilities.ConvertToXna(left),
                                                            Utilities.ConvertToXna(right)));

            Quaternion actual;

            actual = Quaternion.Subtract(left, right);
            Utilities.AreEqual(expected, actual);
        }
示例#17
0
        public void op_AdditionTest()
        {
            Quaternion left  = Utilities.GenerateQuaternion();
            Quaternion right = Utilities.GenerateQuaternion();

            Quaternion expected = Utilities.ConvertFrom(Microsoft.Xna.Framework.Quaternion.Add(
                                                            Utilities.ConvertToXna(left),
                                                            Utilities.ConvertToXna(right)));

            Quaternion actual;

            actual = (left + right);
            Utilities.AreEqual(expected, actual);
        }
示例#18
0
        public void RotationAxisByRefTest()
        {
            Vector3    axis         = Utilities.GenerateVector3();
            Vector3    axisExpected = axis;
            float      angle        = Utilities.GenerateFloat();
            Quaternion result;

            Quaternion resultExpected = Utilities.ConvertFrom(Microsoft.DirectX.Quaternion.RotationAxis(
                                                                  Utilities.ConvertToMdx(axis),
                                                                  angle));

            Quaternion.RotationAxis(ref axis, angle, out result);
            Utilities.AreEqual(axisExpected, axis);
            Utilities.AreEqual(resultExpected, result);
        }
示例#19
0
        public void MultiplyScaleByRefTest()
        {
            Quaternion value         = Utilities.GenerateQuaternion();
            Quaternion valueExpected = value;
            float      scale         = Utilities.GenerateFloat();
            Quaternion result;

            Quaternion resultExpected = Utilities.ConvertFrom(Microsoft.Xna.Framework.Quaternion.Multiply(
                                                                  Utilities.ConvertToXna(value),
                                                                  scale));

            Quaternion.Multiply(ref value, scale, out result);
            Utilities.AreEqual(valueExpected, value);
            Utilities.AreEqual(resultExpected, result);
        }
示例#20
0
        public void RotationYawPitchRollByRefTest()
        {
            float      yaw   = Utilities.GenerateFloat();
            float      pitch = Utilities.GenerateFloat();
            float      roll  = Utilities.GenerateFloat();
            Quaternion result;

            Quaternion resultExpected = Utilities.ConvertFrom(Microsoft.Xna.Framework.Quaternion.CreateFromYawPitchRoll(
                                                                  yaw,
                                                                  pitch,
                                                                  roll));

            Quaternion.RotationYawPitchRoll(yaw, pitch, roll, out result);
            Utilities.AreEqual(resultExpected, result);
        }
示例#21
0
        public void SlerpTest()
        {
            Quaternion start  = Utilities.GenerateQuaternion();
            Quaternion end    = Utilities.GenerateQuaternion();
            float      amount = Utilities.GenerateFloat();

            Quaternion expected = Utilities.ConvertFrom(Microsoft.Xna.Framework.Quaternion.Slerp(
                                                            Utilities.ConvertToXna(start),
                                                            Utilities.ConvertToXna(end),
                                                            amount));

            Quaternion actual;

            actual = Quaternion.Slerp(start, end, amount);
            Utilities.AreEqual(expected, actual);
        }
示例#22
0
        public void RotationYawPitchRollTest()
        {
            float yaw   = Utilities.GenerateFloat();
            float pitch = Utilities.GenerateFloat();
            float roll  = Utilities.GenerateFloat();

            Quaternion expected = Utilities.ConvertFrom(Microsoft.Xna.Framework.Quaternion.CreateFromYawPitchRoll(
                                                            yaw,
                                                            pitch,
                                                            roll));

            Quaternion actual;

            actual = Quaternion.RotationYawPitchRoll(yaw, pitch, roll);
            Utilities.AreEqual(expected, actual);
        }
示例#23
0
        public void SubtractByRefTest()
        {
            Quaternion left          = Utilities.GenerateQuaternion();
            Quaternion leftExpected  = left;
            Quaternion right         = Utilities.GenerateQuaternion();
            Quaternion rightExpected = right;
            Quaternion result;

            Quaternion resultExpected = Utilities.ConvertFrom(Microsoft.Xna.Framework.Quaternion.Subtract(
                                                                  Utilities.ConvertToXna(left),
                                                                  Utilities.ConvertToXna(right)));

            Quaternion.Subtract(ref left, ref right, out result);
            Utilities.AreEqual(leftExpected, left);
            Utilities.AreEqual(rightExpected, right);
            Utilities.AreEqual(resultExpected, result);
        }
示例#24
0
        public void MultiplyByRefTest()
        {
            Quaternion left          = Utilities.GenerateQuaternion();
            Quaternion leftExpected  = left;
            Quaternion right         = Utilities.GenerateQuaternion();
            Quaternion rightExpected = right;
            Quaternion result;

            Quaternion resultExpected = Utilities.ConvertFrom(Microsoft.DirectX.Quaternion.Multiply(
                                                                  Utilities.ConvertToMdx(left),
                                                                  Utilities.ConvertToMdx(right)));

            Quaternion.Multiply(ref left, ref right, out result);
            Utilities.AreEqual(leftExpected, left);
            Utilities.AreEqual(rightExpected, right);
            Utilities.AreEqual(resultExpected, result);
        }
示例#25
0
        public void SlerpByRefTest()
        {
            Quaternion start         = Utilities.GenerateQuaternion();
            Quaternion startExpected = start;
            Quaternion end           = Utilities.GenerateQuaternion();
            Quaternion endExpected   = end;
            float      amount        = Utilities.GenerateFloat();
            Quaternion result;

            Quaternion resultExpected = Utilities.ConvertFrom(Microsoft.Xna.Framework.Quaternion.Slerp(
                                                                  Utilities.ConvertToXna(start),
                                                                  Utilities.ConvertToXna(end),
                                                                  amount));

            Quaternion.Slerp(ref start, ref end, amount, out result);
            Utilities.AreEqual(startExpected, start);
            Utilities.AreEqual(endExpected, end);
            Utilities.AreEqual(resultExpected, result);
        }
示例#26
0
        public void SquadTest()
        {
            Quaternion value1 = Utilities.GenerateQuaternion();
            Quaternion value2 = Utilities.GenerateQuaternion();
            Quaternion value3 = Utilities.GenerateQuaternion();
            Quaternion value4 = Utilities.GenerateQuaternion();
            float      amount = Utilities.GenerateFloat();

            Quaternion expected = Utilities.ConvertFrom(Microsoft.DirectX.Quaternion.Squad(
                                                            Utilities.ConvertToMdx(value1),
                                                            Utilities.ConvertToMdx(value2),
                                                            Utilities.ConvertToMdx(value3),
                                                            Utilities.ConvertToMdx(value4),
                                                            amount));

            Quaternion actual;

            actual = Quaternion.Squad(value1, value2, value3, value4, amount);
            Utilities.AreEqual(expected, actual);
        }
示例#27
0
        public void BarycentricTest()
        {
            Quaternion value1  = Utilities.GenerateQuaternion();
            Quaternion value2  = Utilities.GenerateQuaternion();
            Quaternion value3  = Utilities.GenerateQuaternion();
            float      amount1 = Utilities.GenerateFloat();
            float      amount2 = Utilities.GenerateFloat();

            Quaternion expected = Utilities.ConvertFrom(Microsoft.DirectX.Quaternion.BaryCentric(
                                                            Utilities.ConvertToMdx(value1),
                                                            Utilities.ConvertToMdx(value2),
                                                            Utilities.ConvertToMdx(value3),
                                                            amount1,
                                                            amount2));

            Quaternion actual;

            actual = Quaternion.Barycentric(value1, value2, value3, amount1, amount2);
            Utilities.AreEqual(expected, actual);
        }