Beispiel #1
0
        public void TestPointInCircumcircle()
        {
            Vector2 a = new Vector2(0, -0.5);
            Vector2 b = new Vector2(-0.5, 0.5);
            Vector2 c = new Vector2(0.5, 0.5);

            Vector2 point = new Vector2(0, 0);

            // Check that point is in circumcircle
            Assert.IsTrue(GeometryMath.PointInCircumcircle(point, a, b, c), "Expected to be inside circumcircle but was not (point in middle of triangle)");

            point = new Vector2(0, 1);
            // Check that point is not in circumcircle
            Assert.IsFalse(GeometryMath.PointInCircumcircle(point, a, b, c), "Expected to be outside circumcircle (point outside one of the corners)");

            // Check that point is in circumcircle when triangle points are on the same line
            a = new Vector2(0, 0);
            b = new Vector2(1, 0);
            c = new Vector2(2, 0);
            Assert.IsTrue(GeometryMath.PointInCircumcircle(point, a, b, c), "Expected to be inside circumcircle (all triangle points on the same line)");

            // Check that point is in circumcircle when on triangle side length is 0
            a = new Vector2(0, 0);
            b = new Vector2(0, 0);
            c = new Vector2(0, 1);
            Assert.IsTrue(GeometryMath.PointInCircumcircle(point, a, b, c), "Expected to be inside circumcircle (one triangle side length is 0)");

            // Check that point is in circumcircle when is it just within radius
            a     = new Vector2(0, -0.5);
            b     = new Vector2(-0.5, 0.5);
            c     = new Vector2(0.5, 0.5);
            point = new Vector2(0, -0.5);
            Assert.IsTrue(GeometryMath.PointInCircumcircle(point, a, b, c), "Expected to be inside circumcircle (point is the same as one of the triangle points)");
        }