All Products
Search
Document Center

PolarDB:ST_RayIntersection

Last Updated:Mar 28, 2026

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

ParameterTypeDescription
sfmeshsfmeshThe sfmesh model object.
mpointMULTIPOINTThe endpoint of the ray.
directionPOINTThe 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_RayIntersection once per direction.

  • direction is a direction vector, not a target position. Each ray starts from a point in mpoint and 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))