skrobot.coordinates.math.rotation_matrix

skrobot.coordinates.math.rotation_matrix(theta, axis)[source]

Return the rotation matrix.

Return the rotation matrix associated with counterclockwise rotation about the given axis by theta radians.

Parameters:
  • theta (float) – radian

  • axis (str or list or numpy.ndarray) – rotation axis such that ‘x’, ‘y’, ‘z’ [0, 0, 1], [0, 1, 0], [1, 0, 0]

Returns:

rot – rotation matrix about the given axis by theta radians.

Return type:

numpy.ndarray

Examples

>>> import numpy as np
>>> from skrobot.coordinates.math import rotation_matrix
>>> rotation_matrix(np.pi / 2.0, [1, 0, 0])
array([[ 1.00000000e+00,  0.00000000e+00,  0.00000000e+00],
       [ 0.00000000e+00,  2.22044605e-16, -1.00000000e+00],
       [ 0.00000000e+00,  1.00000000e+00,  2.22044605e-16]])
>>> rotation_matrix(np.pi / 2.0, 'y')
array([[ 2.22044605e-16,  0.00000000e+00,  1.00000000e+00],
       [ 0.00000000e+00,  1.00000000e+00,  0.00000000e+00],
       [-1.00000000e+00,  0.00000000e+00,  2.22044605e-16]])