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

Method getReactionTorque

src/constraint/HingeJoint.cpp:285–301  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

283 * @return The current torque (in Newtons * meters) applied on body 2
284 */
285Vector3 HingeJoint::getReactionTorque(decimal timeStep) const {
286
287 assert(timeStep > MACHINE_EPSILON);
288
289 const uint32 jointIndex = mWorld.mHingeJointsComponents.getEntityIndex(mEntity);
290
291 const Vector2& impulseRotation = mWorld.mHingeJointsComponents.mImpulseRotation[jointIndex];
292 const Vector3& b2CrossA1 = mWorld.mHingeJointsComponents.mB2CrossA1[jointIndex];
293 const Vector3& c2CrossA1 = mWorld.mHingeJointsComponents.mC2CrossA1[jointIndex];
294
295 Vector3 impulseJoint = b2CrossA1 * impulseRotation.x + c2CrossA1 * impulseRotation.y;
296 Vector3 impulseLowerLimit = mWorld.mHingeJointsComponents.mImpulseLowerLimit[jointIndex] * mWorld.mHingeJointsComponents.mA1[jointIndex];
297 Vector3 impulseUpperLimit = -mWorld.mHingeJointsComponents.mImpulseUpperLimit[jointIndex] * mWorld.mHingeJointsComponents.mA1[jointIndex];
298 Vector3 impulseMotor = mWorld.mHingeJointsComponents.mImpulseMotor[jointIndex] * mWorld.mHingeJointsComponents.mA1[jointIndex];
299
300 return (impulseJoint + impulseLowerLimit + impulseUpperLimit + impulseMotor) / timeStep;
301}
302
303// Return the number of bytes used by the joint
304 size_t HingeJoint::getSizeInBytes() const {

Callers

nothing calls this directly

Calls 1

getEntityIndexMethod · 0.80

Tested by

no test coverage detected