findEdgeInSameDirection method

Edge? findEdgeInSameDirection(
  1. Coordinate p0,
  2. Coordinate p1
)

Returns the edge which starts at p0 and whose first segment is parallel to p1

@return the edge, if found null if the edge was not found

Implementation

Edge? findEdgeInSameDirection(Coordinate p0, Coordinate p1) {
  for (int i = 0; i < edges.length; i++) {
    Edge e = edges[i];

    List<Coordinate> eCoord = e.getCoordinates();
    if (matchInSameDirection(p0, p1, eCoord[0], eCoord[1])) return e;

    if (matchInSameDirection(
        p0, p1, eCoord[eCoord.length - 1], eCoord[eCoord.length - 2]))
      return e;
  }
  return null;
}