Last active
          December 13, 2022 13:21 
        
      - 
      
- 
        Save marmakoide/bb11884220e259573f52ba0d88d4a0d4 to your computer and use it in GitHub Desktop. 
    Computes the rotation matrix equivalent to an axis & angle rotation
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import numpy | |
| def axis_angle_to_rotation_matrix(U, theta): | |
| cos_theta, sin_theta = numpy.cos(theta, dtype = U.dtype), numpy.sin(theta, dtype = U.dtype) | |
| U_x = numpy.array([[0, -U[2], U[1]], [U[2], 0, -U[0]], [-U[1], U[0], 0]], dtype = U.dtype) | |
| return cos_theta * numpy.identity(3, dtype = U.dtype) + sin_theta * U_x + (1 - cos_theta) * numpy.outer(U, U) | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment