All Products
Search
Document Center

PolarDB:ST_ComputeFrustum

Last Updated:Mar 28, 2026

Computes the 3D view frustum of a viewpoint and returns it as a meshgeom object.

Syntax

meshgeom  ST_ComputeFrustum(cstring viewpoint);

Parameters

ParameterDescription
viewpointThe viewpoint definition in JSON format. See the field reference below.

Viewpoint JSON fields

FieldDescriptionDefaultValid values
xThe x-coordinate of the viewpoint.0(-inf, +inf)
yThe y-coordinate of the viewpoint.0(-inf, +inf)
zThe z-coordinate of the viewpoint.0(-inf, +inf)
hThe height of the viewpoint.0[0, +inf)
azimuthThe horizontal viewing direction, measured clockwise from north (the positive y-axis direction). Unit: degrees.0[-180, 180]
pitchThe vertical tilt of the viewing direction relative to the XOY plane. Positive values tilt upward (above the XOY plane); negative values tilt downward (below the XOY plane). Unit: degrees.0[-90, 90]
distanceThe maximum viewing distance. A larger value produces a frustum with wider coverage.100(0, +inf)
horizontalFovThe horizontal field of view (FOV). Unit: degrees.90(0, 180)
verticalFovThe vertical FOV. Unit: degrees.60(0, 180)
depthMapSizeThe depth map resolution used to compute the frustum shape. A larger value produces a finer frustum.128(0, 2048]

Description

ST_ComputeFrustum computes a 3D view frustum from the given viewpoint parameters. The returned meshgeom object represents the visible volume from that viewpoint and is composed of 3D triangles.

The following diagrams illustrate the computed frustum shape.

View frustum (top view)

image..png

View frustum (side view)

image..png

Examples

The following example computes a view frustum at a specific viewpoint and uses ST_NumPatches to count the 3D triangles in the result.

SELECT ST_NumPatches(ST_ComputeFrustum('{"x" : 2938, "y" : 750, "z" : 90, "h" : 1.8, "azimuth" : 90, "pitch" : -35, "horizontalFov" : 90, "verticalFov" : 60, "distance" : 600, "depthMapSize" : 128}'));
--------
32766
The result 32766 is the number of 3D triangles that make up the computed view frustum.