예제 #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 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");
        }