Package maths_fns :: Module rotation_matrix
[hide private]
[frames] | no frames]

Module rotation_matrix

source code

Functions [hide private]
float, float, float
axis_angle_to_euler_xyx(axis, angle)
Convert the axis-angle notation to xyx Euler angles.
source code
float, float, float
axis_angle_to_euler_xyz(axis, angle)
Convert the axis-angle notation to xyz Euler angles.
source code
float, float, float
axis_angle_to_euler_xzx(axis, angle)
Convert the axis-angle notation to xzx Euler angles.
source code
float, float, float
axis_angle_to_euler_xzy(axis, angle)
Convert the axis-angle notation to xzy Euler angles.
source code
float, float, float
axis_angle_to_euler_yxy(axis, angle)
Convert the axis-angle notation to yxy Euler angles.
source code
float, float, float
axis_angle_to_euler_yxz(axis, angle)
Convert the axis-angle notation to yxz Euler angles.
source code
float, float, float
axis_angle_to_euler_yzx(axis, angle)
Convert the axis-angle notation to yzx Euler angles.
source code
float, float, float
axis_angle_to_euler_yzy(axis, angle)
Convert the axis-angle notation to yzy Euler angles.
source code
float, float, float
axis_angle_to_euler_zxy(axis, angle)
Convert the axis-angle notation to zxy Euler angles.
source code
float, float, float
axis_angle_to_euler_zxz(axis, angle)
Convert the axis-angle notation to zxz Euler angles.
source code
float, float, float
axis_angle_to_euler_zyx(axis, angle)
Convert the axis-angle notation to zyx Euler angles.
source code
float, float, float
axis_angle_to_euler_zyz(axis, angle)
Convert the axis-angle notation to zyz Euler angles.
source code
 
axis_angle_to_R(axis, angle, R)
Generate the rotation matrix from the axis-angle notation.
source code
 
axis_angle_to_quaternion(axis, angle, quat, norm_flag=True)
Generate the quaternion from the axis-angle notation.
source code
float
copysign(x, y)
Return x with the sign of y.
source code
numpy 3D rank-1 array, float
euler_to_axis_angle_xyx(alpha, beta, gamma)
Convert the xyx Euler angles to axis-angle notation.
source code
numpy 3D rank-1 array, float
euler_to_axis_angle_xyz(alpha, beta, gamma)
Convert the xyz Euler angles to axis-angle notation.
source code
numpy 3D rank-1 array, float
euler_to_axis_angle_xzx(alpha, beta, gamma)
Convert the xzx Euler angles to axis-angle notation.
source code
numpy 3D rank-1 array, float
euler_to_axis_angle_xzy(alpha, beta, gamma)
Convert the xzy Euler angles to axis-angle notation.
source code
numpy 3D rank-1 array, float
euler_to_axis_angle_yxy(alpha, beta, gamma)
Convert the yxy Euler angles to axis-angle notation.
source code
numpy 3D rank-1 array, float
euler_to_axis_angle_yxz(alpha, beta, gamma)
Convert the yxz Euler angles to axis-angle notation.
source code
numpy 3D rank-1 array, float
euler_to_axis_angle_yzx(alpha, beta, gamma)
Convert the yzx Euler angles to axis-angle notation.
source code
numpy 3D rank-1 array, float
euler_to_axis_angle_yzy(alpha, beta, gamma)
Convert the yzy Euler angles to axis-angle notation.
source code
numpy 3D rank-1 array, float
euler_to_axis_angle_zxy(alpha, beta, gamma)
Convert the zxy Euler angles to axis-angle notation.
source code
numpy 3D rank-1 array, float
euler_to_axis_angle_zxz(alpha, beta, gamma)
Convert the zxz Euler angles to axis-angle notation.
source code
numpy 3D rank-1 array, float
euler_to_axis_angle_zyx(alpha, beta, gamma)
Convert the zyx Euler angles to axis-angle notation.
source code
numpy 3D rank-1 array, float
euler_to_axis_angle_zyz(alpha, beta, gamma)
Convert the zyz Euler angles to axis-angle notation.
source code
 
euler_to_R_xyx(alpha, beta, gamma, R)
Generate the x-y-x Euler angle convention rotation matrix.
source code
 
euler_to_R_xyz(alpha, beta, gamma, R)
Generate the x-y-z Euler angle convention rotation matrix.
source code
 
euler_to_R_xzx(alpha, beta, gamma, R)
Generate the x-z-x Euler angle convention rotation matrix.
source code
 
euler_to_R_xzy(alpha, beta, gamma, R)
Generate the x-z-y Euler angle convention rotation matrix.
source code
 
euler_to_R_yxy(alpha, beta, gamma, R)
Generate the y-x-y Euler angle convention rotation matrix.
source code
 
euler_to_R_yxz(alpha, beta, gamma, R)
Generate the y-x-z Euler angle convention rotation matrix.
source code
 
euler_to_R_yzx(alpha, beta, gamma, R)
Generate the y-z-x Euler angle convention rotation matrix.
source code
 
euler_to_R_yzy(alpha, beta, gamma, R)
Generate the y-z-y Euler angle convention rotation matrix.
source code
 
euler_to_R_zxy(alpha, beta, gamma, R)
Generate the z-x-y Euler angle convention rotation matrix.
source code
 
euler_to_R_zxz(alpha, beta, gamma, R)
Generate the z-x-z Euler angle convention rotation matrix.
source code
 
euler_to_R_zyx(alpha, beta, gamma, R)
Generate the z-y-x Euler angle convention rotation matrix.
source code
 
euler_to_R_zyz(alpha, beta, gamma, R)
Generate the z-y-z Euler angle convention rotation matrix.
source code
tuple of int
matrix_indices(i, neg, alt)
Calculate the parameteric indices i, j, k, and h.
source code
 
R_random_axis(R, angle=0.0)
Generate a random rotation matrix of fixed angle via the axis-angle notation.
source code
 
R_random_hypersphere(R)
Generate a random rotation matrix using 4D hypersphere point picking.
source code
numpy 3D rank-1 array, float
R_to_axis_angle(R)
Convert the rotation matrix into the axis-angle notation.
source code
tuple of float
R_to_euler(R, notation, axes_rot='static', second_sol=False)
Convert the rotation matrix to the given Euler angles.
source code
tuple of float
R_to_euler_xyx(R)
Convert the rotation matrix to the xyx Euler angles.
source code
tuple of float
R_to_euler_xyz(R)
Convert the rotation matrix to the xyz Euler angles.
source code
tuple of float
R_to_euler_xzx(R)
Convert the rotation matrix to the xzx Euler angles.
source code
tuple of float
R_to_euler_xzy(R)
Convert the rotation matrix to the xzy Euler angles.
source code
tuple of float
R_to_euler_yxy(R)
Convert the rotation matrix to the yxy Euler angles.
source code
tuple of float
R_to_euler_yxz(R)
Convert the rotation matrix to the yxz Euler angles.
source code
tuple of float
R_to_euler_yzx(R)
Convert the rotation matrix to the yzx Euler angles.
source code
tuple of float
R_to_euler_yzy(R)
Convert the rotation matrix to the yzy Euler angles.
source code
tuple of float
R_to_euler_zxy(R)
Convert the rotation matrix to the zxy Euler angles.
source code
tuple of float
R_to_euler_zxz(R)
Convert the rotation matrix to the zxz Euler angles.
source code
tuple of float
R_to_euler_zyx(R)
Convert the rotation matrix to the zyx Euler angles.
source code
tuple of float
R_to_euler_zyz(R)
Convert the rotation matrix to the zyz Euler angles.
source code
tuple of float
R_to_tilt_torsion(R)
Convert the rotation matrix to the tilt and torsion rotation angles.
source code
 
R_to_quaternion(R, quat)
Convert a rotation matrix into quaternion form.
source code
 
random_rot_axis(axis)
Generate a random rotation axis.
source code
tuple of float
reverse_euler_xyx(alpha, beta, gamma)
Convert the given forward rotation Euler angles into the equivalent reverse rotation Euler angles.
source code
tuple of float
reverse_euler_xyz(alpha, beta, gamma)
Convert the given forward rotation Euler angles into the equivalent reverse rotation Euler angles.
source code
tuple of float
reverse_euler_xzx(alpha, beta, gamma)
Convert the given forward rotation Euler angles into the equivalent reverse rotation Euler angles.
source code
tuple of float
reverse_euler_xzy(alpha, beta, gamma)
Convert the given forward rotation Euler angles into the equivalent reverse rotation Euler angles.
source code
tuple of float
reverse_euler_yxy(alpha, beta, gamma)
Convert the given forward rotation Euler angles into the equivalent reverse rotation Euler angles.
source code
tuple of float
reverse_euler_yxz(alpha, beta, gamma)
Convert the given forward rotation Euler angles into the equivalent reverse rotation Euler angles.
source code
tuple of float
reverse_euler_yzx(alpha, beta, gamma)
Convert the given forward rotation Euler angles into the equivalent reverse rotation Euler angles.
source code
tuple of float
reverse_euler_yzy(alpha, beta, gamma)
Convert the given forward rotation Euler angles into the equivalent reverse rotation Euler angles.
source code
tuple of float
reverse_euler_zxy(alpha, beta, gamma)
Convert the given forward rotation Euler angles into the equivalent reverse rotation Euler angles.
source code
tuple of float
reverse_euler_zxz(alpha, beta, gamma)
Convert the given forward rotation Euler angles into the equivalent reverse rotation Euler angles.
source code
tuple of float
reverse_euler_zyx(alpha, beta, gamma)
Convert the given forward rotation Euler angles into the equivalent reverse rotation Euler angles.
source code
tuple of float
reverse_euler_zyz(alpha, beta, gamma)
Convert the given forward rotation Euler angles into the equivalent reverse rotation Euler angles.
source code
numpy 3D rank-1 array, float
quaternion_to_axis_angle(quat)
Convert a quaternion into the axis-angle notation.
source code
 
quaternion_to_R(quat, R)
Convert a quaternion into rotation matrix form.
source code
 
tilt_torsion_to_R(phi, theta, sigma, R)
Generate a rotation matrix from the tilt and torsion rotation angles.
source code
 
two_vect_to_R(vector_orig, vector_fin, R)
Calculate the rotation matrix required to rotate from one vector to another.
source code
Variables [hide private]
  EULER_NEXT = [1, 2, 0, 1]
  EULER_TRANS_TABLE = {'xyx': [0, 0, 1], 'xyz': [0, 0, 0], 'xzx'...
  EULER_EPSILON = 1e-05
  __package__ = 'maths_fns'

Imports: deepcopy, acos, asin, atan2, cos, pi, sin, sqrt, array, cross, dot, float64, hypot, sign, transpose, zeros, norm, gauss, uniform, generic_fns


Function Details [hide private]

axis_angle_to_euler_xyx(axis, angle)

source code 

Convert the axis-angle notation to xyx Euler angles.

This first generates a rotation matrix via axis_angle_to_R() and then used this together with R_to_euler_xyx() to obtain the Euler angles.

Parameters:
  • axis (numpy array, len 3) - The 3D rotation axis.
  • angle (float) - The rotation angle.
Returns: float, float, float
The alpha, beta, and gamma Euler angles in the xyx convention.

axis_angle_to_euler_xyz(axis, angle)

source code 

Convert the axis-angle notation to xyz Euler angles.

This first generates a rotation matrix via axis_angle_to_R() and then used this together with R_to_euler_xyz() to obtain the Euler angles.

Parameters:
  • axis (numpy array, len 3) - The 3D rotation axis.
  • angle (float) - The rotation angle.
Returns: float, float, float
The alpha, beta, and gamma Euler angles in the xyz convention.

axis_angle_to_euler_xzx(axis, angle)

source code 

Convert the axis-angle notation to xzx Euler angles.

This first generates a rotation matrix via axis_angle_to_R() and then used this together with R_to_euler_xzx() to obtain the Euler angles.

Parameters:
  • axis (numpy array, len 3) - The 3D rotation axis.
  • angle (float) - The rotation angle.
Returns: float, float, float
The alpha, beta, and gamma Euler angles in the xzx convention.

axis_angle_to_euler_xzy(axis, angle)

source code 

Convert the axis-angle notation to xzy Euler angles.

This first generates a rotation matrix via axis_angle_to_R() and then used this together with R_to_euler_xzy() to obtain the Euler angles.

Parameters:
  • axis (numpy array, len 3) - The 3D rotation axis.
  • angle (float) - The rotation angle.
Returns: float, float, float
The alpha, beta, and gamma Euler angles in the xzy convention.

axis_angle_to_euler_yxy(axis, angle)

source code 

Convert the axis-angle notation to yxy Euler angles.

This first generates a rotation matrix via axis_angle_to_R() and then used this together with R_to_euler_yxy() to obtain the Euler angles.

Parameters:
  • axis (numpy array, len 3) - The 3D rotation axis.
  • angle (float) - The rotation angle.
Returns: float, float, float
The alpha, beta, and gamma Euler angles in the yxy convention.

axis_angle_to_euler_yxz(axis, angle)

source code 

Convert the axis-angle notation to yxz Euler angles.

This first generates a rotation matrix via axis_angle_to_R() and then used this together with R_to_euler_yxz() to obtain the Euler angles.

Parameters:
  • axis (numpy array, len 3) - The 3D rotation axis.
  • angle (float) - The rotation angle.
Returns: float, float, float
The alpha, beta, and gamma Euler angles in the yxz convention.

axis_angle_to_euler_yzx(axis, angle)

source code 

Convert the axis-angle notation to yzx Euler angles.

This first generates a rotation matrix via axis_angle_to_R() and then used this together with R_to_euler_yzx() to obtain the Euler angles.

Parameters:
  • axis (numpy array, len 3) - The 3D rotation axis.
  • angle (float) - The rotation angle.
Returns: float, float, float
The alpha, beta, and gamma Euler angles in the yzx convention.

axis_angle_to_euler_yzy(axis, angle)

source code 

Convert the axis-angle notation to yzy Euler angles.

This first generates a rotation matrix via axis_angle_to_R() and then used this together with R_to_euler_yzy() to obtain the Euler angles.

Parameters:
  • axis (numpy array, len 3) - The 3D rotation axis.
  • angle (float) - The rotation angle.
Returns: float, float, float
The alpha, beta, and gamma Euler angles in the yzy convention.

axis_angle_to_euler_zxy(axis, angle)

source code 

Convert the axis-angle notation to zxy Euler angles.

This first generates a rotation matrix via axis_angle_to_R() and then used this together with R_to_euler_zxy() to obtain the Euler angles.

Parameters:
  • axis (numpy array, len 3) - The 3D rotation axis.
  • angle (float) - The rotation angle.
Returns: float, float, float
The alpha, beta, and gamma Euler angles in the zxy convention.

axis_angle_to_euler_zxz(axis, angle)

source code 

Convert the axis-angle notation to zxz Euler angles.

This first generates a rotation matrix via axis_angle_to_R() and then used this together with R_to_euler_zxz() to obtain the Euler angles.

Parameters:
  • axis (numpy array, len 3) - The 3D rotation axis.
  • angle (float) - The rotation angle.
Returns: float, float, float
The alpha, beta, and gamma Euler angles in the zxz convention.

axis_angle_to_euler_zyx(axis, angle)

source code 

Convert the axis-angle notation to zyx Euler angles.

This first generates a rotation matrix via axis_angle_to_R() and then used this together with R_to_euler_zyx() to obtain the Euler angles.

Parameters:
  • axis (numpy array, len 3) - The 3D rotation axis.
  • angle (float) - The rotation angle.
Returns: float, float, float
The alpha, beta, and gamma Euler angles in the zyx convention.

axis_angle_to_euler_zyz(axis, angle)

source code 

Convert the axis-angle notation to zyz Euler angles.

This first generates a rotation matrix via axis_angle_to_R() and then used this together with R_to_euler_zyz() to obtain the Euler angles.

Parameters:
  • axis (numpy array, len 3) - The 3D rotation axis.
  • angle (float) - The rotation angle.
Returns: float, float, float
The alpha, beta, and gamma Euler angles in the zyz convention.

axis_angle_to_R(axis, angle, R)

source code 

Generate the rotation matrix from the axis-angle notation.

Conversion equations

From Wikipedia (http://en.wikipedia.org/wiki/Rotation_matrix), the conversion is given by:

   c = cos(angle); s = sin(angle); C = 1-c
   xs = x*s;   ys = y*s;   zs = z*s
   xC = x*C;   yC = y*C;   zC = z*C
   xyC = x*yC; yzC = y*zC; zxC = z*xC
   [ x*xC+c   xyC-zs   zxC+ys ]
   [ xyC+zs   y*yC+c   yzC-xs ]
   [ zxC-ys   yzC+xs   z*zC+c ]
Parameters:
  • axis (numpy array, len 3) - The 3D rotation axis.
  • angle (float) - The rotation angle.
  • R (3x3 numpy array) - The 3x3 rotation matrix to update.

axis_angle_to_quaternion(axis, angle, quat, norm_flag=True)

source code 

Generate the quaternion from the axis-angle notation.

Conversion equations

From Wolfram MathWorld (http://mathworld.wolfram.com/Quaternion.html), the conversion is given by:

   q = (cos(angle/2), n * sin(angle/2)),

where q is the quaternion and n is the unit vector representing the rotation axis.

Parameters:
  • axis (numpy array, len 3) - The 3D rotation axis.
  • angle (float) - The rotation angle.
  • quat (numpy 4D, rank-1 array) - The quaternion structure.
  • norm_flag (bool) - A flag which if True forces the axis to be converted to a unit vector.

copysign(x, y)

source code 

Return x with the sign of y.

This is defined as:

   copysign(x, y) = abs(x) / abs(y) * y
Parameters:
  • x (float) - The value.
  • y (float) - The value.
Returns: float
x with the sign of y.

euler_to_axis_angle_xyx(alpha, beta, gamma)

source code 

Convert the xyx Euler angles to axis-angle notation.

This function first generates a rotation matrix via euler_*_to_R() and then uses R_to_axis_angle() to convert to the axis and angle notation.

Parameters:
  • alpha (float) - The alpha Euler angle in rad.
  • beta (float) - The beta Euler angle in rad.
  • gamma (float) - The gamma Euler angle in rad.
Returns: numpy 3D rank-1 array, float
The 3D rotation axis and angle.

euler_to_axis_angle_xyz(alpha, beta, gamma)

source code 

Convert the xyz Euler angles to axis-angle notation.

This function first generates a rotation matrix via euler_*_to_R() and then uses R_to_axis_angle() to convert to the axis and angle notation.

Parameters:
  • alpha (float) - The alpha Euler angle in rad.
  • beta (float) - The beta Euler angle in rad.
  • gamma (float) - The gamma Euler angle in rad.
Returns: numpy 3D rank-1 array, float
The 3D rotation axis and angle.

euler_to_axis_angle_xzx(alpha, beta, gamma)

source code 

Convert the xzx Euler angles to axis-angle notation.

This function first generates a rotation matrix via euler_*_to_R() and then uses R_to_axis_angle() to convert to the axis and angle notation.

Parameters:
  • alpha (float) - The alpha Euler angle in rad.
  • beta (float) - The beta Euler angle in rad.
  • gamma (float) - The gamma Euler angle in rad.
Returns: numpy 3D rank-1 array, float
The 3D rotation axis and angle.

euler_to_axis_angle_xzy(alpha, beta, gamma)

source code 

Convert the xzy Euler angles to axis-angle notation.

This function first generates a rotation matrix via euler_*_to_R() and then uses R_to_axis_angle() to convert to the axis and angle notation.

Parameters:
  • alpha (float) - The alpha Euler angle in rad.
  • beta (float) - The beta Euler angle in rad.
  • gamma (float) - The gamma Euler angle in rad.
Returns: numpy 3D rank-1 array, float
The 3D rotation axis and angle.

euler_to_axis_angle_yxy(alpha, beta, gamma)

source code 

Convert the yxy Euler angles to axis-angle notation.

This function first generates a rotation matrix via euler_*_to_R() and then uses R_to_axis_angle() to convert to the axis and angle notation.

Parameters:
  • alpha (float) - The alpha Euler angle in rad.
  • beta (float) - The beta Euler angle in rad.
  • gamma (float) - The gamma Euler angle in rad.
Returns: numpy 3D rank-1 array, float
The 3D rotation axis and angle.

euler_to_axis_angle_yxz(alpha, beta, gamma)

source code 

Convert the yxz Euler angles to axis-angle notation.

This function first generates a rotation matrix via euler_*_to_R() and then uses R_to_axis_angle() to convert to the axis and angle notation.

Parameters:
  • alpha (float) - The alpha Euler angle in rad.
  • beta (float) - The beta Euler angle in rad.
  • gamma (float) - The gamma Euler angle in rad.
Returns: numpy 3D rank-1 array, float
The 3D rotation axis and angle.

euler_to_axis_angle_yzx(alpha, beta, gamma)

source code 

Convert the yzx Euler angles to axis-angle notation.

This function first generates a rotation matrix via euler_*_to_R() and then uses R_to_axis_angle() to convert to the axis and angle notation.

Parameters:
  • alpha (float) - The alpha Euler angle in rad.
  • beta (float) - The beta Euler angle in rad.
  • gamma (float) - The gamma Euler angle in rad.
Returns: numpy 3D rank-1 array, float
The 3D rotation axis and angle.

euler_to_axis_angle_yzy(alpha, beta, gamma)

source code 

Convert the yzy Euler angles to axis-angle notation.

This function first generates a rotation matrix via euler_*_to_R() and then uses R_to_axis_angle() to convert to the axis and angle notation.

Parameters:
  • alpha (float) - The alpha Euler angle in rad.
  • beta (float) - The beta Euler angle in rad.
  • gamma (float) - The gamma Euler angle in rad.
Returns: numpy 3D rank-1 array, float
The 3D rotation axis and angle.

euler_to_axis_angle_zxy(alpha, beta, gamma)

source code 

Convert the zxy Euler angles to axis-angle notation.

This function first generates a rotation matrix via euler_*_to_R() and then uses R_to_axis_angle() to convert to the axis and angle notation.

Parameters:
  • alpha (float) - The alpha Euler angle in rad.
  • beta (float) - The beta Euler angle in rad.
  • gamma (float) - The gamma Euler angle in rad.
Returns: numpy 3D rank-1 array, float
The 3D rotation axis and angle.

euler_to_axis_angle_zxz(alpha, beta, gamma)

source code 

Convert the zxz Euler angles to axis-angle notation.

This function first generates a rotation matrix via euler_*_to_R() and then uses R_to_axis_angle() to convert to the axis and angle notation.

Parameters:
  • alpha (float) - The alpha Euler angle in rad.
  • beta (float) - The beta Euler angle in rad.
  • gamma (float) - The gamma Euler angle in rad.
Returns: numpy 3D rank-1 array, float
The 3D rotation axis and angle.

euler_to_axis_angle_zyx(alpha, beta, gamma)

source code 

Convert the zyx Euler angles to axis-angle notation.

This function first generates a rotation matrix via euler_*_to_R() and then uses R_to_axis_angle() to convert to the axis and angle notation.

Parameters:
  • alpha (float) - The alpha Euler angle in rad.
  • beta (float) - The beta Euler angle in rad.
  • gamma (float) - The gamma Euler angle in rad.
Returns: numpy 3D rank-1 array, float
The 3D rotation axis and angle.

euler_to_axis_angle_zyz(alpha, beta, gamma)

source code 

Convert the zyz Euler angles to axis-angle notation.

This function first generates a rotation matrix via euler_*_to_R() and then uses R_to_axis_angle() to convert to the axis and angle notation.

Parameters:
  • alpha (float) - The alpha Euler angle in rad.
  • beta (float) - The beta Euler angle in rad.
  • gamma (float) - The gamma Euler angle in rad.
Returns: numpy 3D rank-1 array, float
The 3D rotation axis and angle.

euler_to_R_xyx(alpha, beta, gamma, R)

source code 

Generate the x-y-x Euler angle convention rotation matrix.

Rotation matrix

The rotation matrix is defined as the vector of unit vectors:

   R = [mux, muy, muz].

According to wikipedia (http://en.wikipedia.org/wiki/Euler_angles#Table_of_matrices), the rotation matrix for the xyx convention is:

         |  cb                  sa*sb               ca*sb            |
   R  =  |  sb*sg               ca*cg - sa*cb*sg   -sa*cg - ca*cb*sg |,
         | -sb*cg               ca*sg + sa*cb*cg   -sa*sg + ca*cb*cg |

where:

   ca = cos(alpha),
   sa = sin(alpha),
   cb = cos(beta),
   sb = sin(beta),
   cg = cos(gamma),
   sg = sin(gamma).
Parameters:
  • alpha (float) - The alpha Euler angle in rad for the x-rotation.
  • beta (float) - The beta Euler angle in rad for the y-rotation.
  • gamma (float) - The gamma Euler angle in rad for the second x-rotation.
  • R (3x3 numpy array) - The 3x3 rotation matrix to update.

euler_to_R_xyz(alpha, beta, gamma, R)

source code 

Generate the x-y-z Euler angle convention rotation matrix.

Rotation matrix

The rotation matrix is defined as the vector of unit vectors:

   R = [mux, muy, muz].

According to wikipedia (http://en.wikipedia.org/wiki/Euler_angles#Table_of_matrices), the rotation matrix for the xyz convention is:

         |  cb*cg              -ca*sg + sa*sb*cg    sa*sg + ca*sb*cg |
   R  =  |  cb*sg               ca*cg + sa*sb*sg   -sa*cg + ca*sb*sg |,
         | -sb                  sa*cb               ca*cb            |

where:

   ca = cos(alpha),
   sa = sin(alpha),
   cb = cos(beta),
   sb = sin(beta),
   cg = cos(gamma),
   sg = sin(gamma).
Parameters:
  • alpha (float) - The alpha Euler angle in rad for the x-rotation.
  • beta (float) - The beta Euler angle in rad for the y-rotation.
  • gamma (float) - The gamma Euler angle in rad for the z-rotation.
  • R (3x3 numpy array) - The 3x3 rotation matrix to update.

euler_to_R_xzx(alpha, beta, gamma, R)

source code 

Generate the x-z-x Euler angle convention rotation matrix.

Rotation matrix

The rotation matrix is defined as the vector of unit vectors:

   R = [mux, muy, muz].

According to wikipedia (http://en.wikipedia.org/wiki/Euler_angles#Table_of_matrices), the rotation matrix for the xzx convention is:

         |  cb                 -ca*sb               sa*sb            |
   R  =  |  sb*cg              -sa*sg + ca*cb*cg   -ca*sg - sa*cb*cg |,
         |  sb*sg               sa*cg + ca*cb*sg    ca*cg - sa*cb*sg |

where:

   ca = cos(alpha),
   sa = sin(alpha),
   cb = cos(beta),
   sb = sin(beta),
   cg = cos(gamma),
   sg = sin(gamma).
Parameters:
  • alpha (float) - The alpha Euler angle in rad for the x-rotation.
  • beta (float) - The beta Euler angle in rad for the z-rotation.
  • gamma (float) - The gamma Euler angle in rad for the second x-rotation.
  • R (3x3 numpy array) - The 3x3 rotation matrix to update.

euler_to_R_xzy(alpha, beta, gamma, R)

source code 

Generate the x-z-y Euler angle convention rotation matrix.

Rotation matrix

The rotation matrix is defined as the vector of unit vectors:

   R = [mux, muy, muz].

According to wikipedia (http://en.wikipedia.org/wiki/Euler_angles#Table_of_matrices), the rotation matrix for the xzy convention is:

         |  cb*cg               sa*sg - ca*sb*cg    ca*sg + sa*sb*cg |
   R  =  |  sb                  ca*cb              -sa*cb            |,
         | -cb*sg               sa*cg + ca*sb*sg    ca*cg - sa*sb*sg |

where:

   ca = cos(alpha),
   sa = sin(alpha),
   cb = cos(beta),
   sb = sin(beta),
   cg = cos(gamma),
   sg = sin(gamma).
Parameters:
  • alpha (float) - The alpha Euler angle in rad for the x-rotation.
  • beta (float) - The beta Euler angle in rad for the z-rotation.
  • gamma (float) - The gamma Euler angle in rad for the y-rotation.
  • R (3x3 numpy array) - The 3x3 rotation matrix to update.

euler_to_R_yxy(alpha, beta, gamma, R)

source code 

Generate the y-x-y Euler angle convention rotation matrix.

Rotation matrix

The rotation matrix is defined as the vector of unit vectors:

   R = [mux, muy, muz].

According to wikipedia (http://en.wikipedia.org/wiki/Euler_angles#Table_of_matrices), the rotation matrix for the yxy convention is:

         |  ca*cg - sa*cb*sg    sb*sg               sa*cg + ca*cb*sg |
   R  =  |  sa*sb               cb                 -ca*sb            |,
         | -ca*sg - sa*cb*cg    sb*cg              -sa*sg + ca*cb*cg |

where:

   ca = cos(alpha),
   sa = sin(alpha),
   cb = cos(beta),
   sb = sin(beta),
   cg = cos(gamma),
   sg = sin(gamma).
Parameters:
  • alpha (float) - The alpha Euler angle in rad for the y-rotation.
  • beta (float) - The beta Euler angle in rad for the x-rotation.
  • gamma (float) - The gamma Euler angle in rad for the second y-rotation.
  • R (3x3 numpy array) - The 3x3 rotation matrix to update.

euler_to_R_yxz(alpha, beta, gamma, R)

source code 

Generate the y-x-z Euler angle convention rotation matrix.

Rotation matrix

The rotation matrix is defined as the vector of unit vectors:

   R = [mux, muy, muz].

According to wikipedia (http://en.wikipedia.org/wiki/Euler_angles#Table_of_matrices), the rotation matrix for the yxz convention is:

         |  ca*cg - sa*sb*sg   -cb*sg               sa*cg + ca*sb*sg |
   R  =  |  ca*sg + sa*sb*cg    cb*cg               sa*sg - ca*sb*cg |,
         | -sa*cb               sb                  ca*cb            |

where:

   ca = cos(alpha),
   sa = sin(alpha),
   cb = cos(beta),
   sb = sin(beta),
   cg = cos(gamma),
   sg = sin(gamma).
Parameters:
  • alpha (float) - The alpha Euler angle in rad for the y-rotation.
  • beta (float) - The beta Euler angle in rad for the x-rotation.
  • gamma (float) - The gamma Euler angle in rad for the z-rotation.
  • R (3x3 numpy array) - The 3x3 rotation matrix to update.

euler_to_R_yzx(alpha, beta, gamma, R)

source code 

Generate the y-z-x Euler angle convention rotation matrix.

Rotation matrix

The rotation matrix is defined as the vector of unit vectors:

   R = [mux, muy, muz].

According to wikipedia (http://en.wikipedia.org/wiki/Euler_angles#Table_of_matrices), the rotation matrix for the yzx convention is:

         |  ca*cb              -sb                  sa*cb            |
   R  =  |  sa*sg + ca*sb*cg    cb*cg              -ca*sg + sa*sb*cg |,
         | -sa*cg + ca*sb*sg    cb*sg               ca*cg + sa*sb*sg |

where:

   ca = cos(alpha),
   sa = sin(alpha),
   cb = cos(beta),
   sb = sin(beta),
   cg = cos(gamma),
   sg = sin(gamma).
Parameters:
  • alpha (float) - The alpha Euler angle in rad for the y-rotation.
  • beta (float) - The beta Euler angle in rad for the z-rotation.
  • gamma (float) - The gamma Euler angle in rad for the x-rotation.
  • R (3x3 numpy array) - The 3x3 rotation matrix to update.

euler_to_R_yzy(alpha, beta, gamma, R)

source code 

Generate the y-z-y Euler angle convention rotation matrix.

Rotation matrix

The rotation matrix is defined as the vector of unit vectors:

   R = [mux, muy, muz].

According to wikipedia (http://en.wikipedia.org/wiki/Euler_angles#Table_of_matrices), the rotation matrix for the yzy convention is:

         | -sa*sg + ca*cb*cg   -sb*cg               ca*sg + sa*cb*cg |
   R  =  |  ca*sb               cb                  sa*sb            |,
         | -sa*cg - ca*cb*sg    sb*sg               ca*cg - sa*cb*sg |

where:

   ca = cos(alpha),
   sa = sin(alpha),
   cb = cos(beta),
   sb = sin(beta),
   cg = cos(gamma),
   sg = sin(gamma).
Parameters:
  • alpha (float) - The alpha Euler angle in rad for the y-rotation.
  • beta (float) - The beta Euler angle in rad for the z-rotation.
  • gamma (float) - The gamma Euler angle in rad for the second y-rotation.
  • R (3x3 numpy array) - The 3x3 rotation matrix to update.

euler_to_R_zxy(alpha, beta, gamma, R)

source code 

Generate the z-x-y Euler angle convention rotation matrix.

Rotation matrix

The rotation matrix is defined as the vector of unit vectors:

   R = [mux, muy, muz].

According to wikipedia (http://en.wikipedia.org/wiki/Euler_angles#Table_of_matrices), the rotation matrix for the zxy convention is:

         |  ca*cg + sa*sb*sg   -sa*cg + ca*sb*sg    cb*sg            |
   R  =  |  sa*cb               ca*cb              -sb               |,
         | -ca*sg + sa*sb*cg    sa*sg + ca*sb*cg    cb*cg            |

where:

   ca = cos(alpha),
   sa = sin(alpha),
   cb = cos(beta),
   sb = sin(beta),
   cg = cos(gamma),
   sg = sin(gamma).
Parameters:
  • alpha (float) - The alpha Euler angle in rad for the z-rotation.
  • beta (float) - The beta Euler angle in rad for the x-rotation.
  • gamma (float) - The gamma Euler angle in rad for the y-rotation.
  • R (3x3 numpy array) - The 3x3 rotation matrix to update.

euler_to_R_zxz(alpha, beta, gamma, R)

source code 

Generate the z-x-z Euler angle convention rotation matrix.

Rotation matrix

The rotation matrix is defined as the vector of unit vectors:

   R = [mux, muy, muz].

According to wikipedia (http://en.wikipedia.org/wiki/Euler_angles#Table_of_matrices), the rotation matrix for the zxz convention is:

         |  ca*cg - sa*cb*sg   -sa*cg - ca*cb*sg    sb*sg            |
   R  =  |  ca*sg + sa*cb*cg   -sa*sg + ca*cb*cg   -sb*cg            |,
         |  sa*sb               ca*sb               cb               |

where:

   ca = cos(alpha),
   sa = sin(alpha),
   cb = cos(beta),
   sb = sin(beta),
   cg = cos(gamma),
   sg = sin(gamma).
Parameters:
  • alpha (float) - The alpha Euler angle in rad for the z-rotation.
  • beta (float) - The beta Euler angle in rad for the y-rotation.
  • gamma (float) - The gamma Euler angle in rad for the second z-rotation.
  • R (3x3 numpy array) - The 3x3 rotation matrix to update.

euler_to_R_zyx(alpha, beta, gamma, R)

source code 

Generate the z-y-x Euler angle convention rotation matrix.

Rotation matrix

The rotation matrix is defined as the vector of unit vectors:

   R = [mux, muy, muz].

According to wikipedia (http://en.wikipedia.org/wiki/Euler_angles#Table_of_matrices), the rotation matrix for the zyx convention is:

         |  ca*cb              -sa*cb               sb               |
   R  =  |  sa*cg + ca*sb*sg    ca*cg - sa*sb*sg   -cb*sg            |,
         |  sa*sg - ca*sb*cg    ca*sg + sa*sb*cg    cb*cg            |

where:

   ca = cos(alpha),
   sa = sin(alpha),
   cb = cos(beta),
   sb = sin(beta),
   cg = cos(gamma),
   sg = sin(gamma).
Parameters:
  • alpha (float) - The alpha Euler angle in rad for the z-rotation.
  • beta (float) - The beta Euler angle in rad for the y-rotation.
  • gamma (float) - The gamma Euler angle in rad for the x-rotation.
  • R (3x3 numpy array) - The 3x3 rotation matrix to update.

euler_to_R_zyz(alpha, beta, gamma, R)

source code 

Generate the z-y-z Euler angle convention rotation matrix.

Rotation matrix

The rotation matrix is defined as the vector of unit vectors:

   R = [mux, muy, muz].

According to wikipedia (http://en.wikipedia.org/wiki/Euler_angles#Table_of_matrices), the rotation matrix for the zyz convention is:

         | -sa*sg + ca*cb*cg   -ca*sg - sa*cb*cg    sb*cg            |
   R  =  |  sa*cg + ca*cb*sg    ca*cg - sa*cb*sg    sb*sg            |,
         | -ca*sb               sa*sb               cb               |

where:

   ca = cos(alpha),
   sa = sin(alpha),
   cb = cos(beta),
   sb = sin(beta),
   cg = cos(gamma),
   sg = sin(gamma).
Parameters:
  • alpha (float) - The alpha Euler angle in rad for the z-rotation.
  • beta (float) - The beta Euler angle in rad for the y-rotation.
  • gamma (float) - The gamma Euler angle in rad for the second z-rotation.
  • R (3x3 numpy array) - The 3x3 rotation matrix to update.

matrix_indices(i, neg, alt)

source code 

Calculate the parameteric indices i, j, k, and h.

This is one of the algorithms of Ken Shoemake in "Euler Angle Conversion. Graphics Gems IV. Paul Heckbert (ed.). Academic Press, 1994, ISBN: 0123361567. pp. 222-229." (http://www.graphicsgems.org/).

The indices (i, j, k) are a permutation of (x, y, z), and the index h corresponds to the row containing the Givens argument a.

Parameters:
  • i (int) - The index i.
  • neg (int) - Zero if (i, j, k) is an even permutation of (x, y, z) or one if odd.
  • alt (int) - Zero if the first and last system axes are the same, or one if they are different.
Returns: tuple of int
The values of j, k, and h.

R_random_axis(R, angle=0.0)

source code 

Generate a random rotation matrix of fixed angle via the axis-angle notation.

Uniform point sampling on a unit sphere is used to generate a random axis orientation. This, together with the fixed rotation angle, is used to generate the random rotation matrix.

Parameters:
  • R (numpy 3D, rank-2 array) - A 3D matrix to convert to the rotation matrix.
  • angle (float) - The fixed rotation angle.

R_random_hypersphere(R)

source code 

Generate a random rotation matrix using 4D hypersphere point picking.

A quaternion is generated by creating a 4D vector with each value randomly selected from a Gaussian distribution, and then normalising.

Parameters:
  • R (numpy 3D, rank-2 array) - A 3D matrix to convert to the rotation matrix.

R_to_axis_angle(R)

source code 

Convert the rotation matrix into the axis-angle notation.

Conversion equations

From Wikipedia (http://en.wikipedia.org/wiki/Rotation_matrix), the conversion is given by:

   x = Qzy-Qyz
   y = Qxz-Qzx
   z = Qyx-Qxy
   r = hypot(x,hypot(y,z))
   t = Qxx+Qyy+Qzz
   theta = atan2(r,t-1)
Parameters:
  • R (3x3 numpy array) - The 3x3 rotation matrix to update.
Returns: numpy 3D rank-1 array, float
The 3D rotation axis and angle.

R_to_euler(R, notation, axes_rot='static', second_sol=False)

source code 

Convert the rotation matrix to the given Euler angles.

This uses the algorithms of Ken Shoemake in "Euler Angle Conversion. Graphics Gems IV. Paul Heckbert (ed.). Academic Press, 1994, ISBN: 0123361567. pp. 222-229." (http://www.graphicsgems.org/).

The Euler angle notation can be one of:

  • xyx
  • xyz
  • xzx
  • xzy
  • yxy
  • yxz
  • yzx
  • yzy
  • zxy
  • zxz
  • zyx
  • zyz
Parameters:
  • R (3D, rank-2 numpy array) - The 3x3 rotation matrix to extract the Euler angles from.
  • notation (str) - The Euler angle notation to use.
  • axes_rot (str) - The axes rotation - either 'static', the static axes or 'rotating', the rotating axes.
  • second_sol (bool) - Return the second solution instead (currently unused).
Returns: tuple of float
The alpha, beta, and gamma Euler angles in the given convention.

R_to_euler_xyx(R)

source code 

Convert the rotation matrix to the xyx Euler angles.

Parameters:
  • R (3D, rank-2 numpy array) - The 3x3 rotation matrix to extract the Euler angles from.
Returns: tuple of float
The alpha, beta, and gamma Euler angles in the xyx convention.

R_to_euler_xyz(R)

source code 

Convert the rotation matrix to the xyz Euler angles.

Parameters:
  • R (3D, rank-2 numpy array) - The 3x3 rotation matrix to extract the Euler angles from.
Returns: tuple of float
The alpha, beta, and gamma Euler angles in the xyz convention.

R_to_euler_xzx(R)

source code 

Convert the rotation matrix to the xzx Euler angles.

Parameters:
  • R (3D, rank-2 numpy array) - The 3x3 rotation matrix to extract the Euler angles from.
Returns: tuple of float
The alpha, beta, and gamma Euler angles in the xzx convention.

R_to_euler_xzy(R)

source code 

Convert the rotation matrix to the xzy Euler angles.

Parameters:
  • R (3D, rank-2 numpy array) - The 3x3 rotation matrix to extract the Euler angles from.
Returns: tuple of float
The alpha, beta, and gamma Euler angles in the xzy convention.

R_to_euler_yxy(R)

source code 

Convert the rotation matrix to the yxy Euler angles.

Parameters:
  • R (3D, rank-2 numpy array) - The 3x3 rotation matrix to extract the Euler angles from.
Returns: tuple of float
The alpha, beta, and gamma Euler angles in the yxy convention.

R_to_euler_yxz(R)

source code 

Convert the rotation matrix to the yxz Euler angles.

Parameters:
  • R (3D, rank-2 numpy array) - The 3x3 rotation matrix to extract the Euler angles from.
Returns: tuple of float
The alpha, beta, and gamma Euler angles in the yxz convention.

R_to_euler_yzx(R)

source code 

Convert the rotation matrix to the yzx Euler angles.

Parameters:
  • R (3D, rank-2 numpy array) - The 3x3 rotation matrix to extract the Euler angles from.
Returns: tuple of float
The alpha, beta, and gamma Euler angles in the yzx convention.

R_to_euler_yzy(R)

source code 

Convert the rotation matrix to the yzy Euler angles.

Parameters:
  • R (3D, rank-2 numpy array) - The 3x3 rotation matrix to extract the Euler angles from.
Returns: tuple of float
The alpha, beta, and gamma Euler angles in the yzy convention.

R_to_euler_zxy(R)

source code 

Convert the rotation matrix to the zxy Euler angles.

Parameters:
  • R (3D, rank-2 numpy array) - The 3x3 rotation matrix to extract the Euler angles from.
Returns: tuple of float
The alpha, beta, and gamma Euler angles in the zxy convention.

R_to_euler_zxz(R)

source code 

Convert the rotation matrix to the zxz Euler angles.

Parameters:
  • R (3D, rank-2 numpy array) - The 3x3 rotation matrix to extract the Euler angles from.
Returns: tuple of float
The alpha, beta, and gamma Euler angles in the zxz convention.

R_to_euler_zyx(R)

source code 

Convert the rotation matrix to the zyx Euler angles.

Parameters:
  • R (3D, rank-2 numpy array) - The 3x3 rotation matrix to extract the Euler angles from.
Returns: tuple of float
The alpha, beta, and gamma Euler angles in the zyx convention.

R_to_euler_zyz(R)

source code 

Convert the rotation matrix to the zyz Euler angles.

Parameters:
  • R (3D, rank-2 numpy array) - The 3x3 rotation matrix to extract the Euler angles from.
Returns: tuple of float
The alpha, beta, and gamma Euler angles in the zyz convention.

R_to_tilt_torsion(R)

source code 

Convert the rotation matrix to the tilt and torsion rotation angles.

This notation is taken from "Bonev, I. A. and Gosselin, C. M. (2006) Analytical determination of the workspace of symmetrical spherical parallel mechanisms. IEEE Transactions on Robotics, 22(5), 1011-1017".

Parameters:
  • R (3D, rank-2 numpy array) - The 3x3 rotation matrix to extract the tilt and torsion angles from.
Returns: tuple of float
The phi, theta, and sigma tilt and torsion angles.

R_to_quaternion(R, quat)

source code 

Convert a rotation matrix into quaternion form.

This is from Wikipedia (http://en.wikipedia.org/wiki/Rotation_matrix#Quaternion), where:

   w = 0.5*sqrt(1+Qxx+Qyy+Qzz),
   x = copysign(0.5*sqrt(1+Qxx-Qyy-Qzz),Qzy-Qyz),
   y = copysign(0.5*sqrt(1-Qxx+Qyy-Qzz),Qxz-Qzx),
   z = copysign(0.5*sqrt(1-Qxx-Qyy+Qzz),Qyx-Qxy),

where the quaternion is defined as q = (w, x, y, z), and the copysign function is x with the sign of y:

   copysign(x, y) = abs(x) / abs(y) * y
Parameters:
  • R (numpy 3D, rank-2 array) - The 3D rotation matrix.
  • quat (numpy 4D, rank-1 array) - The quaternion.

random_rot_axis(axis)

source code 

Generate a random rotation axis.

Uniform point sampling on a unit sphere is used to generate a random axis orientation.

Parameters:
  • axis (numpy array, len 3) - The 3D rotation axis.

reverse_euler_xyx(alpha, beta, gamma)

source code 

Convert the given forward rotation Euler angles into the equivalent reverse rotation Euler angles.

This if for the xyx notation.

Parameters:
  • alpha (float) - The alpha Euler angle in rad.
  • beta (float) - The beta Euler angle in rad.
  • gamma (float) - The gamma Euler angle in rad.
Returns: tuple of float
The alpha, beta, and gamma Euler angles for the reverse rotation.

reverse_euler_xyz(alpha, beta, gamma)

source code 

Convert the given forward rotation Euler angles into the equivalent reverse rotation Euler angles.

This if for the xyz notation.

Parameters:
  • alpha (float) - The alpha Euler angle in rad.
  • beta (float) - The beta Euler angle in rad.
  • gamma (float) - The gamma Euler angle in rad.
Returns: tuple of float
The alpha, beta, and gamma Euler angles for the reverse rotation.

reverse_euler_xzx(alpha, beta, gamma)

source code 

Convert the given forward rotation Euler angles into the equivalent reverse rotation Euler angles.

This if for the xzx notation.

Parameters:
  • alpha (float) - The alpha Euler angle in rad.
  • beta (float) - The beta Euler angle in rad.
  • gamma (float) - The gamma Euler angle in rad.
Returns: tuple of float
The alpha, beta, and gamma Euler angles for the reverse rotation.

reverse_euler_xzy(alpha, beta, gamma)

source code 

Convert the given forward rotation Euler angles into the equivalent reverse rotation Euler angles.

This if for the xzy notation.

Parameters:
  • alpha (float) - The alpha Euler angle in rad.
  • beta (float) - The beta Euler angle in rad.
  • gamma (float) - The gamma Euler angle in rad.
Returns: tuple of float
The alpha, beta, and gamma Euler angles for the reverse rotation.

reverse_euler_yxy(alpha, beta, gamma)

source code 

Convert the given forward rotation Euler angles into the equivalent reverse rotation Euler angles.

This if for the yxy notation.

Parameters:
  • alpha (float) - The alpha Euler angle in rad.
  • beta (float) - The beta Euler angle in rad.
  • gamma (float) - The gamma Euler angle in rad.
Returns: tuple of float
The alpha, beta, and gamma Euler angles for the reverse rotation.

reverse_euler_yxz(alpha, beta, gamma)

source code 

Convert the given forward rotation Euler angles into the equivalent reverse rotation Euler angles.

This if for the yxz notation.

Parameters:
  • alpha (float) - The alpha Euler angle in rad.
  • beta (float) - The beta Euler angle in rad.
  • gamma (float) - The gamma Euler angle in rad.
Returns: tuple of float
The alpha, beta, and gamma Euler angles for the reverse rotation.

reverse_euler_yzx(alpha, beta, gamma)

source code 

Convert the given forward rotation Euler angles into the equivalent reverse rotation Euler angles.

This if for the yzx notation.

Parameters:
  • alpha (float) - The alpha Euler angle in rad.
  • beta (float) - The beta Euler angle in rad.
  • gamma (float) - The gamma Euler angle in rad.
Returns: tuple of float
The alpha, beta, and gamma Euler angles for the reverse rotation.

reverse_euler_yzy(alpha, beta, gamma)

source code 

Convert the given forward rotation Euler angles into the equivalent reverse rotation Euler angles.

This if for the yzy notation.

Parameters:
  • alpha (float) - The alpha Euler angle in rad.
  • beta (float) - The beta Euler angle in rad.
  • gamma (float) - The gamma Euler angle in rad.
Returns: tuple of float
The alpha, beta, and gamma Euler angles for the reverse rotation.

reverse_euler_zxy(alpha, beta, gamma)

source code 

Convert the given forward rotation Euler angles into the equivalent reverse rotation Euler angles.

This if for the zxy notation.

Parameters:
  • alpha (float) - The alpha Euler angle in rad.
  • beta (float) - The beta Euler angle in rad.
  • gamma (float) - The gamma Euler angle in rad.
Returns: tuple of float
The alpha, beta, and gamma Euler angles for the reverse rotation.

reverse_euler_zxz(alpha, beta, gamma)

source code 

Convert the given forward rotation Euler angles into the equivalent reverse rotation Euler angles.

This if for the zxz notation.

Parameters:
  • alpha (float) - The alpha Euler angle in rad.
  • beta (float) - The beta Euler angle in rad.
  • gamma (float) - The gamma Euler angle in rad.
Returns: tuple of float
The alpha, beta, and gamma Euler angles for the reverse rotation.

reverse_euler_zyx(alpha, beta, gamma)

source code 

Convert the given forward rotation Euler angles into the equivalent reverse rotation Euler angles.

This if for the zyx notation.

Parameters:
  • alpha (float) - The alpha Euler angle in rad.
  • beta (float) - The beta Euler angle in rad.
  • gamma (float) - The gamma Euler angle in rad.
Returns: tuple of float
The alpha, beta, and gamma Euler angles for the reverse rotation.

reverse_euler_zyz(alpha, beta, gamma)

source code 

Convert the given forward rotation Euler angles into the equivalent reverse rotation Euler angles.

This if for the zyz notation.

Parameters:
  • alpha (float) - The alpha Euler angle in rad.
  • beta (float) - The beta Euler angle in rad.
  • gamma (float) - The gamma Euler angle in rad.
Returns: tuple of float
The alpha, beta, and gamma Euler angles for the reverse rotation.

quaternion_to_axis_angle(quat)

source code 

Convert a quaternion into the axis-angle notation.

Conversion equations

From Wolfram MathWorld (http://mathworld.wolfram.com/Quaternion.html), the conversion is given by:

   q = (cos(angle/2), n * sin(angle/2)),

where q is the quaternion and n is the unit vector representing the rotation axis. Therfore:

   angle = 2*acos(w),

   axis = 2*asin([x, y, z])
Parameters:
  • quat (numpy 4D, rank-1 array) - The quaternion.
Returns: numpy 3D rank-1 array, float
The 3D rotation axis and angle.

quaternion_to_R(quat, R)

source code 

Convert a quaternion into rotation matrix form.

This is from Wikipedia (http://en.wikipedia.org/wiki/Rotation_matrix#Quaternion), where:

       | 1 - 2y**2 - 2z**2      2xy - 2zw          2xz + 2yw     |
   Q = |     2xy + 2zw      1 - 2x**2 - 2z**2      2yz - 2xw     |,
       |     2xz - 2yw          2yz + 2xw      1 - 2x**2 - 2y**2 |

and where the quaternion is defined as q = (w, x, y, z). This has been verified using Simo Saerkkae's "Notes on Quaternions" at http://www.lce.hut.fi/~ssarkka/.

Parameters:
  • quat (numpy 4D, rank-1 array) - The quaternion.
  • R (numpy 3D, rank-2 array) - A 3D matrix to convert to the rotation matrix.

tilt_torsion_to_R(phi, theta, sigma, R)

source code 

Generate a rotation matrix from the tilt and torsion rotation angles.

This notation is taken from "Bonev, I. A. and Gosselin, C. M. (2006) Analytical determination of the workspace of symmetrical spherical parallel mechanisms. IEEE Transactions on Robotics, 22(5), 1011-1017".

Parameters:
  • phi (float) - The angle defining the x-y plane rotation axis.
  • theta (float) - The tilt angle - the angle of rotation about the x-y plane rotation axis.
  • sigma (float) - The torsion angle - the angle of rotation about the z' axis.
  • R (3D, rank-2 numpy array) - The 3x3 rotation matrix to update.

two_vect_to_R(vector_orig, vector_fin, R)

source code 

Calculate the rotation matrix required to rotate from one vector to another.

For the rotation of one vector to another, there are an infinit series of rotation matrices possible. Due to axially symmetry, the rotation axis can be any vector lying in the symmetry plane between the two vectors. Hence the axis-angle convention will be used to construct the matrix with the rotation axis defined as the cross product of the two vectors. The rotation angle is the arccosine of the dot product of the two unit vectors.

Given a unit vector parallel to the rotation axis, w = [x, y, z] and the rotation angle a, the rotation matrix R is:

         |  1 + (1-cos(a))*(x*x-1)   -z*sin(a)+(1-cos(a))*x*y   y*sin(a)+(1-cos(a))*x*z |
   R  =  |  z*sin(a)+(1-cos(a))*x*y   1 + (1-cos(a))*(y*y-1)   -x*sin(a)+(1-cos(a))*y*z |
         | -y*sin(a)+(1-cos(a))*x*z   x*sin(a)+(1-cos(a))*y*z   1 + (1-cos(a))*(z*z-1)  |
Parameters:
  • vector_orig (numpy array, len 3) - The unrotated vector defined in the reference frame.
  • vector_fin (numpy array, len 3) - The rotated vector defined in the reference frame.
  • R (3x3 numpy array) - The 3x3 rotation matrix to update.

Variables Details [hide private]

EULER_TRANS_TABLE

Value:
{'xyx': [0, 0, 1],
 'xyz': [0, 0, 0],
 'xzx': [0, 1, 1],
 'xzy': [0, 1, 0],
 'yxy': [1, 1, 1],
 'yxz': [1, 1, 0],
 'yzx': [1, 0, 0],
 'yzy': [1, 0, 1],
...