Page 1 of 1

how to get internal forces in constrains ?

Posted: Sun Mar 06, 2016 10:45 am
by yanbo2u
I have two boxes that are constrained by a RevoluteJoint. I want to know the internal forces that are exerted on the joint, satisfying the constrain. It should be in the form of a direction plus the magnitude of the force.

the code of the objects system are the following:

Code: Select all

            Box b1 = new Box(new Vector3(0, 2, -10), 1, 0.3f, 0.3f);
            AttachWithSkin(game, b1, CubeBlue);
            space.Add(b1);

            Box b2 = new Box(b1.Position + Vector3.UnitY * -b1.Height, 1, 0.3f, 0.3f,1);
            AttachWithSkin(game, b2, CubeModel);
            space.Add(b2);

            Vector3 j_position = b1.Position + Vector3.UnitX * b1.Width / 2 + Vector3.UnitY * -b1.Height / 2;
            space.Add(new RevoluteJoint(b1, b2, j_position, Vector3.UnitZ));

Re: how to get internal forces in constrains ?

Posted: Sun Mar 06, 2016 2:37 pm
by yanbo2u
I think I got the answer.

Is it "myRevoluteJoint.BallSocketJoint.TotalImpulse / /space.TimeStepSettings.TimeStepDuration" ?

Re: how to get internal forces in constrains ?

Posted: Sun Mar 06, 2016 8:07 pm
by Norbo
Yup. Note that the TotalImpulse properties on constraints are in constraint space. That's not much of a concern if all you're looking for is magnitude, but to get the world space force applied to each entity you'd need to multiply the impulse by the jacobians (GetLinearJacobianA/B and GetAngularJacobianA/B).

For an example of how you use the jacobians to get to world space impulses, check out something like the PointOnLineJoint.ExclusiveUpdate function. The constraint space impulse (here accumulatedImpulse) is transformed by the linear jacobians worldRestrictedAxis1 and worldRestrictedAxis2 to get the linear world impulse, and then transformed by angularA1/A2/B1/B2 to get angular world impulse.