comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: 3D vector rotation to the Z axis
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: 3D vector rotation to the Z axis [message #74027 is a reply to message #73974] Thu, 16 December 2010 11:48 Go to previous messageGo to previous message
James[2] is currently offline  James[2]
Messages: 44
Registered: November 2009
Member
Do you have to use a rotation matrix? Quaternions (http://
en.wikipedia.org/wiki/Quaternion) are more numerically stable, and
there is an easy-to-use library by Craig Markwardt at
http://www.physics.wisc.edu/~craigm/idl/math.html. I was just using
them to draw some rotating polyhedra in IDL, and they work great!
Your code would look like this:

;define the axis of rotation
rotaxis = crossp (input, [0,0,1])

;find the angle of rotation
rotangle = transpose(input) # [0,0,1]

;make the quaternion
q = qtcompose(rotaxis, rotangle)

;do it
rotated = qtvrot(input, q)

;there is even a routine to create a rotation matrix from the
quaternion:
rmatx = qtmat(q)

by the way, I like the # operator. It lets you treat 1D arrays as
column vectors; then defining a matrix is just concatenating a group
of column vectors across the second dimension. Matrix-by-vector
multiplication works like you expect.

- James


On Dec 14, 12:28 pm, David Fanning <n...@dfanning.com> wrote:
> MartyL writes:
>> Any help appreciated.
>
> I don't have any suggestions. You obviously know more
> about this than I do. Just an observation. I know any
> time I try to translate matrix operations out of a book
> into IDL my head swells up to about three times its
> normal size trying to keep columns and rows straight.
>
> That said, using the # operator, rather than the ## operator
> always throws me back from discovering the solution at LEAST
> two days, sometimes more. :-(
>
> Cheers,
>
> David
>
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming:http://www.dfanning.com/
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Random NetCDF I/O error
Next Topic: Associating GeoTiFF tags with basic Mercator projection parameters?

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 16:06:52 PDT 2025

Total time taken to generate the page: 0.00234 seconds