MCPcopy Create free account
hub / github.com/DanielChappuis/reactphysics3d / getReactionForce

Method getReactionForce

src/constraint/SliderJoint.cpp:301–317  ·  view source on GitHub ↗

Return the force (in Newtons) on body 2 required to satisfy the joint constraint in world-space * @return The current force (in Newtons) applied on body 2 */

Source from the content-addressed store, hash-verified

299 * @return The current force (in Newtons) applied on body 2
300 */
301Vector3 SliderJoint::getReactionForce(decimal timeStep) const {
302 assert(timeStep > MACHINE_EPSILON);
303
304 const uint32 jointIndex = mWorld.mSliderJointsComponents.getEntityIndex(mEntity);
305
306 const Vector2 translationImpulse = mWorld.mSliderJointsComponents.mImpulseTranslation[jointIndex];
307 const Vector3& n1 = mWorld.mSliderJointsComponents.mN1[jointIndex];
308 const Vector3& n2 = mWorld.mSliderJointsComponents.mN2[jointIndex];
309 const Vector3 impulseJoint = n1 * translationImpulse.x + n2 * translationImpulse.y;
310
311 const Vector3& sliderAxisWorld = mWorld.mSliderJointsComponents.mSliderAxisWorld[jointIndex];
312 const Vector3 impulseLowerLimit = mWorld.mSliderJointsComponents.mImpulseLowerLimit[jointIndex] * sliderAxisWorld;
313 const Vector3 impulseUpperLimit = -mWorld.mSliderJointsComponents.mImpulseUpperLimit[jointIndex] * sliderAxisWorld;
314 Vector3 impulseMotor = -mWorld.mSliderJointsComponents.mImpulseMotor[jointIndex] * sliderAxisWorld;
315
316 return (impulseJoint + impulseLowerLimit + impulseUpperLimit + impulseMotor) / timeStep;
317}
318
319// Return the torque (in Newtons * meters) on body 2 required to satisfy the joint constraint in world-space
320/**

Callers

nothing calls this directly

Calls 1

getEntityIndexMethod · 0.80

Tested by

no test coverage detected