[ODE] rotating a set of bodies in concert

Roel van Dijk roelvandijk at home.nl
Wed Nov 16 06:21:32 MST 2005


Well, the general case of transforming (moving, rotating, scaling, shearing) a 
set of points is to use a transformation matrix.

Moving is not so hard and you don't need a matrix for that. Just move all the 
bodies by the same amount.

If you want to rotate the bodies you'll first have to ask the question: 
"around what point do I want to rotate the bodies?" Then calculate the 
positions of all the bodies relative to that point. (Just substract the 
central point from the other points). Then construct the correct rotation 
matrix*. Use the rotation matrix to transform the relative positions 
(multiply the position vectors by the matrix). This gives you a set of 
rotated body positions relative to point you've chosen. Add that point to the 
rotated positions to get there final absolute coordinates.


* Making a rotation matrix in ODE
ODE has some utility functions for matrices because there used a lot in ODE. 
The definitions are in rotation.h, matrix.h and odemath.h.
I can't seem to find a usefull function to transform a 3d vector by a 4x4 
matrix so maybe you'll have to write on yourself. If someone knows if that 
function is in ODE I would also like to know it :-)


Matrix and Quaternion FAQ: http://skal.planet-d.net/demo/matrixfaq.htm

On Tuesday 15 November 2005 00:43, Keith Wiley wrote:
> I have a set of dBody objects, not dGeom objects and I would like to
> rotate them all into a new configuration, maintaining their relative
> locations.  Basically, have a chain composed of long slender
> rectangles (or cylinders), attached end to end with ball joints,
> thus, a nice little chain.  It works well.  To construct the chain
> with the links properly placed relative to one another before
> creating the joints, I lay the chain out cleanly on a cardinal axis,
> it just makes things easier.  After constructing the chain, I need to
> rotate the whole thing into position.  If the links were dGeoms, I
> could add them to a single dBody and rotate the body as a whole, but
> the links are individual dBodies.
>
> How do I do this?
>
> Thanks.


More information about the ODE mailing list