skrobot.coordinates.math.quaternion_from_axis_angle

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

Return the quaternion from axis angle

This function returns quaternion associated with counterclockwise rotation about the given axis by theta radians.

Parameters:
  • theta (float) – radian

  • axis (list or numpy.ndarray) – length is 3. Automatically normalize in this function

Returns:

quaternion – [w, x, y, z] order

Return type:

numpy.ndarray

Examples

>>> import numpy
>>> from skrobot.coordinates.math import quaternion_from_axis_angle
>>> quaternion_from_axis_angle(0.1, [1, 0, 0])
array([0.99875026, 0.04997917, 0.        , 0.        ])
>>> quaternion_from_axis_angle(numpy.pi, [1, 0, 0])
array([6.123234e-17, 1.000000e+00, 0.000000e+00, 0.000000e+00])
>>> quaternion_from_axis_angle(0, [1, 0, 0])
array([1., 0., 0., 0.])
>>> quaternion_from_axis_angle(numpy.pi, [1, 0, 1])
array([6.12323400e-17, 7.07106781e-01, 0.00000000e+00, 7.07106781e-01])