GEOS  3.14.0dev
Static Public Member Functions | List of all members
geos::algorithm::Intersection Class Reference

Functions to compute intersection points between lines and line segments. More...

#include <Intersection.h>

Static Public Member Functions

static geom::CoordinateXY intersection (const geom::CoordinateXY &p1, const geom::CoordinateXY &p2, const geom::CoordinateXY &q1, const geom::CoordinateXY &q2)
 Computes the intersection point of two lines. If the lines are parallel or collinear this case is detected and null is returned. More...
 
static geom::CoordinateXY intersectionLineSegment (const geom::CoordinateXY &line1, const geom::CoordinateXY &line2, const geom::CoordinateXY &seg1, const geom::CoordinateXY &seg2)
 

Detailed Description

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.

Member Function Documentation

◆ intersection()

static geom::CoordinateXY geos::algorithm::Intersection::intersection ( const geom::CoordinateXY &  p1,
const geom::CoordinateXY &  p2,
const geom::CoordinateXY &  q1,
const geom::CoordinateXY &  q2 
)
static

Computes the intersection point of two lines. If the lines are parallel or collinear this case is detected and null is returned.

Parameters
p1an endpoint of line 1
p2an endpoint of line 1
q1an endpoint of line 2
q2an 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)

◆ intersectionLineSegment()

static geom::CoordinateXY geos::algorithm::Intersection::intersectionLineSegment ( const geom::CoordinateXY &  line1,
const geom::CoordinateXY &  line2,
const geom::CoordinateXY &  seg1,
const geom::CoordinateXY &  seg2 
)
static

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)

If the segment is collinear with the line the first segment endpoint is returned.

Parameters
line1a point on the line
line2a point on the line
seg1an endpoint of the line segment
seg2an endpoint of the line segment
Returns
the intersection point, or null if it is not possible to find an intersection

The documentation for this class was generated from the following file: