[postgis-users] ST_RotateX with pointOrigin!
Stephen Mather
stephen at smathermather.com
Sun Dec 15 11:15:08 PST 2013
Thanks Bob,
That looks like a great resource. Now when will one of my bits of
inspiration get permanently etched into a stone bridge? :D
Best,
Steve
On Sun, Dec 15, 2013 at 1:56 AM, Bob and Deb <bobdebm at gmail.com> wrote:
> So you don't like to do linear algebra? :-) Well, you might be interested
> in using Quaternion math for your rotations. You can even do rotations on
> an arbitrary axis. Take a look at this: http://3dgep.com/?p=1815
>
> -Bob
> On Dec 14, 2013 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
>>
>
> _______________________________________________
> 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/20131215/e6b70771/attachment.html>
More information about the postgis-users
mailing list