matchInSameDirection method

bool matchInSameDirection(
  1. Coordinate p0,
  2. Coordinate p1,
  3. Coordinate ep0,
  4. Coordinate ep1,
)

The coordinate pairs match if they define line segments lying in the same direction. E.g. the segments are parallel and in the same quadrant (as opposed to parallel and opposite!).

Implementation

bool matchInSameDirection(
    Coordinate p0, Coordinate p1, Coordinate ep0, Coordinate ep1) {
  if (!p0.equals(ep0)) return false;

  if (Orientation.index(p0, p1, ep1) == Orientation.COLLINEAR &&
      Quadrant.quadrantFromCoords(p0, p1) ==
          Quadrant.quadrantFromCoords(ep0, ep1)) return true;
  return false;
}