Page 1 of 1

A 3D related question

Posted: Sat Nov 19, 2005 6:09 pm
by Polo
Hi !
I've got a 3D matrix related question :)
I've got a "pivot" that has a position (x,y,z), a rotation (pitch,yaw,roll (euler angles)).
I want it to be translated to the position + a vector (x',y',z') according to the rotation ;)
Ok, i've badly explained that, but does someone has a link or a code ?

Posted: Sun Nov 20, 2005 9:36 am
by dmoc
Lets see if I understand: you have a fixed translation T, a rotation R and another translation T' which is a function of the rotation, hence T'(R)? Correct? If so then the order is R, T'(R) then T (or visa versa) or in short R then T'' where T'' is sum of vectors T and T'(R). This is a lot more straight forward than it sounds: rotate, calc and add vectors, translate.

May help to think of operations acting on the origin rather than an object. HTH

Posted: Sun Nov 20, 2005 11:45 pm
by dell_jockey
What you need is what makes any motion simulator tick. You might want to check out the sources of an open source flight simulator: http://www.flightgear.org/

In general you can combine multiple rotations, translations, whatever into a single 'result' matrix and use this matrix to do the transformation of the coordinates of your 3D objects. This way, the coordinates of your object lists are visited only once per update.