public static int Compare(EndPoint a, EndPoint b) { //return ShadowMathUtils.Approximately(a, b); // Traverse in angle order if (a.Angle > b.Angle) return 1; if (a.Angle < b.Angle) return -1; // But for ties (common), we want Begin nodes before End nodes if (!a.Begin && b.Begin) return 1; if (a.Begin && !b.Begin) return -1; return 0; }
private void InsertPoint(EndPoint p) { if (p.Begin) { bool inserted = false; for (int index = 0; index < Open.Count; index++) { Segment test = Open[index]; if (Segment.IsInFrontOf(p.Segment, test, Center) != Segment.IntersectionResult.InFront) { Open.Insert(index, p.Segment); inserted = true; break; } } if (!inserted) { Open.Add(p.Segment); } } else { Open.Remove(p.Segment); } }
public Segment(Vector2 start, Vector2 end) { Start = new EndPoint(start, this); End = new EndPoint(end, this); Slope = (end - start).normalized; }