Package org.locationtech.jts.algorithm
Class Intersection
- java.lang.Object
-
- org.locationtech.jts.algorithm.Intersection
-
public class Intersection extends java.lang.Object
Functions to compute intersection points between lines and line segments.In general it is not possible to compute the intersection point of two lines exactly, due to numerical roundoff. This is particularly true when the lines are nearly parallel. These routines uses numerical conditioning on the input values to ensure that the computed value is very close to the correct value.
The Z-ordinate is ignored, and not populated.
- Author:
- Martin Davis
-
-
Constructor Summary
Constructors Constructor Description Intersection()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Coordinate
intersection(Coordinate p1, Coordinate p2, Coordinate q1, Coordinate q2)
Computes the intersection point of two lines.static Coordinate
lineSegment(Coordinate line1, Coordinate line2, Coordinate seg1, Coordinate seg2)
Computes the intersection point of a line and a line segment (if any).
-
-
-
Method Detail
-
intersection
public static Coordinate intersection(Coordinate p1, Coordinate p2, Coordinate q1, Coordinate q2)
Computes the intersection point of two lines. If the lines are parallel or collinear this case is detected andnull
is returned.- Parameters:
p1
- an endpoint of line 1p2
- an endpoint of line 1q1
- an endpoint of line 2q2
- an endpoint of line 2- Returns:
- the intersection point between the lines, if there is one, or null if the lines are parallel or collinear
- See Also:
CGAlgorithmsDD.intersection(Coordinate, Coordinate, Coordinate, Coordinate)
-
lineSegment
public static Coordinate lineSegment(Coordinate line1, Coordinate line2, Coordinate seg1, Coordinate seg2)
Computes the intersection point of a line and a line segment (if any). There will be no intersection point if:- the segment does not intersect the line
- the line or the segment are degenerate (have zero length)
- Parameters:
line1
- a point on the lineline2
- a point on the lineseg1
- an endpoint of the line segmentseg2
- an endpoint of the line segment- Returns:
- the intersection point, or null if it is not possible to find an intersection
-
-