skrobot.coordinates.math.matrix2ypr
- skrobot.coordinates.math.matrix2ypr(matrix)[source]
Convert rotation matrix to yaw-pitch-roll angles.
This function extracts yaw, pitch, roll angles from a rotation matrix.
- Parameters:
matrix (numpy.ndarray) – 3x3 rotation matrix
- Returns:
angles – Array of [yaw, pitch, roll] angles in radians - yaw: rotation around Z-axis - pitch: rotation around Y-axis - roll: rotation around X-axis
- Return type:
Examples
>>> import numpy as np >>> from skrobot.coordinates.math import ypr2matrix, matrix2ypr >>> yaw, pitch, roll = np.pi/6, np.pi/4, np.pi/3 >>> rot = ypr2matrix(yaw, pitch, roll) >>> angles = matrix2ypr(rot) >>> np.allclose(angles, [yaw, pitch, roll]) True >>> print("Yaw: {:.3f}, Pitch: {:.3f}, Roll: {:.3f}".format(angles[0], angles[1], angles[2])) Yaw: 0.524, Pitch: 0.785, Roll: 1.047