A 3D related question

Everything else that doesn't fall into one of the other PB categories.
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

A 3D related question

Post 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 ?
dmoc
Enthusiast
Enthusiast
Posts: 739
Joined: Sat Apr 26, 2003 12:40 am

Post 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
dell_jockey
Enthusiast
Enthusiast
Posts: 767
Joined: Sat Jan 24, 2004 6:56 pm

Post 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.
cheers,
dell_jockey
________
http://blog.forex-trading-ideas.com
Post Reply