19[[nodiscard]]
inline glm::mat3
boxInvInertia(
float mass, glm::vec3 halfExtents)
noexcept
22 return glm::mat3(0.0f);
26 const float w2 = (halfExtents.x * 2.0f) * (halfExtents.x * 2.0f);
27 const float h2 = (halfExtents.y * 2.0f) * (halfExtents.y * 2.0f);
28 const float d2 = (halfExtents.z * 2.0f) * (halfExtents.z * 2.0f);
29 const float k = 12.0f / mass;
31 glm::vec3{k / (h2 + d2), 0.0f, 0.0f},
32 glm::vec3{0.0f, k / (w2 + d2), 0.0f},
33 glm::vec3{0.0f, 0.0f, k / (w2 + h2)},
42 return glm::mat3(0.0f);
43 const float i = (2.0f / 5.0f) * mass * radius * radius;
45 glm::vec3{1.0f / i, 0.0f, 0.0f},
46 glm::vec3{0.0f, 1.0f / i, 0.0f},
47 glm::vec3{0.0f, 0.0f, 1.0f / i},
54[[nodiscard]]
inline glm::mat3
capsuleInvInertia(
float mass,
float radius,
float halfHeight)
noexcept
57 return glm::mat3(0.0f);
61 const float r = radius;
62 const float h = halfHeight;
63 const float vCyl = 2.0f * h * (r * r);
64 const float vSph = (4.0f / 3.0f) * (r * r * r);
65 const float vTot = vCyl + vSph;
67 return glm::mat3(0.0f);
69 const float mCyl = mass * (vCyl / vTot);
70 const float mSph = mass * (vSph / vTot);
75 const float iYcyl = 0.5f * mCyl * r * r;
76 const float iXcyl = (1.0f / 12.0f) * mCyl * (3.0f * r * r + (2.0f * h) * (2.0f * h));
81 const float iYsph = (2.0f / 5.0f) * mSph * r * r;
82 const float iXsph = iYsph + mSph * h * h;
84 const float iY = iYcyl + iYsph;
85 const float iX = iXcyl + iXsph;
88 glm::vec3{1.0f / iX, 0.0f, 0.0f},
89 glm::vec3{0.0f, 1.0f / iY, 0.0f},
90 glm::vec3{0.0f, 0.0f, 1.0f / iX},