MCPcopy Index your code
hub / github.com/CadQuery/cadquery / testMatrixOfInertia

Method testMatrixOfInertia

tests/test_cad_objects.py:241–255  ·  view source on GitHub ↗

Tests the calculation of the matrix of inertia for a solid

(self)

Source from the content-addressed store, hash-verified

239 self.assertTupleAlmostEquals((0.0, 0.0, 1.0), mplane.normalAt().toTuple(), 3)
240
241 def testMatrixOfInertia(self):
242 """
243 Tests the calculation of the matrix of inertia for a solid
244 """
245 radius = 1.0
246 height = 2.0
247 cylinder = Solid.makeCylinder(radius=radius, height=height)
248 moi = Shape.matrixOfInertia(cylinder)
249 two_pi = 2 * math.pi
250 true_moi = (
251 two_pi * (radius ** 2 / 4 + height ** 2 / 12),
252 two_pi * (radius ** 2 / 4 + height ** 2 / 12),
253 two_pi * radius ** 2 / 2,
254 )
255 self.assertTupleAlmostEquals((moi[0][0], moi[1][1], moi[2][2]), true_moi, 3)
256
257 def testVertexMatrixOfInertiaNotImplemented(self):
258 with self.assertRaises(NotImplementedError):

Callers

nothing calls this directly

Calls 3

makeCylinderMethod · 0.80
matrixOfInertiaMethod · 0.80

Tested by

no test coverage detected