Ejemplo n.º 1
0
        public void When_FindAngleToVectors_Expect_InsideValidInterval()
        {
            Vect3 baseVector   = new Vect3(1, 0, 0);
            Vect3 movingVector = new Vect3(1, 0, 0);

            for (int newX = -10; newX <= 10; newX++)
            {
                movingVector.x = newX;
                for (int newY = -10; newY <= 10; newY++)
                {
                    movingVector.y = newY;
                    for (int newZ = -10; newZ <= 10; newZ++)
                    {
                        movingVector.z = newZ;
                        if (movingVector.Equals(Vect3.Zero))
                        {
                            continue;
                        }
                        Assert.LessOrEqual(movingVector.AngleTo(baseVector), 180,
                                           "Invalid angle found for {0} and {1}: {2}", movingVector, baseVector, movingVector.AngleTo(baseVector));
                        Assert.GreaterOrEqual(movingVector.AngleTo(baseVector), 0,
                                              "Invalid angle found for {0} and {1}: {2}", movingVector, baseVector, movingVector.AngleTo(baseVector));
                        Assert.LessOrEqual(baseVector.AngleTo(movingVector), 180,
                                           "Invalid angle found for {0} and {1}: {2}", baseVector, movingVector, baseVector.AngleTo(movingVector));
                        Assert.GreaterOrEqual(baseVector.AngleTo(movingVector), 0,
                                              "Invalid angle found for {0} and {1}: {2}", baseVector, movingVector, baseVector.AngleTo(movingVector));
                        Assert.That(Util.NearlyEqual(movingVector.AngleTo(baseVector), baseVector.AngleTo(movingVector)));
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public void When_FindAngleBetween45Degrees_Expect_45()
        {
            Vect3 v = new Vect3(1, 1, 0);

            Assert.That(Util.NearlyEqual(v.AngleTo(Vect3.Up), 45d));
        }
Ejemplo n.º 3
0
        public void When_FindAngleBetweenSameVector_Expect_Zero()
        {
            Vect3 v = new Vect3(5, 1, 2);

            Assert.That(Util.NearlyEqual(v.AngleTo(v), 0));
        }