def test_center(): """Test getting and setting the center.""" ellipsoid = Ellipsoid(1, 2, 3) assert all(ellipsoid.center == (0, 0, 0)) center = (1, 1, 1) ellipsoid.center = center assert all(ellipsoid.center == center)
def test_inertia_tensor(a, b, c, center): # First just test a sphere. ellipsoid = Ellipsoid(a, a, a) assert np.all(ellipsoid.inertia_tensor >= 0) volume = ellipsoid.volume expected = [2 / 5 * volume * a**2] * 3 np.testing.assert_allclose(np.diag(ellipsoid.inertia_tensor), expected) ellipsoid.center = center expected = translate_inertia_tensor(center, np.diag(expected), volume) np.testing.assert_allclose(ellipsoid.inertia_tensor, expected)