ST_RotateY

更新时间:
复制 MD 格式

Rotates a geometry object by a specified angle about the Y axis.

Syntax

geometry ST_RotateY(geometry geomA, float rotRadians);

Parameters

ParameterDescription
geomAThe geometry object to rotate.
rotRadiansThe rotation angle in radians.

Description

ST_RotateY(geomA, rotRadians) is shorthand for ST_Affine(geomA, 1, 0, 0, 0, cos(rotRadians), -sin(rotRadians), 0, sin(rotRadians), cos(rotRadians), 0, 0, 0).

Supported geometry types: circular strings, curves, polyhedral surfaces, triangles, triangulated irregular network (TIN) surfaces, and 3D objects.

Examples

Rotate a 3D line 90 degrees about the Y axis:

-- Rotate a 3D line 90 degrees about the Y axis (pi()/2 radians)
SELECT ST_AsEWKT(ST_RotateY(ST_GeomFromEWKT('LINESTRING(1 2 3, 1 1 1)'), pi()/2));
         st_asewkt
---------------------------
 LINESTRING(3 2 -1,1 1 -1)
(1 row)

Rotate a 2D line 180 degrees about the Y axis:

-- Rotate a 2D line 180 degrees about the Y axis (pi() radians)
SELECT ST_AsEWKT(ST_RotateY('LINESTRING (1 2,2 2)'::geometry, pi()));
       st_asewkt
-----------------------
 LINESTRING(-1 2,-2 2)
(1 row)

See also

  • ST_RotateX: Rotates a geometry object about the X axis.

  • ST_RotateZ: Rotates a geometry object about the Z axis.

  • ST_Affine: Applies a 3D affine transformation to a geometry object.