how to get internal forces in constrains ?

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
yanbo2u
Posts: 21
Joined: Sun Oct 04, 2015 4:41 pm

how to get internal forces in constrains ?

Post 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));
Attachments
Capture.PNG
Capture.PNG (22.19 KiB) Viewed 4441 times
yanbo2u
Posts: 21
Joined: Sun Oct 04, 2015 4:41 pm

Re: how to get internal forces in constrains ?

Post by yanbo2u »

I think I got the answer.

Is it "myRevoluteJoint.BallSocketJoint.TotalImpulse / /space.TimeStepSettings.TimeStepDuration" ?
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: how to get internal forces in constrains ?

Post 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.
Post Reply