My engine uses a different scale than my physics implementation, so I need to scale everything accordingly when giving data to / retrieving data from bullet.
That works just fine, but I'm not sure about btRigidBody::getInvInertiaTensorWorld. According to this article all inertias have to be scaled by X. getInvInertiaTensorWorld returns a matrix, do I just scale the last column?
Scaling result of getInvInertiaTensorWorld?
-
- Posts: 27
- Joined: Thu Oct 30, 2014 9:15 pm
-
- Posts: 849
- Joined: Tue Sep 30, 2014 6:03 pm
- Location: San Francisco
Re: Scaling result of getInvInertiaTensorWorld?
I think you would be better off to scale the non-inverse inertia values assigned to the btRigidBody and then leave the inverse inertia alone. That wiki page may be incorrect. See this thread.
-
- Posts: 27
- Joined: Thu Oct 30, 2014 9:15 pm
Re: Scaling result of getInvInertiaTensorWorld?
Hm... btRigidBody::getLocalInertia returns a vector3, not matrix. My main goal is to calculate the torque I need to apply to an object over a period of time t to reach an angular velocity v.drleviathan wrote:I think you would be better off to scale the non-inverse inertia values assigned to the btRigidBody and then leave the inverse inertia alone. That wiki page may be incorrect. See this thread.
Pseudo code:
Code: Select all
auto targetAngularVelocity = Vector3(0,M_PI,0);
auto t = 1.f; // Time after which target angular velocity should be reached
auto torque = (targetAngularVelocity /t) *inverse(rigidBody->getInvInertiaTensorWorld());
How can I do that using btRigidBody::getLocalInertia instead of btRigidBody::getInvInertiaTensorWorld?
-
- Posts: 849
- Joined: Tue Sep 30, 2014 6:03 pm
- Location: San Francisco
Re: Scaling result of getInvInertiaTensorWorld?
Yes, btRigidBody::getLocalInertia() returns a btVector3 because it assumes the inertia tensor is diagonal in the local frame which means only the diagonal components are non-trivial. You set the local inertia diagonal (scaled as necessary) and then you let Bullet compute the InvInertiaTensorWorld for you. In other words, you scale the local inertia once when you set it, and then the world-frame inverse inertia tensor will be scaled for you when you ask for it.
Meanwhile: are you sure you want to twist the object around using torque? If you can achieve what you want by adjusting the angular velocity (maybe you can't, I dunno what exactly you're trying to do) then you should consider doing that: it is simpler.
Meanwhile: are you sure you want to twist the object around using torque? If you can achieve what you want by adjusting the angular velocity (maybe you can't, I dunno what exactly you're trying to do) then you should consider doing that: it is simpler.
-
- Posts: 27
- Joined: Thu Oct 30, 2014 9:15 pm
Re: Scaling result of getInvInertiaTensorWorld?
I want to simulate a quadcopter and I'm applying torque on the rotors, which would be more realistic I believe?drleviathan wrote:Meanwhile: are you sure you want to twist the object around using torque? If you can achieve what you want by adjusting the angular velocity (maybe you can't, I dunno what exactly you're trying to do) then you should consider doing that: it is simpler.
Anyway, I ended up scaling the inverted inertia matrix by the squared world scale and with that I get an accurate result. That means the wiki page was indeed incorrect, thanks for the tip!