Aligns vector a to vector b with axis angle rotation.
(a=np.array([0, 0, 1]), b=np.array([1, 0, 0]))
| 22 | |
| 23 | |
| 24 | def align_vector_to_another(a=np.array([0, 0, 1]), b=np.array([1, 0, 0])): |
| 25 | """Aligns vector a to vector b with axis angle rotation.""" |
| 26 | if np.array_equal(a, b): |
| 27 | return None, None |
| 28 | axis_ = np.cross(a, b) |
| 29 | axis_ = axis_ / np.linalg.norm(axis_) |
| 30 | angle = np.arccos(np.dot(a, b)) |
| 31 | |
| 32 | return axis_, angle |
| 33 | |
| 34 | |
| 35 | def normalized(a, axis=-1, order=2): |