def test_to_cylindrical_single_point(self): xyz = [1, 0, 0] np.testing.assert_allclose(cartesian_to_cylindrical(xyz), [1, 0, 0], atol=np.finfo(float).eps) xyz = [0, 1, 0] np.testing.assert_allclose(cartesian_to_cylindrical(xyz), [1, np.pi / 2, 0], atol=np.finfo(float).eps) xyz = [1, 0, 1] np.testing.assert_allclose(cartesian_to_cylindrical(xyz), [1, 0, 1], atol=np.finfo(float).eps) xyz = [0, 0, 0] np.testing.assert_allclose(cartesian_to_cylindrical(xyz), [0, 0, 0], atol=np.finfo(float).eps) xyz = [0, 0, 1] np.testing.assert_allclose(cartesian_to_cylindrical(xyz), [0, 0, 1], atol=np.finfo(float).eps)
def test_to_cylindrical_and_back_many_points(self): points_num = 100 xyz = ((np.random.random(points_num * 3) - 0.5) * 200).reshape((points_num, 3)) rpz = cartesian_to_cylindrical(xyz) np.testing.assert_allclose(cylindrical_to_cartesian(rpz), xyz) rtp = cylindrical_to_spherical(rpz) np.testing.assert_allclose(cartesian_to_spherical(xyz), rtp) np.testing.assert_allclose(spherical_to_cylindrical(rtp), rpz) np.testing.assert_allclose(spherical_to_cartesian(rtp), xyz)