예제 #1
0
        public void Transform()
        {
            Matrix2x2 matrix2x2 = Matrix2x2.FromRotation(MathHelper.Pi);

            Assert.AreEqual(matrix2x2 * Vector2D.XAxis, Vector2D.Transform(matrix2x2, Vector2D.XAxis), "matrix2x2 rotation");
            UnitHelper.RefOperationTesterRightSame <Matrix2x2, Vector2D>(matrix2x2, Vector2D.XAxis, matrix2x2 * Vector2D.XAxis, Vector2D.Transform, "matrix2x2 rotation");
            Matrix3x3 matrix3x3 = Matrix3x3.FromTranslate2D(-op1);

            Assert.AreEqual(Vector2D.Zero, matrix3x3 * op1, "matrix3x3 Translate1");
            Assert.AreEqual((matrix3x3 * op1), Vector2D.Transform(matrix3x3, op1), "matrix3x3 Translate2");
            UnitHelper.RefOperationTesterRightSame <Matrix3x3, Vector2D>(matrix3x3, op1, matrix3x3 * op1, Vector2D.Transform, "matrix3x3 Translate");
            matrix3x3 = Matrix3x3.FromRotationZ(MathHelper.Pi);
            Assert.AreEqual((matrix3x3 * op1), Vector2D.Transform(matrix3x3, op1), "matrix3x3 rotation");
            UnitHelper.RefOperationTesterRightSame <Matrix3x3, Vector2D>(matrix3x3, op1, matrix3x3 * op1, Vector2D.Transform, "matrix3x3 rotation");


            Matrix2x2 matrix2x2Inv = matrix2x2.Inverted;
            Vector2D  temp         = matrix2x2 * op1;

            temp = matrix2x2Inv * temp;
            Assert.AreEqual(op1, temp, "inv2x2");

            matrix3x3 = matrix3x3 * Matrix3x3.FromTranslate2D(-op1);
            Matrix3x3 matrix3x3Inv = matrix3x3.Inverted;

            temp = matrix3x3 * op1;
            temp = matrix3x3Inv * temp;
            Assert.AreEqual(op1, temp, "inv3x3");
        }
예제 #2
0
        public void Dot()
        {
            Scalar expected = -(Value * Value * 4);

            UnitHelper.RefOperationTester <Vector4D, Vector4D, Scalar>(op1, op2, expected, Vector4D.Dot, "Dot");
            Assert.AreEqual(expected, op1 * op2, "Operator");
            Assert.AreEqual(expected, Vector4D.Dot(op1, op2), "Method");
        }
예제 #3
0
        public void Multiplication()
        {
            Vector2D expected = op1;

            expected.X *= 2;
            expected.Y *= 2;
            UnitHelper.RefOperationTesterLeftSame <Scalar, Vector2D>(op1, 2, expected, Vector2D.Multiply, "1");
            UnitHelper.RefOperationTesterRightSame <Scalar, Vector2D>(2, op1, expected, Vector2D.Multiply, "2");
            Assert.AreEqual(expected, Vector2D.Multiply(2, op1), "3");
            Assert.AreEqual(expected, Vector2D.Multiply(op1, 2), "4");
            Assert.AreEqual(expected, 2 * op1, "5");
            Assert.AreEqual(expected, op1 * 2, "6");
        }
예제 #4
0
        public void ZCross()
        {
            Assert.AreEqual(0, Vector2D.ZCross(op1, op2), "1");
            Assert.AreEqual(Vector2D.Zero, Vector2D.ZCross(op1, 0), "2");
            Assert.AreEqual(Vector2D.Zero, Vector2D.ZCross(0, op2), "3");
            Assert.AreEqual(new Vector2D(-Value, -Value), Vector2D.ZCross(1, op2), "4");
            Assert.AreEqual(new Vector2D(Value, Value), Vector2D.ZCross(1, op1), "5");
            Assert.AreEqual(new Vector2D(-Value, -Value), Vector2D.ZCross(op1, 1), "6");
            Assert.AreEqual(new Vector2D(Value, Value), Vector2D.ZCross(op2, 1), "7");

            UnitHelper.RefOperationTester <Vector2D, Vector2D, Scalar>(op1, op2, 0, Vector2D.ZCross, "8");
            UnitHelper.RefOperationTester <Vector2D, Scalar, Vector2D>(op1, 1, new Vector2D(-Value, -Value), Vector2D.ZCross, "9");
            UnitHelper.RefOperationTester <Scalar, Vector2D, Vector2D>(1, op2, new Vector2D(-Value, -Value), Vector2D.ZCross, "10");
        }
예제 #5
0
 public void Subtraction()
 {
     Assert.AreEqual(op1 - op1, Vector4D.Zero, "Operator");
     Assert.AreEqual(Vector4D.Zero, Vector4D.Subtract(op1, op1), "Method");
     UnitHelper.RefOperationTester <Vector4D>(op1, op2, op1 - op2, Vector4D.Subtract, "Subtraction");
 }
예제 #6
0
 public void Addition()
 {
     Assert.AreEqual(Vector4D.Zero, op1 + op2, "Operator");
     Assert.AreEqual(Vector4D.Zero, Vector4D.Add(op1, op2), "Method");
     UnitHelper.RefOperationTester <Vector4D>(op1, op2, Vector4D.Zero, Vector4D.Add, "Addition");
 }
예제 #7
0
 public void Max()
 {
     Assert.AreEqual(new Vector4D(Value, Value, Value, Value), Vector4D.Max(op1, op2), "1");
     UnitHelper.RefOperationTester <Vector4D>(op1, op2, new Vector4D(Value, Value, Value, Value), Vector4D.Max, "2");
 }
예제 #8
0
 public void Min()
 {
     Assert.AreEqual(new Vector2D(-Value, -Value), Vector2D.Min(op1, op2), "1");
     UnitHelper.RefOperationTester <Vector2D>(op1, op2, new Vector2D(-Value, -Value), Vector2D.Min, "2");
 }