intersection method

Coordinate? intersection(
  1. LineSegment line
)

Computes an intersection point between two line segments, if there is one. There may be 0, 1 or many intersection points between two segments. If there are 0, null is returned. If there is 1 or more, exactly one of them is returned (chosen at the discretion of the algorithm). If more information is required about the details of the intersection, the {@link RobustLineIntersector} class should be used.

@param line a line segment @return an intersection point, or null if there is none

@see RobustLineIntersector

Implementation

Coordinate? intersection(LineSegment line) {
  LineIntersector li = new RobustLineIntersector();
  li.computeIntersection(p0, p1, line.p0, line.p1);
  if (li.hasIntersection()) return li.getIntersection(0);
  return null;
}