Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. def rotation_matrix(axis, theta):
  2. """
  3. Return the rotation matrix associated with counterclockwise rotation about
  4. the given axis by theta radians.
  5. """
  6. axis = np.asarray(axis)
  7. axis = axis / np.sqrt(np.dot(axis, axis))
  8. a = np.cos(theta / 2.0)
  9. b, c, d = -axis * np.sin(theta / 2.0)
  10. aa, bb, cc, dd = a * a, b * b, c * c, d * d
  11. bc, ad, ac, ab, bd, cd = b * c, a * d, a * c, a * b, b * d, c * d
  12. return np.array([[aa + bb - cc - dd, 2 * (bc + ad), 2 * (bd - ac)],
  13. [2 * (bc - ad), aa + cc - bb - dd, 2 * (cd + ab)],
  14. [2 * (bd + ac), 2 * (cd - ab), aa + dd - bb - cc]])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement