All Products
Search
Document Center

PolarDB:ST_YupToZup

Last Updated:Mar 28, 2026

Flips the Y and Z axes of an sfmesh object to convert it from a Y-up coordinate system to a Z-up coordinate system.

Syntax

sfmesh ST_YupToZup(sfmesh mesh);

Parameters

ParameterDescription
meshThe sfmesh object to convert.

Return value

Returns the sfmesh object after the Y and Z axes are flipped.

Description

ST_YupToZup swaps the Y and Z axes of the input sfmesh object. Use this function when importing 3D models that use a Y-up coordinate convention (such as assets from some 3D modeling tools) into a pipeline that expects Z-up orientation (such as BIM or GIS workflows).

The transformation is equivalent to calling ST_Affine with the following matrix: This matrix applies the coordinate mapping x' = x, y' = z, z' = -y. The Y axis becomes the new Z axis, and the original Z axis (negated) becomes the new Y axis.
1.0, 0,    0,   0,
0,   0,    1.0, 0,
0,   -1.0, 0,   0

Example

SELECT ST_AsText(ST_YupToZup(ST_MeshFromText('{"version" : 1, "root" : 0, "meshgeoms" : ["MESHGEOM(PATCH(INDEXSURFACE Z (VERTEX(0 0 2,0 10 3,10 10 1,10 0 1),INDEX((0,1,2),(1,2,3)))))"], "primitives" : [{"meshgeom" : 0}], "nodes" : [{"primitive" : 0}]}')));

Result:

{"version" : 1, "root" : 0, "meshgeoms" : ["MESHGEOM(PATCH(INDEXSURFACE Z (VERTEX(0 0 2,0 10 3,10 10 1,10 0 1),INDEX((0,1,2),(1,2,3)))))"], "primitives" : [{"meshgeom" : 0}], "nodes" : [{"primitive" : 0,"matrix" : [1,0,0,-1,0,0,0,0,1,0,0,0,0,0,0,1]}]}

The output node includes a matrix field that encodes the axis-flip transformation. The mesh geometry is unchanged; the conversion is applied through the scene graph node matrix.