Ejemplo n.º 1
0
        public void QuaternionCreateFromYawPitchRollTest2()
        {
            Single step = 35.0f;

            for (Single yawAngle = -720.0f; yawAngle <= 720.0f; yawAngle += step)
            {
                for (Single pitchAngle = -720.0f; pitchAngle <= 720.0f; pitchAngle += step)
                {
                    for (Single rollAngle = -720.0f; rollAngle <= 720.0f; rollAngle += step)
                    {
                        Single yawRad   = MathHelper.ToRadians(yawAngle);
                        Single pitchRad = MathHelper.ToRadians(pitchAngle);
                        Single rollRad  = MathHelper.ToRadians(rollAngle);

                        Quaternion yaw   = Quaternion.CreateFromAxisAngle(Vector3.UnitY, yawRad);
                        Quaternion pitch = Quaternion.CreateFromAxisAngle(Vector3.UnitX, pitchRad);
                        Quaternion roll  = Quaternion.CreateFromAxisAngle(Vector3.UnitZ, rollRad);

                        Quaternion expected = yaw * pitch * roll;
                        Quaternion actual   = Quaternion.CreateFromYawPitchRoll(yawRad, pitchRad, rollRad);
                        Assert.True(MathHelper.Equal(expected, actual), $"Quaternion.QuaternionCreateFromYawPitchRollTest2 Yaw:{yawAngle} Pitch:{pitchAngle} Roll:{rollAngle} did not return the expected value: expected {expected} actual {actual}");
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public void QuaternionCreateFromYawPitchRollTest1()
        {
            Single yawAngle   = MathHelper.ToRadians(30.0f);
            Single pitchAngle = MathHelper.ToRadians(40.0f);
            Single rollAngle  = MathHelper.ToRadians(50.0f);

            Quaternion yaw   = Quaternion.CreateFromAxisAngle(Vector3.UnitY, yawAngle);
            Quaternion pitch = Quaternion.CreateFromAxisAngle(Vector3.UnitX, pitchAngle);
            Quaternion roll  = Quaternion.CreateFromAxisAngle(Vector3.UnitZ, rollAngle);

            Quaternion expected = yaw * pitch * roll;
            Quaternion actual   = Quaternion.CreateFromYawPitchRoll(yawAngle, pitchAngle, rollAngle);

            Assert.True(MathHelper.Equal(expected, actual), $"Quaternion.QuaternionCreateFromYawPitchRollTest1 did not return the expected value: expected {expected} actual {actual}");
        }