Re: [Algorithms] Rotation about arbitrary axis
Brought to you by:
vexxed72
From: Jamie F. <j.f...@re...> - 2000-08-21 17:41:26
|
Quaternions are the baby :) Unit quaternions can be very simply mapped to / from an axis and angle. If your axis of rotation is ( x , y , z ) and your angle is r, an associated quaternion is { x * sin ( r / 2 ) , y * sin ( r / 2 ) , z * sin ( r / 2 ) , cos ( r / 2 ) } There are 2 quaternions for any given axis and angle, because rotating around the negative vector by the negative angle is equivalent to the original rotation. But I don't have any code for the stuff I can give away, I'm afraid :) I'm sure there are plenty of references to appropriate stuff in the archives of the list... if they're working. :) Jamie Pierre Terdiman wrote: > Hi, > > Since I needed a piece of code to do that I searched the web and found: > http://www.iuk.tu-harburg.de/hypgraph/modeling/mod_tran/3drota.htm > > I used the final matrix at the bottom of the page, but it seems to fail when > the arbitrary axis actually is the Z axis. The third column gets erased > where it should at least contain a 1. This is obvious when looking at the > provided matrix, since the third column of the third row depends on the > rotation angle - and of course if the input axis already is the Z axis, it > shouldn't. > > Now, it sounds normal regarding the underlying method (mapping the rotation > axis to Z, etc). But I wonder whether there's an easy way to perform a real > arbitrary rotation about any arbitrary axis without using different code > paths according to the input axis. > > I think it can probably be done by introducing quaternions or better, > angle-axis, in the story. But err.... maybe there's something simpler. > > Pierre > > _______________________________________________ > GDAlgorithms-list mailing list > GDA...@li... > http://lists.sourceforge.net/mailman/listinfo/gdalgorithms-list |