public void TestIntersectionInit() { Vertex vA = new Vertex(2, 6); Vertex vB = new Vertex(2, 2); Intersection intersection = new Intersection(4, 4, vA, vB, Vertex.VertexType.Edge, ls1, ls2); Assert.AreEqual(4, intersection.GetX()); Assert.AreEqual(4, intersection.GetY()); Assert.AreEqual(vA, intersection.GetVA()); Assert.AreEqual(vB, intersection.GetVB()); Assert.AreEqual(2, intersection.Distance); }
public static Intersection GetClosestIntersection(Vertex v) { Vertex next = v.GetNextVertex(); Vertex prev = v.GetPrevVertex(); Vertex nextIntersection = MathLibrary.GetIntersectionPoint(new LineSegment(next, next.AngleBisector), new LineSegment(v, v.AngleBisector)); Vertex prevIntersection = MathLibrary.GetIntersectionPoint(new LineSegment(prev, prev.AngleBisector), new LineSegment(v, v.AngleBisector)); Vertex.VertexType type = Vertex.VertexType.Undefined; if (MathLibrary.GetDistanceBetweenLineAndVertex(v, next, nextIntersection) < MathLibrary.GetDistanceBetweenLineAndVertex(v, prev, prevIntersection)) { if (v.Type == Vertex.VertexType.Split || next.Type == Vertex.VertexType.Split) type = Vertex.VertexType.Split; else type = Vertex.VertexType.Edge; Intersection i = new Intersection(nextIntersection.GetX(), nextIntersection.GetY(), next, v, type, next.NextLineSegment, v.PrevLineSegment); return i; } else { if (v.Type == Vertex.VertexType.Split || prev.Type == Vertex.VertexType.Split) type = Vertex.VertexType.Split; else type = Vertex.VertexType.Edge; Intersection i = new Intersection(prevIntersection.GetX(), prevIntersection.GetY(), v, prev, type, prev.PrevLineSegment, v.NextLineSegment); return i; } }
public Element(Intersection intersection, Element parent) { this.intersection = intersection; this.leftE = null; this.rightE = null; this.parent = parent; this.ID = globalID; globalID++; }
public void Push(Intersection intersection) { if (head == null) { head = new Element(intersection, null); last = head; } else { if (last.Right != null) { UpdateLast(); } Element newElement = new Element(intersection, last); if (last.Left == null) last.Left = newElement; else if (last.Right == null) last.Right = newElement; bool resetLast = false; if (last == head) resetLast = true; if (newElement < newElement.Parent) Heapify(newElement); if (resetLast) last = head; } }
public void TestGetType() { Intersection intersection = new Intersection(4, 4, new Vertex(2, 6), new Vertex(2, 6), Vertex.VertexType.Edge, ls1, ls2); Assert.AreEqual(Vertex.VertexType.Edge, intersection.Type); }
public void TestGetLineSegments() { Intersection intersection = new Intersection(4, 4, new Vertex(2, 6), new Vertex(2, 6), Vertex.VertexType.Edge, ls1, ls2); Assert.AreEqual(ls1, intersection.GetLSVA()); Assert.AreEqual(ls2, intersection.GetLSVB()); }
public void TestEqualIntersections() { Intersection intersection1 = new Intersection(4, 4, new Vertex(2, 6), new Vertex(2, 6), Vertex.VertexType.Edge, ls1, ls2); Intersection intersection2 = new Intersection(4, 4, new Vertex(2, 6), new Vertex(2, 6), Vertex.VertexType.Edge, ls1, ls2); Assert.AreEqual(intersection1, intersection2); }