public static void SetAsTriangleEdge(double d2, Edge currentEdge, Edge nextEdge)
        {
            Vertice start  = currentEdge.Start;
            Vertice middle = currentEdge.End;
            Vertice end    = nextEdge.End;

            (double, double)nextLine     = Line.GetStraightLine(end, middle);
            (double, double)straightLine = Line.GetStraightLine(end, start);
            double cos       = Angle.GetCosinusFromBetween(nextLine, straightLine);
            double d         = DistanceHelpers.DistanceBetween(start, end);
            double sqrtDelta = Math.Sqrt(Math.Pow(2 * d * cos, 2) - 4 * (d * d * d2 * d2));
            double x1        = (-2 * d * cos - sqrtDelta) / 2;
            double x2        = (-2 * d * cos + sqrtDelta) / 2;
            double x         = Math.Min(x1, x2);

            if (x < 0)
            {
                x = Math.Max(x1, x2);
            }

            (Vertice, Vertice)vertices = PointHelpers.GetPointFromLineDistanceAndPoint(nextLine, x, end);
            Vertice resultVertice = DistanceHelpers.GetCloserVerticeFromVertice(vertices, start);

            if (resultVertice.x < int.MinValue + 100 || resultVertice.y > int.MaxValue - 100 || resultVertice.y < int.MinValue + 100 || resultVertice.y > int.MaxValue - 100)
            {
                int xdddd = 2;
            }
            PointHelpers.SetPointXY(middle, resultVertice.x, resultVertice.y);
        }
Example #2
0
        public static void SetPerpednicular(Edge siblingEdge, Edge currentEdge, Edge nextEdge)
        {
            Vertice start  = currentEdge.Start;
            Vertice middle = currentEdge.End;
            Vertice end    = nextEdge.End;
            double  d      = DistanceHelpers.GetEdgeLength(siblingEdge);

            (double, double)line = Line.GetStraightLine(siblingEdge.Start, siblingEdge.End);
            (Vertice, Vertice)vertices;
            if (line.Item1 == 0)
            {
                vertices = (new Vertice(start.x, start.y - (int)d), new Vertice(start.x, start.y + (int)d));
            }
            else if (line.Item1 > int.MaxValue - 100 || line.Item1 < int.MinValue + 100)
            {
                vertices = (new Vertice(start.x - (int)d, start.y), new Vertice(start.x + (int)d, start.y));
            }
            else
            {
                (double, double)perpendicularLine = Line.GetPerpendicularThroughPoint(line, start);
                vertices = PointHelpers.GetPointFromLineDistanceAndPoint(perpendicularLine, d, start);
            }
            Vertice resultVertice = DistanceHelpers.GetCloserVerticeFromVertice(vertices, middle);

            PointHelpers.SetPointXY(middle, resultVertice.x, resultVertice.y);
        }
Example #3
0
        public static void SetPerpednicularNextEqual(Edge siblingEdge, Edge currentEdge, Edge nextEdge)
        {
            Vertice start  = currentEdge.Start;
            Vertice middle = currentEdge.End;
            Vertice end    = nextEdge.End;
            double  d      = DistanceHelpers.GetEdgeLength(siblingEdge);
            double  d2     = DistanceHelpers.GetEdgeLength(nextEdge);

            (double, double)line         = Line.GetStraightLine(siblingEdge.Start, siblingEdge.End);
            (double, double)distanceLine = Line.GetStraightLine(start, end);
            (Vertice, Vertice)vertices   = (null, null);
            if (line.Item1 != 0 && line.Item1 < int.MaxValue - 100 && line.Item1 > int.MinValue + 100)
            {
                (double, double)perpendicularLine = Line.GetPerpendicularThroughPoint(line, start);
                if (d2 < Line.DistanceVerticeFromLine(perpendicularLine, end))
                {
                    d2 = Line.DistanceVerticeFromLine(perpendicularLine, end) + 1;
                }
                double cos       = Angle.GetCosinusFromBetween(perpendicularLine, distanceLine);
                double sqrtDelta = Math.Sqrt(Math.Pow(2 * d * cos, 2) - 4 * (d * d - d2 * d2));
                double x1        = (2 * d * cos - sqrtDelta) / 2;
                double x2        = (2 * d * cos + sqrtDelta) / 2;
                double x         = Math.Min(x1, x2);
                if (x < 0)
                {
                    x = Math.Max(x1, x2);
                }
                vertices = PointHelpers.GetPointFromLineDistanceAndPoint(perpendicularLine, x, start);
                Vertice resultVertice = DistanceHelpers.GetCloserVerticeFromVertice(vertices, end);
                PointHelpers.SetPointXY(middle, resultVertice.x, resultVertice.y);
            }
            else
            {
                SetPerpednicularNextPerpendicular(siblingEdge, currentEdge, nextEdge);
            }
        }