0
\$\begingroup\$

I have the following situation: I've got a box with its center of mass transform matrix that I'm obtaining from physics simulation, i.e. it keeps changing with time. I've also got two points (actually two transformation matrices) which are static (the simulation doesn't calculate them, neither do I want it to) that I want to 'keep in sync' with the original state (t=0 in the picture).

enter image description here

Any ideas how do I calculate the other two matrices when the center of mass changes, while keeping their original offsets satisfied?

I'm using jBullet for physics.

\$\endgroup\$
0
\$\begingroup\$

As long as the transformation applied to the center of mass is only composed of rotation and translation (given that it comes from a physics simulation that should be true), that same transformation applied to your two non-simulated points will put them in the same relative position at t = 0.25 as they were in at t = 0.

Most physics engines provide a way for you to get the world transform of a given body's center of mass, either in matrix form or as separate translation and rotation components. For jBullet, that would be the getCenterOfMassTransform function.

Construct two Transform objects for both of your non-simulated points in their original position. Then use the mul method of Transform to multiply your non-simulated point transforms by the rigid body's transformation to bring your non-simulated points into the same relative orientation and position as the new center of mass.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ That's pretty much what I've been doing, but it doesn't quite work as expected. First, I get the center of mass, then I multiply the world bind matrix (those non-simulated points are actually part of my skeleton) by it. Do you think that the fact of the points being actually bones changes the equations? \$\endgroup\$ – Pateman Oct 31 '16 at 19:15
  • \$\begingroup\$ It is possible, yes. Your diagram suggests the two points are in the same coordinate space as the model-space center-of-mass, but if they're bones they may be in some slightly different space you'd need to account for (bringing them into the COM model-space) first. :\ \$\endgroup\$ – user1430 Oct 31 '16 at 19:34
  • \$\begingroup\$ I thought so, but it's strange because I'm passing the world bind matrix into the calculations... I'll accept your answer, because you pretty much confirmed my original assumptions. I need to figure out the rest. Thank you :) \$\endgroup\$ – Pateman Oct 31 '16 at 19:40
  • \$\begingroup\$ Try making one of these points essentially the same as the COM, for testing, and then follow it through the transformations. That can help illustrate when exactly things go off the rails. \$\endgroup\$ – user1430 Oct 31 '16 at 19:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.