Rotation from Axis and Angle
Implement axis_angle_to_matrix(axis, angle).
Examples
z-axis, 90 degrees
- Input
- axis_angle_to_matrix([0, 0, 1], 1.5707963267948966)
- Output
- [[0, -1, 0], [1, 0, 0], [0, 0, 1]]
x-axis, 180 degrees flips y and z
- Input
- axis_angle_to_matrix([1, 0, 0], 3.141592653589793)
- Output
- [[1, 0, 0], [0, -1, 0], [0, 0, -1]]
Angle 0 is the identity for any axis
- Input
- axis_angle_to_matrix([1, 2, 3], 0)
- Output
- [[1, 0, 0], [0, 1, 0], [0, 0, 1]]
Hints
Hint 1
gives the magnitude in one call; pick the axis deliberately.
Hint 2
Do not forget to normalise the axis. That step is easy to skip.
Requirements
: (3,) rotation axis, not necessarily unit length
angle: rotation in radians, counterclockwise about the axisReturn (3, 3) rotation matrix
Constraints
Allowed library: NumPy only
Time limit: 200 ms, Memory: 64 MB
Try similar problems(4)
Industrial Robotics: Kinematics and Control · ~16 min
Industrial Robotics: Kinematics and Control · ~14 min
Industrial Robotics: Kinematics and Control · ~16 min
Industrial Robotics: Kinematics and Control · ~18 min
Where this shows up
6 employers weight this skill
4 autonomy companies, 2 defense companies. Top match scores 92.
import numpy as np
def axis_angle_to_matrix(axis, angle):
"""
Rodrigues rotation formula.
Args:
axis: (3,) rotation axis, not necessarily unit length
angle: rotation in radians, counterclockwise about the axis
Returns:
(3, 3) rotation matrix
"""
# YOUR CODE HERE
pass