MCPcopy Create free account
hub / github.com/bulletphysics/bullet3 / randomInertiaMatrix

Function randomInertiaMatrix

Extras/InverseDynamics/IDRandomUtil.cpp:41–59  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39}
40
41mat33 randomInertiaMatrix()
42{
43 // generate random valid inertia matrix by first getting valid components
44 // along major axes and then rotating by random amount
45 vec3 principal = randomInertiaPrincipal();
46 mat33 rot(transformX(randomFloat(-BT_ID_PI, BT_ID_PI)) * transformY(randomFloat(-BT_ID_PI, BT_ID_PI)) *
47 transformZ(randomFloat(-BT_ID_PI, BT_ID_PI)));
48 mat33 inertia;
49 inertia(0, 0) = principal(0);
50 inertia(0, 1) = 0;
51 inertia(0, 2) = 0;
52 inertia(1, 0) = 0;
53 inertia(1, 1) = principal(1);
54 inertia(1, 2) = 0;
55 inertia(2, 0) = 0;
56 inertia(2, 1) = 0;
57 inertia(2, 2) = principal(2);
58 return rot * inertia * rot.transpose();
59}
60
61vec3 randomAxis()
62{

Callers

nothing calls this directly

Calls 6

randomInertiaPrincipalFunction · 0.85
transformXFunction · 0.85
randomFloatFunction · 0.85
transformYFunction · 0.85
transformZFunction · 0.85
transposeMethod · 0.45

Tested by

no test coverage detected