Name

ST_RotateX — Rotates a geometry, an Angle (in radians), around the X axis.

Synopsis

bytea ST_RotateX(bytea Geometry, double AngleRadians);

Alias

RotateX

Description

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

Transformation matrix

Equations to transform the vertices

[Note]

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

ST_Affine(geomA, 1, 0, 0, 0, cos(rotRadians), -sin(rotRadians), 0, sin(rotRadians), cos(rotRadians), 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_RotateX(ST_GeomFromEWKT('POINT (1 2.5 3 4)'),pi()));
--Result
POINT (1 -2.5 -3 4)

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

--Same Rotation with ST_Affine
SELECT ST_AsEWKT(ST_Affine(geomA, 1, 0, 0, 0, cos(rotRadians), -sin(rotRadians), 0, sin(rotRadians), cos(rotRadians), 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 -15 10.000000000000002, 5 -10 2)

Related functions

ST_Affine, ST_RotateY, ST_RotateZ