[Fluxus] how to get the local rotation of a primitive as a vector??

Claude Heiland-Allen claudiusmaximus at goto10.org
Wed Jan 27 07:31:58 PST 2010


Dave Griffiths wrote:
> On Tue, 2010-01-26 at 15:54 +0100, Rob Bothof wrote:
>> I've been reading on quaternions but this is still beyond my 
>> understanding of 3d math.
> 
> I would imagine that the flipping you describe with maim is gimbal
> lock[1] occurring. The proper way to avoid these problems is to use
> quaternions, but there are often quick hacky ways to solve it. 

Re: "how to get the local rotation of a primitive as a vector??" - the 
problem is that a 3D vector as a direction doesn't include information 
about any twists around that vector, so it's not enough to describe an 
orientation.  So sometimes you'll get extra twisting/flips that you 
don't want, (a result of gimbal lock).  Quaternions include the extra 
twist information (as far as I understand it), and you can convert a 
quaternion to a rotation matrix fairly easily (though using the 
quaternion directly maybe more computationally efficient).

Using quaternions isn't too hard (though understanding them might be, I 
get very confused).  There is one little algorithm I found the other day 
which might apply here, to calculate the quaternion that takes one 3D 
direction onto another 3D direction along the shortest arc between them:

http://www.gamedev.net/community/forums/topic.asp?topic_id=429507&whichpage=1&#2856228

Interpolating between quaternions (aka slerp) is a bit tricky, but you 
only have to write the code once (or once per language...).  I have some 
code I use for this (but not in Fluxus) which is essentially just an 
implementation in C of the equations from this:

http://www.lce.hut.fi/~ssarkka/pub/quat.pdf

It would be good to have a library of quaternion functions and 
conversions to/from various vector and matrix representations available 
in Fluxus, if there isn't already one.


Claude
-- 
http://claudiusmaximus.goto10.org



More information about the Fluxus mailing list