Exemplo n.º 1
0
        public void Orientation2()
        {
            Matrix rotation = MatrixExt.Orientation(MathHelper.ToRadians(-90));

            Vector2 dude   = new Vector2(1.0f, 0.0f);
            Vector2 result = rotation.Multiply(dude);

            Assert.AreEqual(0, Convert.ToInt32(result.X));
            Assert.AreEqual(-1, Convert.ToInt32(result.Y));
        }
Exemplo n.º 2
0
        public void Orientation()
        {
            Matrix rotation = MatrixExt.Orientation(MathHelper.ToRadians(90));

            Vector2 dude   = new Vector2(1.0f, 0.0f);
            Vector2 result = rotation.Multiply(dude);

            Assert.AreEqual(0, (int)(result.X + 0.5f));
            Assert.AreEqual(1, (int)(result.Y + 0.5f));
        }
Exemplo n.º 3
0
        public void OrientationFromHeadingAndSide()
        {
            //create his heading
            Vector2 dudeHeading = Vector2.UnitX;

            //create his side matrix
            Vector2 dudeSide = new Vector2(-dudeHeading.Y, dudeHeading.X);

            //create an orientation matrix
            Matrix rotate = MatrixExt.Orientation(dudeHeading, dudeSide);

            //that should be identity
            Assert.AreEqual(Matrix.Identity, rotate);
        }
Exemplo n.º 4
0
        public void OrientationFromHeadingAndSide_4()
        {
            //create his heading
            Vector2 dudeHeading = -Vector2.UnitY;

            //create his side matrix
            Vector2 dudeSide = new Vector2(-dudeHeading.Y, dudeHeading.X);

            //create an orientation matrix
            Matrix rotate = MatrixExt.Orientation(dudeHeading, dudeSide);

            Vector2 myPoint = rotate.Multiply(new Vector2(0.0f, 10.0f));

            Assert.AreEqual(-10.0f, Math.Round(myPoint.X, 3));
            Assert.AreEqual(0.0f, Math.Round(myPoint.Y, 3));
        }
Exemplo n.º 5
0
        public void Orientations_1()
        {
            //create his heading -90
            Vector2 dudeHeading = new Vector2(0.0f, 1.0f);

            //create his side matrix
            Vector2 dudeSide = new Vector2(-dudeHeading.Y, dudeHeading.X);

            //create an orientation matrix
            Matrix rotate = MatrixExt.Orientation(dudeHeading, dudeSide);

            //that should be identity
            Matrix rotate1 = MatrixExt.Orientation(MathHelper.ToRadians(-90.0f));

            for (int i = 0; i < Matrix.ToFloatArray(rotate).Length; i++)
            {
                float expected = (float)Math.Round(Matrix.ToFloatArray(rotate1)[i], 3);
                float actual   = (float)Math.Round(Matrix.ToFloatArray(rotate)[i], 3);
                Assert.AreEqual(expected, actual, string.Format("incorrect index at {0}", i));
            }
        }
Exemplo n.º 6
0
        public void OrientationFromHeadingAndSide_3()
        {
            //create his heading
            Vector2 dudeHeading = Vector2.UnitX;

            //create his side matrix
            Vector2 dudeSide = new Vector2(-dudeHeading.Y, dudeHeading.X);

            //create an orientation matrix
            Matrix rotate = MatrixExt.Orientation(dudeHeading, dudeSide);


            //create a dude
            Vector2 dudePos = new Vector2(100.0f, 100.0f);

            //convert another point to "local space"
            Vector2 myPoint = new Vector2(100.0f, 110.0f);

            myPoint = myPoint - dudePos;
            myPoint = rotate.Multiply(myPoint);

            Assert.AreEqual(0.0f, Math.Round(myPoint.X, 3));
            Assert.AreEqual(10.0f, Math.Round(myPoint.Y, 3));
        }