Followers 0

What is the fastest way to transform rigid body space

2 posts in this topic

Hi there,

currently my 2D rigidbody physics system uses world-space positions/rotations for mostly everything, even the contact points are in world-space.

It works fine, but i think its not good for performance to have everything in world-space and to transform all the bodies*vertices for each frame. Therefore i want to know, what is the fastest way to transform one bodys space into another bodys space.

My thought about that is that i treat one body A (The reference body) as static without any rotation at all and transform the other body (incident body B) into that space like this:

Offset position for bodyA = position of body B - postion of body A

Offset rotation for bodyA = rotation of body B - rotation of body A

Then i just add the offsets to bodyA position and rotation - and calculate separating axis, support points, contact points, all that stuff and leave it in that local space. After that, the contact manifold+points must be converted back into the space of the incident body - would this work, or is there some better way?

0

Share on other sites

If you think in homogeneous transformation matrices, then (using column vectors here) the placement of a model in the world is

P := T * R

where T denotes the position (as translation from the origin) and R denotes the orientation (as rotation from the identity rotation).

The inverse of this

P-1 = R-1 * T-1

defines the backward way from the world into the model local space.

So now, coming from model local space 1 and going into model local space 2 means

( R2-1 * T2-1 ) * ( T1 * R1 )

== R2-1 * ( T2-1 * T1 ) * R1

What can be seen from this is that subtracting the position of model 2 from model 1 is okay because of both transformations lie side by side, but subtracting rotation is not because both transformations are separated by translation.

As ever in such a situation, working with matrices is better than using components.

Edited by haegarr
0

Share on other sites

You probably could develop an algorithm using vectors and quaternions, but I don't think you can get faster (or simpler) than matrix math. If you're premultiplying all your matrices before you transform and solve for the inverse to get back, transforming is as easy as it's going to be.

0

Create an account

Register a new account