Example #1
0
 def test_to_cartesian_single_point(self):
     rtp = [0, 0, 0]
     np.testing.assert_allclose(spherical_to_cartesian(rtp), [0, 0, 0], atol=np.finfo(float).eps)
     rtp = [0, 1, 0]
     np.testing.assert_allclose(spherical_to_cartesian(rtp), [0, 0, 0], atol=np.finfo(float).eps)
     rtp = [1, 0, 0]
     np.testing.assert_allclose(spherical_to_cartesian(rtp), [0, 0, 1], atol=np.finfo(float).eps)
     rtp = [1, np.pi/2, 0]
     np.testing.assert_allclose(spherical_to_cartesian(rtp), [1, 0, 0], atol=np.finfo(float).eps)
     rtp = [1, np.pi, 0]
     np.testing.assert_allclose(spherical_to_cartesian(rtp), [0, 0, -1], atol=np.finfo(float).eps)
Example #2
0
 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)