All Products
Search
Document Center

:ST_ComputeFrustum

Last Updated:May 17, 2023

This topic describes the ST_ComputeFrustum function. This function returns the view frustum of a viewpoint.

Syntax

meshgeom  ST_ComputeFrustum(cstring viewpoint);

Parameters

Parameter

Description

viewpoint

The information about the viewpoint.

The value is in the JSON format.

{
  "x": 0,  //The x-coordinate of the viewpoint.      
  "y": 0,  //The y-coordinate of the viewpoint.
  "z": 0,  //The z-coordinate of the viewpoint.
  "h": 0,   //The height of the viewpoint.
  "azimuth": 0,  //The azimuth of the viewpoint.
  "pitch": 0,  //The pitch angle of the viewpoint.
  "distance": 100,  //The maximum viewing distance.
  "horizontalFov": 90,  //The horizontal field of view (FOV).
  "verticalFov": 60  //The vertical FOV.
  "depthMapSize": 128  //The size of a depth map.
}

The following table describes the fields in the JSON value.

Field

Description

Valid values

x

The x-coordinate of the viewpoint. Default value: 0.

(-inf, +inf)

y

The y-coordinate of the viewpoint. Default value: 0.

(-inf, +inf)

z

The z-coordinate of the viewpoint. Default value: 0.

(-inf, +inf)

h

The height of the viewpoint. Default value: 0.

[0, +inf)

azimuth

The angle that rotates in the clockwise direction starting from the north (y-axis forward direction) to the viewing point. Default value: 0. Unit: degrees.

[-180, 180]

pitch

The pitch angle, which indicates the angle between the viewing point and the XOY plane. If the viewing point is above the XOY plane, the pitch angle is positive. Otherwise, the pitch angle is negative. Default value: 0. Unit: degrees.

[-90, 90]

distance

The maximum viewing distance. A larger value indicates a wider coverage of the view frustum. Default value: 100.

(0, +inf)

horizontalFov

The horizontal FOV. Default value: 90. Unit: degrees.

(0, 180)

verticalFov

The vertical FOV. Default value: 60. Unit: degrees.

(0, 180)

depthMapSize

The size of the depth map. A larger size indicates a finer view frustum. Default value: 128.

(0, 2048]

Description

This function calculates the view frustum of the given viewpoint.

Examples:

View frustum (top view)

image..png

View frustum (side view)

image..png

Examples

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
Note

The return value indicates that the view frustum consists of 32,766 3D triangles.