Example #1
0
        public void TestPointNearZero()
        {
            float  a      = 2.5F;
            float  b      = 1.25F;
            PointF center = new PointF(3F, 2F);
            PointF test   = new PointF(3.01F, 2.01F);

            PointF intersection = EllipsePrimitive.IntersectEllipseAndLine(a, b, center, test);

            VerifyPointOnEllipse(a, b, center, intersection);
        }
Example #2
0
        public void TestMinorAxisZero()
        {
            float  a      = 2.5F;
            float  b      = 0F;
            PointF center = new PointF(3F, 2F);
            PointF test   = new PointF(13F, 7F);

            PointF intersection = EllipsePrimitive.IntersectEllipseAndLine(a, b, center, test);

            //intersection is at center.
            Assert.IsTrue(FloatComparer.AreEqual(center, intersection), "ellipse intersection point is not correct!");
        }
Example #3
0
        public void TestPointVeryCloseToZero()
        {
            float  a      = 2.5F;
            float  b      = 1.25F;
            PointF center = new PointF(3F, 2F);
            PointF test   = new PointF(3.0001F, 2.0001F);

            PointF intersection = EllipsePrimitive.IntersectEllipseAndLine(a, b, center, test);

            //intersection is at center.
            Assert.IsTrue(FloatComparer.AreEqual(center, intersection), "ellipse intersection point is not correct!");
        }
Example #4
0
        public void TestPointOutside()
        {
            float  a      = -2.5F;
            float  b      = -1.25F;
            PointF center = new PointF(3F, 2F);
            PointF test   = new PointF(13F, 7F);
            PointF result = new PointF(4.767767F, 2.883884F);

            PointF intersection = EllipsePrimitive.IntersectEllipseAndLine(a, b, center, test);

            VerifyPointOnEllipse(a, b, center, intersection);

            Assert.IsTrue(FloatComparer.AreEqual(result, intersection), "ellipse intersection point is not correct!");
        }
Example #5
0
        public void SimpleTest()
        {
            //for a circle of radius=1, test point = 1,1, intesection is 1/sqrt(2), 1/sqrt(2)
            float  a            = 1F;
            float  b            = 1F;
            PointF center       = new PointF(0, 0);
            float  root2Inverse = 1F / (float)Math.Sqrt(2);
            PointF result       = new PointF(root2Inverse, root2Inverse);
            PointF intersection = EllipsePrimitive.IntersectEllipseAndLine(a, b, center, new PointF(1, 1));

            VerifyPointOnEllipse(a, b, center, intersection);

            Assert.IsTrue(FloatComparer.AreEqual(result, intersection), "ellipse intersection point is not correct!");
        }