[postgis-users] ST_RotateX with pointOrigin!

Rémi Cura remi.cura at gmail.com
Mon Dec 16 05:54:05 PST 2013


Not complaining or whatever,
but a truly generic rotation function can be made by using a single
ST_Affine call

ST_Affine(T^-1. R . T) ,
where T is the 4-4 translation matrix (id + translation vector on last
column), and R is a rotation matrix (possibly a composition of rotation
around X,Y,Z. It will be order dependent).

It is a little boring to do the matrix multiplication, but this should
simplify well, and some software will do it once and for all.
Rotation matrix are very simple (
http://fr.wikipedia.org/wiki/Matrice_de_rotation)

Cheers,

Rémi-C


2013/12/16 Stephen Mather <stephen at smathermather.com>

> Hmm, I know so little about Euler, strike, dip and rake.  What are the
> advantages?
>
> What I do know is that it's easy now to construct a 3 axis rotation
> function (which also might be better handled with ST_Affine):
>
> http://trac.osgeo.org/postgis/attachment/ticket/2575/
>
> -- Function: st_rotatezyz(geometry, double precision, double precision,
> double precision, geometry)
> CREATE OR REPLACE FUNCTION ST_RotateXYZ(geomA geometry, rotRadiansX double
> precision, rotRadiansY double precision, rotRadiansZ double precision,
> pointOrigin geometry)
>   RETURNS geometry AS
> $BODY$
>
> -- Rotate around X-axis
> WITH rotatedX AS (
>     SELECT ST_RotateX(geomA, rotRadiansX, pointOrigin) AS geom
>     ),
> -- Rotate around Y-axis
> rotatedXY AS (
>     SELECT ST_RotateY(geom, rotRadiansY, pointOrigin) AS geom
>       FROM rotatedX
>     ),
> -- Rotate around Z-axis
> rotatedXYZ AS (
>     SELECT ST_Rotate(geom, rotRadiansZ, pointOrigin) AS geom
>       FROM rotatedXY
>     )
> -- Return rotated geometry
> SELECT geom from rotatedXYZ
>
> ;
>
> $BODY$
>   LANGUAGE sql VOLATILE
>   COST 100;
>
>
>
> On Sun, Dec 15, 2013 at 9:27 PM, Mike Toews <mwtoews at gmail.com> wrote:
>
>> What do you need to rotate on either X or Y axes? And is it always
>> aligned to either grid directions? I personally see these functions as
>> rather limiting and wouldn't miss them if they vanished.
>>
>> I have thought of developing a better 3d rotate function that is
>> independent of grid X and Y assumptions. Either a function that takes Euler
>> angles, or strike & dip (& possibly rake) angles used by geologists. If
>> there is any interest on these, I can figure some stuff out.
>>
>> -Mike
>>
>> _______________________________________________
>> postgis-users mailing list
>> postgis-users at lists.osgeo.org
>> http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
>>
>
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at lists.osgeo.org
> http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20131216/26ad70f2/attachment.html>


More information about the postgis-users mailing list