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

Method getConeHalfAngle

src/constraint/BallAndSocketJoint.cpp:111–127  ·  view source on GitHub ↗

Return the current cone angle in radians (in [0, pi]) * @return The current half-angle (in radians) of the joint with respect to the cone-limit axis */

Source from the content-addressed store, hash-verified

109 * @return The current half-angle (in radians) of the joint with respect to the cone-limit axis
110 */
111decimal BallAndSocketJoint::getConeHalfAngle() const {
112
113 // Get the bodies entities
114 const Entity body1Entity = mWorld.mJointsComponents.getBody1Entity(mEntity);
115 const Entity body2Entity = mWorld.mJointsComponents.getBody2Entity(mEntity);
116
117 const Transform& transformBody1 = mWorld.mTransformComponents.getTransform(body1Entity);
118 const Transform& transformBody2 = mWorld.mTransformComponents.getTransform(body2Entity);
119
120 // Convert local-space cone axis of bodies to world-space
121 const Vector3 r1Local = mWorld.mBallAndSocketJointsComponents.getLocalAnchorPointBody1(mEntity) - mWorld.mRigidBodyComponents.getCenterOfMassLocal(body1Entity);
122 const Vector3 r2Local = mWorld.mBallAndSocketJointsComponents.getLocalAnchorPointBody2(mEntity) - mWorld.mRigidBodyComponents.getCenterOfMassLocal(body2Entity);
123 const Vector3 r1World = transformBody1.getOrientation() * r1Local;
124 const Vector3 r2World = transformBody2.getOrientation() * r2Local;
125
126 return SolveBallAndSocketJointSystem::computeCurrentConeHalfAngle(r1World.getUnit(), -r2World.getUnit());
127}
128
129// Reset the limits
130void BallAndSocketJoint::resetLimits() {

Callers

nothing calls this directly

Calls 3

getBody1EntityMethod · 0.80
getBody2EntityMethod · 0.80
getUnitMethod · 0.45

Tested by

no test coverage detected