static double SegmentPosition(SegmentBase segment, Directions direction) {
     return direction == Directions.North ? segment.Start.X : -segment.Start.Y;
 }
 static internal bool SegmentsIntersect(SegmentBase first, SegmentBase second, out Point intersect) {
     return IntervalsIntersect(first.Start, first.End, second.Start, second.End, out intersect);
 }
 static internal Point SegmentIntersection(SegmentBase first, SegmentBase second) {
     // Caller expects segments to intersect.
     Point intersect;
     if (!SegmentsIntersect(first, second, out intersect)) {
         Debug.Assert(false, "intersect is not on both segments");
     }
     return intersect;
 }
 static internal Point SegmentIntersection(SegmentBase seg, Point from) {
     return SegmentIntersection(seg.Start, seg.End, from);
 }
 static internal bool SegmentsIntersect(SegmentBase first, SegmentBase second) {
     Point intersect;
     return SegmentsIntersect(first, second, out intersect);
 }
 static internal bool IsVertical(SegmentBase seg) {
     return IsVertical(PointComparer.GetPureDirection(seg.Start, seg.End));
 }
 static internal double Slope(SegmentBase seg, ScanDirection scanDir) {
     return Slope(seg.Start, seg.End, scanDir);
 }
 static internal bool PointIsOnSegmentInterior(SegmentBase seg, Point test) {
     return PointIsOnSegmentInterior(seg.Start, seg.End, test);
 }
 static internal bool IntervalsAreCollinear(SegmentBase first, SegmentBase second) {
     return IntervalsAreCollinear(first.Start, first.End, second.Start, second.End);
 }
 static internal bool IntervalsOverlap(SegmentBase first, SegmentBase second) {
     return IntervalsOverlap(first.Start, first.End, second.Start, second.End);
 }
 internal bool IsPerpendicular(SegmentBase seg) {
     return IsPerpendicular(seg.Start, seg.End);
 }
 internal bool IsFlat(SegmentBase seg) {
     return IsFlat(seg.Start, seg.End);
 }