def test_create_from_axis_rotation_non_normalized(self): result = quaternion.create_from_axis_rotation([1., 1., 1.], np.pi) np.testing.assert_almost_equal( result, [5.77350000e-01, 5.77350000e-01, 5.77350000e-01, 6.12323400e-17], decimal=3) self.assertTrue(result.dtype == np.float)
def test_create_from_axis_rotation(self): # wolfram alpha can be awesome sometimes result = quaternion.create_from_axis_rotation( [0.57735, 0.57735, 0.57735], np.pi) np.testing.assert_almost_equal( result, [5.77350000e-01, 5.77350000e-01, 5.77350000e-01, 6.12323400e-17], decimal=3) self.assertTrue(result.dtype == np.float)
def compute_geodesic(dst, index, point_a, point_b, num_segments): """Given two points on a unit sphere, returns a sequence of surface points that lie between them along a geodesic curve.""" angle_between_endpoints = acos(dot(point_a, point_b)) rotation_axis = cross(point_a, point_b) dst[index] = point_a index = index + 1 if num_segments == 0: return index dtheta = angle_between_endpoints / num_segments for point_index in range(1, num_segments): theta = point_index * dtheta q = quaternion.create_from_axis_rotation(rotation_axis, theta) dst[index] = quaternion.apply_to_vector(q, point_a) index = index + 1 dst[index] = point_b return index + 1
def test_create_from_axis_rotation_non_normalized(self): result = quaternion.create_from_axis_rotation([1., 1., 1.], np.pi) np.testing.assert_almost_equal(result, [5.77350000e-01, 5.77350000e-01, 5.77350000e-01, 6.12323400e-17], decimal=3) self.assertTrue(result.dtype == np.float)
def test_create_from_axis_rotation(self): # wolfram alpha can be awesome sometimes result = quaternion.create_from_axis_rotation([0.57735, 0.57735, 0.57735], np.pi) np.testing.assert_almost_equal(result, [5.77350000e-01, 5.77350000e-01, 5.77350000e-01, 6.12323400e-17], decimal=3) self.assertTrue(result.dtype == np.float)