Пример #1
0
        public void TestCollinearIntersect()
        {
            int fX1       = 0;
            int fY1       = 0;
            int fX2       = 5;
            int fY2       = 0;
            int directrix = 5;

            Assert.AreEqual(5.0 / 2, ParabolaMath.IntersectParabolaX(fX1, fY1, fX2, fY2, directrix), Epsilon);
        }
Пример #2
0
        public void TestIntersect()
        {
            int fX1       = 1;
            int fY1       = 2;
            int fX2       = 5;
            int fY2       = 4;
            int directrix = 14;

            Assert.AreEqual(.50510257, ParabolaMath.IntersectParabolaX(fX1, fY1, fX2, fY2, directrix), .00000001);
            Assert.AreEqual(49.49489743, ParabolaMath.IntersectParabolaX(fX2, fY2, fX1, fY1, directrix), .00000001);
        }
Пример #3
0
        private static double RightBreakpoint(RBTreeNode <BeachSection> node, double directrix)
        {
            var rightNode = node.Next;

            //degenerate parabola
            if ((node.Data.Site.Y - directrix).ApproxEqual(0))
            {
                return(node.Data.Site.X);
            }
            //node is the last piece of the beach line
            if (rightNode == null)
            {
                return(double.PositiveInfinity);
            }
            //left node is degenerate
            if ((rightNode.Data.Site.Y - directrix).ApproxEqual(0))
            {
                return(rightNode.Data.Site.X);
            }
            var site      = node.Data.Site;
            var rightSite = rightNode.Data.Site;

            return(ParabolaMath.IntersectParabolaX(site.X, site.Y, rightSite.X, rightSite.Y, directrix));
        }
Пример #4
0
        private static double LeftBreakpoint(RBTreeNode <BeachSection> node, double directrix)
        {
            var leftNode = node.Previous;

            //degenerate parabola
            if ((node.Data.Site.Y - directrix).ApproxEqual(0))
            {
                return(node.Data.Site.X);
            }
            //node is the first piece of the beach line
            if (leftNode == null)
            {
                return(double.NegativeInfinity);
            }
            //left node is degenerate
            if ((leftNode.Data.Site.Y - directrix).ApproxEqual(0))
            {
                return(leftNode.Data.Site.X);
            }
            var site     = node.Data.Site;
            var leftSite = leftNode.Data.Site;

            return(ParabolaMath.IntersectParabolaX(leftSite.X, leftSite.Y, site.X, site.Y, directrix));
        }