Exemplo n.º 1
0
        public void ComputeAreaOfTriangle_IgnoresTranslations(float area, Vector2[] triangle)
        {
            var translation = m_Rand.NextFloat2();

            for (var i = 0; i < 3; i++)
            {
                triangle[i] = (Vector2)translation + triangle[i];
            }
            Assert.AreApproximatelyEqual(area,
                                         ObjectPlacementUtilities.ComputeAreaOfTriangle(triangle[0], triangle[1], triangle[2]));
        }
Exemplo n.º 2
0
        public void ComputeAreaOfTriangle_IgnoresZAxis(float area, Vector2[] triangle)
        {
            var triangle3d = new Vector3[3];

            for (var i = 0; i < 3; i++)
            {
                triangle3d[i] = (Vector3)triangle[i] + m_Rand.NextFloat(-10f, 10f) * Vector3.forward;
            }

            Assert.AreApproximatelyEqual(area,
                                         ObjectPlacementUtilities.ComputeAreaOfTriangle(triangle3d[0], triangle3d[1], triangle3d[2]));
        }
Exemplo n.º 3
0
 public void ComputeAreaOfTriangle_IsOrderInvariant(float area, Vector2[] triangle)
 {
     Assert.AreApproximatelyEqual(area,
                                  ObjectPlacementUtilities.ComputeAreaOfTriangle(triangle[0], triangle[1], triangle[2]));
     Assert.AreApproximatelyEqual(area,
                                  ObjectPlacementUtilities.ComputeAreaOfTriangle(triangle[0], triangle[2], triangle[1]));
     Assert.AreApproximatelyEqual(area,
                                  ObjectPlacementUtilities.ComputeAreaOfTriangle(triangle[1], triangle[0], triangle[2]));
     Assert.AreApproximatelyEqual(area,
                                  ObjectPlacementUtilities.ComputeAreaOfTriangle(triangle[1], triangle[2], triangle[0]));
     Assert.AreApproximatelyEqual(area,
                                  ObjectPlacementUtilities.ComputeAreaOfTriangle(triangle[2], triangle[1], triangle[0]));
     Assert.AreApproximatelyEqual(area,
                                  ObjectPlacementUtilities.ComputeAreaOfTriangle(triangle[2], triangle[0], triangle[1]));
 }