Beispiel #1
0
        public void TestSlerp()
        {
            {
                //native
                Vec2 vec2p = new Vec2(1f, 1f);
                vec2p.Normalize();
                Vec2 vec2q = new Vec2(10.0f, 10.0f);
                vec2q.Normalize();
                Vec2 vec2Mid = Vec2.CreateSlerp(vec2p, vec2q, 0.5f);
                //managed
                Vector2 vector2p = new Vector2(vec2p.x, vec2p.y);
                vector2p = vector2p.Normalized;
                Vector2 vector2q = new Vector2(vec2q.x, vec2q.y);
                vector2q = vector2q.Normalized;
                Vector2 vector2Mid = Vector2.Slerp(vector2p, vector2q, 0.5f);

                Assert.IsTrue(MathHelpers.Approximately(vec2Mid.x, vector2Mid.x, 0.000001f) && MathHelpers.Approximately(vec2Mid.y, vector2Mid.y, 0.000001f), " Slerp tests fails for native and managed vector2 1");
            }
            {
                Vec2 vec2p = new Vec2(1f, 1f);
                vec2p.Normalize();
                Vec2 vec2q = new Vec2(10.0f, 10.0f);
                vec2q.Normalize();
                Vec2 vec2Start = Vec2.CreateSlerp(vec2p, vec2q, 0.0f);

                //managed
                Vector2 vector2p = new Vector2(vec2p.x, vec2p.y);
                vector2p = vector2p.Normalized;
                Vector2 vector2q = new Vector2(vec2q.x, vec2q.y);
                vector2q = vector2q.Normalized;
                Vector2 vector2Start = Vector2.Slerp(vector2p, vector2q, 0.0f);

                Assert.IsTrue(NativeExtensions.TestVectorsAreEqual(vec2Start, vector2Start), "Slerp tests fails for vector2 2a");
                Assert.IsTrue(NativeExtensions.TestVectorsAreEqual(vec2Start, vec2p), "Slerp tests fails for vector2 2b " + vec2Start.PrintString() + "," + vec2p.PrintString());
                Assert.IsTrue(NativeExtensions.TestVectorsAreEqual(vector2Start, vector2p), "Slerp tests fails for vector2 2c");
            }
            {
                Vec2 vec2p = new Vec2(1f, 1f);
                vec2p.Normalize();
                Vec2 vec2q = new Vec2(10.0f, 10.0f);
                vec2q.Normalize();
                Vec2 vec2Start = Vec2.CreateSlerp(vec2p, vec2q, 1.0f);

                //managed
                Vector2 vector2p = new Vector2(vec2p.x, vec2p.y);
                vector2p = vector2p.Normalized;
                Vector2 vector2q = new Vector2(vec2q.x, vec2q.y);
                vector2q = vector2q.Normalized;
                Vector2 vector2Start = Vector2.Slerp(vector2p, vector2q, 1.0f);

                Assert.IsTrue(NativeExtensions.TestVectorsAreEqual(vec2Start, vector2Start), "Slerp tests fails for vector2 3a");
                Assert.IsTrue(NativeExtensions.TestVectorsAreEqual(vec2Start, vec2q), "Slerp tests fails for vector2 3b");
                Assert.IsTrue(NativeExtensions.TestVectorsAreEqual(vector2Start, vector2q), "Slerp tests fails for vector2 3c");
            }
        }