Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


What is the fastest way to transform rigid body space


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Finalspace   Members   -  Reputation: 319

Like
0Likes
Like

Posted 25 July 2014 - 04:45 AM

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?



Sponsor:

#2 haegarr   Crossbones+   -  Reputation: 4580

Like
0Likes
Like

Posted 25 July 2014 - 09:09 AM

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, 25 July 2014 - 09:10 AM.


#3 cadjunkie   Members   -  Reputation: 1338

Like
0Likes
Like

Posted 25 July 2014 - 03:25 PM

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.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS