All Products
Search
Document Center

PolarDB:ST_ComputeFrustum

Last Updated:Mar 28, 2026

ST_ComputeFrustum computes the view frustum of a viewpoint and returns it as a meshgeom object for downstream spatial analysis.

Syntax

meshgeom ST_ComputeFrustum(cstring viewpoint);

Parameters

ParameterDescription
viewpointViewpoint configuration in JSON format. See the field reference below.

Viewpoint JSON fields

All fields are optional and fall back to their defaults if omitted.

{
  "x": 0,              // x-coordinate of the viewpoint
  "y": 0,              // y-coordinate of the viewpoint
  "z": 0,              // z-coordinate of the viewpoint
  "h": 0,              // height of the viewpoint
  "azimuth": 0,        // horizontal direction, in degrees clockwise from north (y-axis)
  "pitch": 0,          // vertical angle above (positive) or below (negative) the XOY plane, in degrees
  "distance": 100,     // maximum viewing distance
  "horizontalFov": 90, // horizontal field of view (FOV), in degrees
  "verticalFov": 60,   // vertical FOV, in degrees
  "depthMapSize": 128  // depth map resolution; higher values produce a finer frustum mesh
}
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)
azimuthHorizontal viewing direction, measured in degrees clockwise from north (the positive y-axis).0[-180, 180]
pitchVertical viewing angle relative to the XOY plane. Positive values point above the plane; negative values point below.0[-90, 90]
distanceMaximum viewing distance. Larger values extend the frustum's reach.100(0, +inf)
horizontalFovHorizontal field of view (FOV), in degrees.90(0, 180)
verticalFovVertical FOV, in degrees.60(0, 180)
depthMapSizeDepth map resolution. Larger values produce a finer frustum mesh.128(0, 2048]

Description

ST_ComputeFrustum builds a 3D view frustum from the given viewpoint parameters and returns it as a meshgeom geometry composed of triangular patches.

View frustum (top view)

image..png

View frustum (side view)

image..png

Examples

Count the number of triangular patches in the computed frustum:

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 32,766 is the number of 3D triangles that make up the frustum mesh. A higher depthMapSize produces more triangles and a more precise frustum boundary.