[postgis-users] ST_RotateX with pointOrigin!

Bborie Park dustymugs at gmail.com
Sat Dec 14 22:02:12 PST 2013


Sweet. Can you create a ticket and attach the patch?

Some unit tests would be nice so that expected behavior is maintained...
and bugs are caught.

Thanks!

-bborie


On Sat, Dec 14, 2013 at 7:57 PM, Stephen Mather
<stephen at smathermather.com>wrote:

> Ahem-- bugs fixed:
>
> -- Function: st_rotatex(geometry, double precision, geometry)
> CREATE OR REPLACE FUNCTION ST_RotateX(geomA geometry, rotRadians
> double precision, pointOrigin geometry)
>   RETURNS geometry AS
> $BODY$
>
> ----- Transform geometry to nullsville (0,0,0) so rotRadians will take
> place around the pointOrigin
> WITH transformed AS (
>     SELECT ST_Translate(geomA, -1 * ST_X(pointOrigin), -1 *
> ST_Y(pointOrigin), -1 * ST_Z(pointOrigin)) AS the_geom
>     ),
> ----- Rotate in place
> rotated AS (
>     SELECT ST_RotateX(the_geom, rotRadians) AS the_geom FROM transformed
>     ),
> ----- Translate back home
> rotTrans AS (
>     SELECT ST_Translate(the_geom, ST_X(pointOrigin),
> ST_Y(pointOrigin), ST_Z(pointOrigin)) AS the_geom
>     FROM rotated
>     )
> ----- profit
> SELECT the_geom from rotTrans
>
> ;
>
> $BODY$
>   LANGUAGE sql VOLATILE
>   COST 100;
>
>
> On Sat, Dec 14, 2013 at 8:37 PM, Stephen Mather
> <stephen at smathermather.com> wrote:
> > Hi All,
> >
> > I think I avoided doing linear algebra, which is good since I never
> > studied it... .
> >
> > This is my cludgy patch for making a version of
> >
> > geometry ST_RotateX(geometry geomA, float rotRadians, geometry
> pointOrigin)
> >
> > It's not pretty enough to be a real patch ('cause my brain couldn't do
> > that whole linear algebra thing, and hence why it's here and not the
> > developers list), but thought I'd share it anyway and get impressions,
> > and have some brighter minds make sure I don't have some major logic
> > failure here:
> >
> > -------
> >
> > DROP FUNCTION st_rotatex(geometry,double precision,geometry);
> >
> > CREATE OR REPLACE FUNCTION ST_RotateX(geomA geometry, rotRadians
> > double precision, pointOrigin geometry)
> >   RETURNS geometry AS
> > $BODY$
> >
> > ----- Transform geometry to nullsville (0,0,0) so rotRadians will take
> > place around the pointOrigin
> > WITH transformed AS (
> >     SELECT ST_Translate(geomA, -1 * ST_X(pointOrigin), -1 *
> > ST_Y(pointOrigin), -1 * ST_Z(pointOrigin)) AS the_geom
> >     ),
> > ----- Rotate in place
> > rotated AS (
> >     SELECT ST_RotateX(the_geom, rotRadians) FROM transformed
> >     ),
> > ----- Translate back home
> > rotTrans AS (
> >     SELECT ST_Translate(geomA, ST_X(pointOrigin), ST_Y(pointOrigin),
> > ST_Z(pointOrigin)) AS the_geom
> >     )
> > ----- profit
> > SELECT the_geom from rotTrans
> >
> > ;
> >
> > $BODY$
> >   LANGUAGE sql VOLATILE
> >   COST 100;
> _______________________________________________
> 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/20131214/14e46e65/attachment.html>


More information about the postgis-users mailing list