Package geometry :: Module rotations_embedding
[hide private]
[frames] | no frames]

Source Code for Module geometry.rotations_embedding

 1  from . import (map_hat_2d, contract, np, angle_from_rot2d, 
 2      rotation_from_axis_angle, hat_map, rot2d) 
3 4 5 @contract(returns='SO3', a='SO2') 6 -def SO3_from_SO2(a):
7 theta = angle_from_rot2d(a) 8 return rotation_from_axis_angle(np.array([0, 0, 1]), theta)
9
10 11 @contract(returns='SO2', b='SO3') 12 -def SO2_project_from_SO3(b):
13 direction = np.array([1, 0, 0]) 14 vector = np.dot(b, direction) 15 n = np.linalg.norm(vector) 16 atol = 1e-8 # XXX: make common 17 if n < atol: 18 return rot2d(0) 19 else: 20 theta = np.arctan2(vector[1], vector[0]) 21 return rot2d(theta)
22
23 24 @contract(returns='so3', a='so2') 25 -def so3_from_so2(a):
26 omega = map_hat_2d(a) 27 return hat_map(np.array([0, 0, omega]))
28
29 30 @contract(returns='so2', b='so3') 31 -def so2_project_from_so3(b):
32 return b[0:2, 0:2]
33