Calculates the intersections between a set of rays and an sfmesh object in a single call.
Syntax
geometry ST_RayIntersection(sfmesh sfmesh, geometry mpoint, geometry direction);Parameters
| Parameter | Type | Description |
|---|---|---|
sfmesh | sfmesh | The sfmesh model object. |
mpoint | MULTIPOINT | The endpoint of the ray. |
direction | POINT | The shared direction of all rays. All rays in the batch travel in this direction. |
Return value
Returns a MULTIPOINT geometry representing the intersections of sfmesh objects and rays.
If no intersection exists, EMPTY is returned.
Usage notes
mpointspecifies the endpoint of the ray and is of the MULTIPOINT type.directionspecifies the direction of the ray and is of the POINT type.All rays share a single direction, specified by
direction. To calculate intersections for rays in different directions, callST_RayIntersectionseparately for each direction.The input
sfmeshis typically created by casting a geometry tomeshgeom(for example,'POLYGON(...)'::geometry::meshgeom).
Examples
Rays intersecting a mesh plane
Calculate the intersections of four rays — all traveling in the direction (0, 1, 0) — against a unit-square mesh centered at the origin on the XY 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
)
);Expected output:
MULTIPOINT Z ((0 0 0),(0 1 0),(0 -1 0),(0 -1 0))