public class Intersection extends Object
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.
Constructor and Description |
---|
Intersection() |
Modifier and Type | Method and 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).
|
public static Coordinate intersection(Coordinate p1, Coordinate p2, Coordinate q1, Coordinate q2)
null
is returned.p1
- an endpoint of line 1p2
- an endpoint of line 1q1
- an endpoint of line 2q2
- an endpoint of line 2CGAlgorithmsDD.intersection(Coordinate, Coordinate, Coordinate, Coordinate)
public static Coordinate lineSegment(Coordinate line1, Coordinate line2, Coordinate seg1, Coordinate seg2)
line1
- a point on the lineline2
- a point on the lineseg1
- an endpoint of the line segmentseg2
- an endpoint of the line segmentCopyright © 2024. All rights reserved.