Name

ST_RotateZ — Rotates a geometry, an Angle (in radians), around the Z axis.

Synopsis

bytea ST_RotateZ(bytea Geometry, double AngleRadians);

Alias

RotateZ, ST_Rotate, Rotate

Description

Rotates a geometry, an Angle (in radians), around the Z axis. In the following table transformation matrices and equations to transform the vertices are shown.

Transformation matrix

Equations to transform the vertices

[Note]

ST_RotateZ (geomA, rotRadians) is an abreviation for the method:

ST_Affine(geomA, cos(rotRadians), -sin(rotRadians), 0, sin(rotRadians), cos(rotRadians), 0, 0, 0, 1, 0, 0, 0)

Coordinate Dimensions
2D3DM
Spatial Standards Support
OGC SFS for SQL. 1.1 (1999)OGC SFS for SQL. 1.1.0 (2005)OGC SFS for SQL. 1.2.0 (2006)SQL-MM Part 3
----

Examples

--Rotates 180º a 4D Point
SELECT ST_AsEWKT(ST_RotateZ(ST_GeomFromEWKT('POINT (1 2.5 3 4)'),pi()));
--Result
POINT (-1 -2.5 3 4)

--Rotates 90º 
SELECT ST_AsEWKT(ST_Rotate(ST_GeomFromEWKT('LINESTRING (10 10 15, 5 2 10)'),pi()/2));
--Result
LINESTRING (-10 10 15, -2 5 10)

--Same Rotation with ST_Affine
SELECT ST_AsEWKT(ST_Affine(geomA, cos(rotRadians), -sin(rotRadians), 0, sin(rotRadians), cos(rotRadians), 0, 0, 0, 1, 0, 0, 0)) 
 FROM (SELECT ST_GeomFromEWKT('LINESTRING (10 10 15, 5 2 10)') as geomA, pi()/2 as rotRadians) as foo;     

--Result
LINESTRING (-10 10 15, -2 5 10)

Related functions

ST_Affine, ST_RotateX, ST_RotateY