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

Method getLocalInertiaTensor

src/collision/shapes/CapsuleShape.cpp:51–67  ·  view source on GitHub ↗

Return the local inertia tensor of the capsule * @param mass Mass to use to compute the inertia tensor of the collision shape */

Source from the content-addressed store, hash-verified

49 * @param mass Mass to use to compute the inertia tensor of the collision shape
50 */
51Vector3 CapsuleShape::getLocalInertiaTensor(decimal mass) const {
52
53 // The inertia tensor formula for a capsule can be found in : Game Engine Gems, Volume 1
54
55 const decimal height = mHalfHeight + mHalfHeight;
56 const decimal radiusSquare = mMargin * mMargin;
57 const decimal heightSquare = height * height;
58 const decimal radiusSquareDouble = radiusSquare + radiusSquare;
59 const decimal factor1 = decimal(2.0) * mMargin / (decimal(4.0) * mMargin + decimal(3.0) * height);
60 const decimal factor2 = decimal(3.0) * height / (decimal(4.0) * mMargin + decimal(3.0) * height);
61 const decimal sum1 = decimal(0.4) * radiusSquareDouble;
62 const decimal sum2 = decimal(0.75) * height * mMargin + decimal(0.5) * heightSquare;
63 const decimal sum3 = decimal(0.25) * radiusSquare + decimal(1.0 / 12.0) * heightSquare;
64 const decimal IxxAndzz = factor1 * mass * (sum1 + sum2) + factor2 * mass * sum3;
65 const decimal Iyy = factor1 * mass * sum1 + factor2 * mass * decimal(0.25) * radiusSquareDouble;
66 return Vector3(IxxAndzz, Iyy, IxxAndzz);
67}
68
69// Return true if a point is inside the collision shape
70bool CapsuleShape::testPointInside(const Vector3& localPoint, Collider* /*collider*/) const {

Callers

nothing calls this directly

Calls 1

Vector3Class · 0.50

Tested by

no test coverage detected