Calculates the intersections between an sfmesh object and a set of rays that share the same direction vector.
Syntax
geometry ST_RayIntersection(sfmesh sfmesh, geometry mpoint, geometry direction);Return value
Returns a MULTIPOINT geometry representing the intersections of sfmesh objects and rays. Returns EMPTY if no intersection exists.
Parameters
| Parameter | Type | Description |
|---|---|---|
sfmesh | sfmesh | The sfmesh model object. |
mpoint | MULTIPOINT | The endpoint of the ray. |
direction | POINT | The direction of the ray. |
Usage notes
All rays in a single call share the same direction. To calculate intersections for rays with different directions, call
ST_RayIntersectiononce per direction.directionis a direction vector, not a target position. Each ray starts from a point inmpointand extends along this vector.
Examples
The following example calculates intersections for four rays. Each ray starts from one of the four points in mpoint and travels in the +Y direction. The sfmesh is a flat polygon on the Z=0 plane.
SELECT ST_AsText(ST_RayIntersection(
'POLYGON((-1 -1 0, 1 -1 0, 1 1 0, -1 1 0, -1 -1 0))'::geometry::meshgeom,
'MULTIPOINT(0 0 0, 0 1 0, 0 -1 0, 0 -2 0)'::geometry,
'POINT(0 1 0)'::geometry
));Output:
MULTIPOINT Z ((0 0 0),(0 1 0),(0 -1 0),(0 -1 0))