private void SortCounterPoints(List<CardinalLinkPoint> list)
        {
            for (int i = 0; i < list.Count; i++) {
                for (int j = 0; j < list.Count; j++) {
                    if (i != j) {
                        LinkPoint counterPoint1 = list[i].GetCounterPoint();
                        LinkPoint point1 = list[i];

                        LinkPoint counterPoint2 = list[j].GetCounterPoint();
                        LinkPoint point2 = list[j];

                        LineSegment lineSegment1 = new LineSegment(point1.Location, counterPoint1.Location);
                        LineSegment lineSegment2 = new LineSegment(point2.Location, counterPoint2.Location);

                        if (lineSegment1.Intersects(lineSegment2)) {
                            int t = 0;
                            t = list[i].X;
                            list[i].X = list[j].X;
                            list[j].X = t;

                            t = list[i].Y;
                            list[i].Y = list[j].Y;
                            list[j].Y = t;

                        }
                    }
                }
            }
        }
Exemple #2
0
 public void TestNonIntersection1()
 {
     LineSegment ls1 = new LineSegment(new Point(0, 0), new Point(100, 100));
     LineSegment ls2 = new LineSegment(new Point(100, 0), new Point(100, 50));
     Assert.IsFalse(ls1.Intersects(ls2));
 }
Exemple #3
0
 public bool Intersects(LineSegment l2)
 {
     return lineValue(l2.p1) * lineValue(l2.p2) < 0 &&
     l2.lineValue(this.p1) * l2.lineValue(this.p2) < 0;
 }
Exemple #4
0
 public void TesIntersection2()
 {
     LineSegment ls1 = new LineSegment(new Point(20, 10), new Point(30, 60));
     LineSegment ls2 = new LineSegment(new Point(10, 10), new Point(100, 30));
     Assert.IsTrue(ls1.Intersects(ls2));
 }