Ejemplo n.º 1
0
def test_sphere_to_cartesian():
    """Test helper transform function from sphere to cartesian"""
    phi, theta, r = (np.pi, np.pi, 1)
    # expected value is (1, 0, 0)
    z = r * np.sin(phi)
    rcos_phi = r * np.cos(phi)
    x = rcos_phi * np.cos(theta)
    y = rcos_phi * np.sin(theta)
    coord = _sphere_to_cartesian(phi, theta, r)
    # np.pi is an approx since pi is irrational
    assert_almost_equal(coord, (x, y, z), 10)
    assert_almost_equal(coord, (1, 0, 0), 10)
Ejemplo n.º 2
0
def test_sphere_to_cartesian():
    """Test helper transform function from sphere to cartesian"""
    phi, theta, r = (np.pi, np.pi, 1)
    # expected value is (1, 0, 0)
    z = r * np.sin(phi)
    rcos_phi = r * np.cos(phi)
    x = rcos_phi * np.cos(theta)
    y = rcos_phi * np.sin(theta)
    coord = _sphere_to_cartesian(phi, theta, r)
    # np.pi is an approx since pi is irrational
    assert_almost_equal(coord, (x, y, z), 10)
    assert_almost_equal(coord, (1, 0, 0), 10)