ST_3DDistance

更新时间:
复制 MD 格式

Returns the shortest 3D distance between two spatial objects as a float8 value.

Syntax

float8 ST_3DDistance(meshgeom geom, meshgeom geom);
float8 ST_3DDistance(sfmesh sfmeshObject, sfmesh sfmeshObject);
float8 ST_3DDistance(meshgeom geom, geometry geometry);
float8 ST_3DDistance(sfmesh sfmeshObject, geometry geometry);

Parameters

ParameterTypeDescription
geommeshgeomA meshgeom object representing a 3D mesh model
sfmeshObjectsfmeshAn sfmesh object
geometrygeometryA standard geometry object

Usage notes

  • Pass two meshgeom or two sfmesh objects to measure the distance between two 3D models.

  • Pass a meshgeom or sfmesh together with a geometry object to measure the distance between a 3D model and a 3D geometry object.

  • Returns NULL if the geom parameter is invalid.

Examples

Example 1: Distance between two meshgeom objects

Each object defines a single triangular patch in 3D space. The two triangles are 1 unit apart along the X axis.

SELECT ST_3DDistance(
    'MESHGEOM(PATCH(TRIANGLE Z(0 0 0,0 10 0,0 0 10)))'::meshgeom,
    'MESHGEOM(PATCH(TRIANGLE Z(1 0 0,1 1 0,1 0 1)))'::meshgeom
);

Result:

 st_3ddistance
---------------
             1

Example 2: Distance between a meshgeom object and a point geometry

The meshgeom object uses an indexed surface (INDEXSURFACE) with four vertices. The point is located 1 unit away from the surface along the X axis.

SELECT ST_3DDistance(
    'MESHGEOM(PATCH(INDEXSURFACE  Z(VERTEX(0 0 0,0 10 0,0 0 10,10 0  0), INDEX((0,1,2),(1,0,3),(3,0,2),(2,1,3)))))'::meshgeom,
    'POINT(-1 0 0)'::geometry
);

Result:

 st_3ddistance
---------------
             1