Example #1
0
def random_directions_bounded_test_1():
    # TODO: write actual test
    r = np.pi / 2
    N = 180
    random_directions_bounded(ndim=2, radius=r, num_points=N, center=None)
    random_directions_bounded(ndim=3, radius=r, num_points=N, center=None)
    random_directions_bounded(ndim=2, radius=r, num_points=N, center=random_direction(2))
    random_directions_bounded(ndim=3, radius=r, num_points=N, center=random_direction(3))
Example #2
0
def random_directions_bounded_test_1():
    # TODO: write actual test
    r = np.pi / 2
    N = 180
    random_directions_bounded(ndim=2, radius=r, num_points=N, center=None)
    random_directions_bounded(ndim=3, radius=r, num_points=N, center=None)
    random_directions_bounded(ndim=2, radius=r, num_points=N,
                              center=random_direction(2))
    random_directions_bounded(ndim=3, radius=r, num_points=N,
                              center=random_direction(3))
Example #3
0
 def test_distances_rotations(self):
     for axis, angle in axis_angle_sequence():
         s = random_direction()
         R = rotation_from_axis_angle(axis, angle)
         s2 = np.dot(R, s)
         dist = geodesic_distance_on_sphere(s, s2)
         # Note: this is == only if axis is orthogonal to s
         assert dist <= angle
 def test_distances_rotations(self):
     for axis, angle in axis_angle_sequence():
         s = random_direction()
         R = rotation_from_axis_angle(axis, angle)
         s2 = np.dot(R, s)
         dist = geodesic_distance_on_sphere(s, s2)
         # Note: this is == only if axis is orthogonal to s
         assert dist <= angle
Example #5
0
def directions_sequence():
    ''' Sequence of directions in S^2. '''
    yield np.array([1.0, 0.0, 0.0])
    yield np.array([0.0, 1.0, 0.0])
    yield np.array([0.0, 0.0, 1.0])
    yield np.array([-1.0, 0.0, 0.0])
    yield np.array([0.0, -1.0, 0.0])
    yield np.array([0.0, 0.0, -1.0])
    # TODO: add special values
    for i in range(N):  # @UnusedVariable
        yield random_direction(3)
Example #6
0
def directions_sequence():
    ''' Sequence of directions in S^2. '''
    yield np.array([1.0, 0.0, 0.0])
    yield np.array([0.0, 1.0, 0.0])
    yield np.array([0.0, 0.0, 1.0])
    yield np.array([-1.0, 0.0, 0.0])
    yield np.array([0.0, -1.0, 0.0])
    yield np.array([0.0, 0.0, -1.0])
    # TODO: add special values
    for i in range(N):  # @UnusedVariable
        yield random_direction(3)
 def test_distances(self):
     for i in range(N):  #@UnusedVariable
         s = random_direction()
         dist = geodesic_distance_on_sphere
         assert_allclose(dist(s, s), 0)
         assert_allclose(dist(s, -s), np.pi)
 def test_random_direction(self):
     for i in range(N):  #@UnusedVariable
         random_direction()
Example #9
0
def random_axis_angle():
    max_angle = np.pi * 0.9
    angle = np.random.uniform() * max_angle
    axis = random_direction()
    return axis, angle
 def random_directions_bounded_density_test():
     radius = [np.pi, np.pi * 3 / 4, np.pi / 2, np.pi / 4, np.pi / 6]
     N = 100
     for r in radius:
         center = random_direction()
         yield random_directions_bounded_density_3d, center, r, N
Example #11
0
 def test_distances(self):
     for i in range(N):  # @UnusedVariable
         s = random_direction()
         dist = geodesic_distance_on_sphere
         assert_allclose(dist(s, s), 0)
         assert_allclose(dist(s, -s), np.pi)
Example #12
0
 def test_random_direction(self):
     for i in range(N):  # @UnusedVariable
         random_direction()
Example #13
0
 def random_directions_bounded_density_test():
     radius = [np.pi, np.pi * 3 / 4, np.pi / 2, np.pi / 4, np.pi / 6]
     N = 100
     for r in radius:
         center = random_direction()
         yield random_directions_bounded_density_3d, center, r, N
Example #14
0
def random_axis_angle():
    max_angle = np.pi * 0.9
    angle = np.random.uniform() * max_angle
    axis = random_direction()
    return axis, angle