Skip to main content
GameDev.net gamedev.net
🔒 Locked

Apply Torque At Point Other Than CM (@Joint Anchor)

Started by crashlander Oct 31, 2006 at 8:50 PM 9 replies 2.4k views
Original Post
crashlander
crashlander
I'm having diffuculty with what seems like it should be a simple problem. I have a standard run-of-the-mill 2D rigid body system. I can create bodies and apply forces and torques and all is good and working properly. To this point all the torques are applied at the bodies center of mass. Now, however, I've created a 2D revolute joint (essentially a hinge joint since it's in 2D) and I want to create an Angular-Spring that acts at the anchor point. I can calculate the torque based on the angular difference, but my problem is I don't know how to apply the torque at the ANCHOR point. When I apply a torque at the center of mass, I simply integrate the AngularVelocity and Rotation using the angular equivalent of F=ma. But how do I do this when the torque is not being applied at the center of mass? -Jeff
-jeff
erissian
erissian
Well, torque in general should be applied at the axis of rotation. It just happens that for a rigid body in free space, the axis of rotation will coincide with the center of mass.

For an angular spring, use τ = αI = -kθ. Integrate it the same way, except your axis of rotation isn't at the center of mass, it's at the hinge.
We''re sorry, but you don''t have the clearance to read this post. Please exit your browser at this time. (Code 23)
crashlander
crashlander
So then I needed to keep track of a second AngularVelocity about the anchor?

Here is how I integrate about the center of mass

velocity:
dw = AngularAcceleration * dt;
_previousAngularVelocity = _angularVelocity;
_angularVelocity = _previousAngularVelocity += dw;

rotation:
orientationChange = _angularVelocity * dt;
_previousOrientation = _orientation;
Orientation = _previousOrientation + orientationChange;

You are saying I should use this same type of logic for each anchor? I can look into doing that.
-jeff
erissian
erissian
Exactly!

Each hinge will need to be integrated that way.
We''re sorry, but you don''t have the clearance to read this post. Please exit your browser at this time. (Code 23)
crashlander
crashlander
Ok, then this is where I'm confused.

Do I integerate about the anchor in ADDItION to my normal integeration about the center of mass? Or does integration about the anchor replace my normal integration about the center of mass. Seems like I'd need to do one or the other else they would conflict with eachother.

What happens if I allow an anchor/joint to "break". Do I then go back to integrating about the center of mass?

Thanks for you help on this.
-jeff
grhodes_at_work
grhodes_at_work
Keep in mind that a pure torque does not really act along a line in space. That is to say that after you have computed a torque, it no longer has anything to do with position. It only affects orientation. The thing that keeps an object in place, or a hinge line fixed, is constraint reaction forces (not torques).

It is easy to see that the net torque on an object has nothing at all to do with a specific point or line on the object. You can see this by a mind experiment. Lets say you have a rigid beam hanging from a ceiling, with a hinge that allows it to rotate about the x axis (parallel to the ceiling). Z is pointing up. Now, apply a force to the bottom of the beam in the positive y axis. If the hinge point is chosen as the reference point, you'll get a torque about the reference point that is in the x direction---causing the beam to rotate about the hinge axis at the ceiling. AT THE SAME TIME, the ceiling exerts a force in the negative y axis at the hinge point on the ceiling. This so-called reaction force, a constraint reaction force, causes no torque about the hinge point since it occurs at the hinge point----lever arm is zero length. So the net torque is in the positive x axis with a magnitude equal to the force times the length of the beam. Now...lets say we choose the bottom of the beam to be the reference point. In this case, the force we apply at the bottom (remember, this is in the positive y direction) causes no torque at all! The lever arm is zero at the reference point. BUT, that constraint reaction force at the ceiling still exists, in the negative y direction. That reaction force now has a lever arm that is the length of the beam, but for the purposes of computing torque the direction of the lever arm is the reverse of the first case, e.g., the lever arm points down (towards the reference point from the force point) instead of up. So, a negative lever arm direction times a negative reaction force equals......wait for it.....a torque in the positive x axis with magnitude equal to the force applied times the length of the beam. SAME EXACT TORQUE no matter what your reference point is. Conclusion...the net torque has nothing at all to do with a particular axis.

It is that reaction force on the ceiling that keeps the hinge line in place. Not the torque. As long as you compute your torques correctly, for all the forces involved, and as long as you compute your reaction forces correctly, you can do integration about any point in space and produce the correct motion with correct positioning of hinge lines or other constraint points.

Hmmm...so, then, integation is typically done at the center-of-mass for convenience. But, it does not have to be. If you know for certain where an axis of rotation will be, you can accumulate torques about a point on that axis, and do integration based on those torques. But, if you do things right, it simply does not matter. The critical thing is that you have to get the reaction forces correct.

Er....sometimes a constraint reaction will have both forces and torques. When it includes torques....same rule as above applies. Those torques may be different if you choose one reference point vs. another, but in the end they have nothing to do with keeping an axis in place.
Graham Rhodes Moderator, Math & Physics forum @ gamedev.net
grhodes_at_work
grhodes_at_work
For reasons you bring up, my suggestion is to always integrate about center-of-mass (has benefits other than those mentioned here too). And just be sure to get constraint reaction forces/torques correct to make sure hinges and contact points line up. Do it right, and it will work out elegantly. There is usually a correction step done to reduce creep that can happen due to floating point precision roundoff errors, but the basic idea is quite elegant.
Graham Rhodes Moderator, Math & Physics forum @ gamedev.net
crashlander
crashlander
Very interesting.

So lets see if I undertand this correctly with respect to my main goal: Implementing an Angular Spring.

My rigid body system already knows how to "ApplyTorques" by integrating about the center of mass.

For the AngularSpring system I compute a torque using the formula:

t = (SpringConstant * AngleOffset - DampningConstant * AngularVelocity)

At this point, I assumed I had to apply the torque, t, at the anchor point of my hinge joint and this is what was confusing me. Are you saying I can actually just apply the torque, t, like I do all other torques, by integrating about the center of mass?

Btw, my joint constraint is implemented using sequential impulses per Erin Catto's Box2D paper:

http://www.gphysics.com/downloads/

So far all the responses have been very helpful. Thanks.
-jeff
grhodes_at_work
grhodes_at_work
If your torque is a pure torque (e.g., it is a directly-applied torque and not in reality being computed from some force applied at a point), then yes, just add it----no need to be concerned about where it is applied. The challenge then becomes finding the correct response force to keep the hinge point in place. This would be done using your usual joint constraint force approach (see Baraff et al, etc.) or using penalty methods. For torques that in reality are being computed from a force applied at a point, you might as well go ahead and compute the torque about the correct reference point, e.g., the center-of-mass.
Graham Rhodes Moderator, Math & Physics forum @ gamedev.net
crashlander
crashlander
Here is how I apply torque in my Rigid Body system: (trimmed down to just the guts)

        public float AngularAcceleration {            get { return _torque / _momentOfInertia; }        }every loop:...             //angular velocity            dw = AngularAcceleration * dt;            _angularVelocity = _angularVelocity+= dw;...         //angle            orientationChange = _angularVelocity * dt;            Orientation = _orientation+ orientationChange;


The torque I calculate from my Angular spring would be applied directly to the _torque parameter.

The _torque parameter is zeroed out every loop.
-jeff
crashlander
crashlander
UPDATE:

It's all working perfect now. I just apply the torque to normally and all is good!

@grhodes_at_work. Thanks for your help!
-jeff

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.