Tests the calculation of the matrix of inertia for a solid
(self)
| 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): |
nothing calls this directly
no test coverage detected