# Compute Force And Torque

This topic is 5020 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

hi, I read this tutorial : C++ Data Structures for Rigid-Body Physics on gamasutra The point is I understand all the things, exept one, when he call this fonction : ComputeForceAndTorque(Force, Torque); in this code :
void cRigidBody::Animate()
{
// Pour tenir la force et le torque
cVector Force, Torque;

// on effectu les déplacements qu'on connait déjà là
Translate(m_Vel * Elapsedf);
RotateArbitrary(m_AngVel * Elapsedf);

// On compute la force et le torque
ComputeForceAndTorque(Force, Torque);

// On save les previous
m_PrevState.setVelocity(m_Vel);
m_PrevState.setAngularVelocity(m_Vel);

// On modifi nos déplacement genre
m_Vel += (1/m_Mass) * Force * Elapsedf;
m_AngVel += m_InvInertia * (Torque - cVector::CrossProduct(m_AngVel, m_Inertia*m_AngVel)) * Elapsedf;
}

And it append that is one of the only fonction he didnt define in the tutorial :(. What I supose to do with Force and Torque? Me i think to create a fonction like : ApplyForce(cVector, float) that will compute the vel and angular vel. But what about torque ? thanks!

##### Share on other sites
The point of that function not being defined is that it is application-dependent. Depending on the type of simulation, 'forces' could include gravity, wind, lift and drag for an airplane, etc.

Applying a force at a point on a rigid body will induce both linear and angular momentum (unless the force vector is through the center of gravity). In other words, generally torque arises from force rather than being applied directly.

Having a ComputeForceAndTorque() function is one way to do it, but it requires knowing about all forces at the time the function is called. The way I've seen it done more often is to have an ApplyForce() function which can be called at anytime prior to the physics update. Forces and torques are accumulated and reset to zero after the physics update.

Hope that helps.

1. 1
2. 2
3. 3
Rutin
22
4. 4
5. 5

• 10
• 16
• 14
• 9
• 9
• ### Forum Statistics

• Total Topics
632928
• Total Posts
3009273
• ### Who's Online (See full list)

There are no registered users currently online

×