Example #1
0
        public DoubleExtention DistanceToPoint(SystemCoordinates alpha)
        {
            List <DoubleExtention> dist = new List <DoubleExtention>();

            if (ULimitSet && LLimitSet)
            {
                dist.Add(alpha.Distance(ULimitPoint));
                dist.Add(alpha.Distance(LLimitPoint));
            }
            Line a = new Line(alpha, center);

            a.FirstEnd = center;
            List <SystemCoordinates> p = IntersectionWithInfLine(a);

            //if(IntersectionWithLine(a).Count!=0)
            foreach (var x in p)
            {
                dist.Add(x.Distance(alpha));
            }
            //dist.Add(this.IntersectionWithLine(a)[0].Distance(alpha));
            DoubleExtention min = dist[0];

            foreach (var z in dist)
            {
                if (z < min)
                {
                    min = z;
                }
            }
            return(min);
        }
Example #2
0
        public Circle(SystemCoordinates p1, SystemCoordinates p2, SystemCoordinates p3)
        {
            DoubleExtention x1    = p1.X;
            DoubleExtention x2    = p2.X;
            DoubleExtention x3    = p3.X;
            DoubleExtention y1    = p1.Y;
            DoubleExtention y2    = p2.Y;
            DoubleExtention y3    = p3.Y;
            DoubleExtention alpha = (x1 * x1 + y1 * y1 - x3 * x3 - y3 * y3) / 2;
            DoubleExtention betaa = (x2 * x2 + y2 * y2 - x3 * x3 - y3 * y3) / 2;
            DoubleExtention b;
            DoubleExtention a;

            if (x1 == x3)
            {
                b = alpha / (y1 - y3);
                a = (betaa - b * (y2 - y3)) / (x2 - x3);
            }
            else
            if (x2 == x3)
            {
                b = betaa / (y2 - y3);
                a = (alpha - b * (y1 - y3)) / (x1 - x3);
            }
            else
            {
                DoubleExtention gamma  = alpha / (x1 - x3) - betaa / (x2 - x3);
                DoubleExtention lambda = (y1 - y3) / (x1 - x3) - (y2 - y3) / (x2 - x3);
                b = gamma / lambda;
                a = (alpha - b * (y1 - y3)) / (x1 - x3);
            }
            center = new SystemCoordinates(a, b);
            radius = center.Distance(p1);
            Line Z = new Line(center, p1, false);

            Z.BuildAngle();
            UpperLimitAngle = Z.AngleForOnePointLines;
            Z = new Line(center, p3, false);
            Z.BuildAngle();
            LowerLimitAngle = Z.AngleForOnePointLines;
            while (lowerLimitAngle > upperLimitAngle)
            {
                lowerLimitAngle -= (Math.PI * 2);
            }
            if (!PointIsBetweenEdges(p2))
            {
                DoubleExtention t = lowerLimitAngle;
                lowerLimitAngle = upperLimitAngle;
                upperLimitAngle = t;
                while (lowerLimitAngle > upperLimitAngle)
                {
                    lowerLimitAngle -= (Math.PI * 2);
                }
                while (upperLimitAngle < 0)
                {
                    lowerLimitAngle += (Math.PI * 2);
                    upperLimitAngle += (Math.PI * 2);
                }
            }
        }
Example #3
0
        public DoubleExtention DistanceToPoint(SystemCoordinates x)
        {
            Line X = BuildOrthogonalLine(x);
            bool Intersect, Equal;
            SystemCoordinates alpha = X.IntersectWithLine(this, out Intersect, out Equal);

            if (Intersect == true)
            {
                return(alpha.Distance(x));
            }
            else
            {
                if (firstEndSet && secondEndSet)
                {
                    return(Math.Min(x.Distance(firstEnd), x.Distance(secondEnd)));
                }
                if (firstEndSet)
                {
                    return(x.Distance(firstEnd));
                }
                return(x.Distance(secondEnd));
            }
        }