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
| Parameter | Type | Description |
|---|---|---|
geom | meshgeom | A meshgeom object representing a 3D mesh model |
sfmeshObject | sfmesh | An sfmesh object |
geometry | geometry | A 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
NULLif thegeomparameter 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
---------------
1Example 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该文章对您有帮助吗?