Sign in to follow this  

Compute Force And Torque

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
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.

Share this post


Link to post
Share on other sites

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

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this