CoordinateTransformations package

Submodules

CoordinateTransformations.RP2T module

CoordinateTransformations.RP2T.RP2T(R, P)

convert rotation matrix and translation vector into transform matrix

Parameters:
  • R (np.array(3,3)) – rotation matrix
  • P (np.array(3,1)) – translation vector
Returns:

T – homogeneous transform matrix

Return type:

np.array(4,4)

CoordinateTransformations.R_x module

CoordinateTransformations.R_x.R_x(alpha, unit='rad')

Rotation about OX-axis with alpha-angle

Parameters:
  • alpha (int/float) – angle of rotation
  • unit (string) – unit of angle, “deg” or “rad”, defaults to rad
Returns:

R – rotation_matrix

Return type:

np.array(3,3)

CoordinateTransformations.R_y module

CoordinateTransformations.R_y.R_y(phi, unit='rad')

Rotation about OY-axis with phi-angle

Parameters:
  • phi (int/float) – angle of rotation
  • unit (string) – unit of angle, “deg” or “rad”, defaults to rad
Returns:

R – rotation_matrix

Return type:

np.array(3,3)

CoordinateTransformations.R_z module

CoordinateTransformations.R_z.R_z(theta, unit='rad')

Rotation about OZ-axis with theta-angle

Parameters:
  • theta (int/float) – angle of rotation
  • unit (string) – unit of angle, “deg” or “rad”, defaults to rad
Returns:

R – rotation_matrix

Return type:

np.array(3,3)

CoordinateTransformations.Screw_X module

CoordinateTransformations.Screw_X.Screw_X(distance, angle, unit='rad')

Screw motion around X axis and with given distnace from the x-axis

Parameters:
  • distnace (int/float) – distance from the x-axis
  • alpha (int/float) – angle of rotation
  • unit (string) – unit of angle, “deg” or “rad”, defaults to rad
Returns:

T – homogeneous rotation matrix

Return type:

np.array(4,4)

CoordinateTransformations.Screw_Z module

CoordinateTransformations.Screw_Z.Screw_Z(distance, angle, unit='rad')

Screw motion around Z axis and with given distnace from the z-axis

Parameters:
  • distnace (int/float) – distance from the z-axis
  • alpha (int/float) – angle of rotation
  • unit (string) – unit of angle, “deg” or “rad”, defaults to rad
Returns:

T – homogeneous rotation matrix

Return type:

np.array(4,4)

CoordinateTransformations.T2RP module

CoordinateTransformations.T2RP.T2RP(T)

convert transform matrix into rotation matrix and translation vector

Parameters:T (np.array(4,4)) – homogeneous transform matrix
Returns:
  • R (np.array(3,3)) – rotation matrix
  • P (np.array(3,1)) – translation vector

CoordinateTransformations.T_translation module

CoordinateTransformations.T_translation.T_translation(translation_vec)

Homogeneous transform matrix for given translation

Notes

no rotation is assumed

Parameters:translation_vec (np.array(3,1)) – translation vector
Returns:T – homogeneous translation matrix
Return type:np.array(4,4)

CoordinateTransformations.T_x module

CoordinateTransformations.T_x.T_x(alpha, unit='rad')

homogeneous transformation matrix rotated around X axis by alpha angle

Notes

no translation is assumed

Parameters:
  • alpha (int/float) – angle of rotation
  • unit (string) – unit of angle, “deg” or “rad”, defaults to rad
Returns:

T – homogeneous transform matrix

Return type:

np.array(4,4)

CoordinateTransformations.T_y module

CoordinateTransformations.T_y.T_y(phi, unit='rad')

homogeneous transformation matrix rotated around Y axis by phi angle

Notes

no translation is assumed

Parameters:
  • phi (int/float) – angle of rotation
  • unit (string) – unit of angle, “deg” or “rad”, defaults to rad
Returns:

T – homogeneous transform matrix

Return type:

np.array(4,4)

CoordinateTransformations.T_z module

CoordinateTransformations.T_z.T_z(theta, unit='rad')

homogeneous transformation matrix rotated around Z axis by theta angle

Notes

no translation is assumed

Parameters:
  • theta (int/float) – angle of rotation
  • unit (string) – unit of angle, “deg” or “rad”, defaults to rad
Returns:

T – homogeneous transform matrix

Return type:

np.array(4,4)

CoordinateTransformations.axis_angle2rotation module

CoordinateTransformations.axis_angle2rotation.axis_angle2rotation(vector_, theta, unit='rad')

Equivalent angle-axis rotation of theta angle around a unit vector in arbitrary direction

Parameters:
  • vector (np.array(3,1)) – unit vector
  • theta (int/float) – angle of rotation
  • unit (string) – unit of angle, “deg” or “rad”, defaults to rad
Returns:

R – rotation matrix

Return type:

np.array(3,3)

CoordinateTransformations.axis_angle2transform module

CoordinateTransformations.axis_angle2transform.axis_angle2transform(vector_, theta, unit='rad', pass_through_origin=True, pass_point=array([[0.], [0.], [0.]]))

Equivalent angle-axis rotation of theta angle around a unit vector in arbitrary direction

Parameters:
  • vector (np.array(3,1)) – unit vector
  • theta (int/float) – angle of rotation
  • unit (string) – unit of angle, “deg” or “rad”, defaults to rad
  • pass_through_origin (bool) – True if vector_ passes through orign, default to True
  • pass_point (np.array(3,1)) – point of pass if vector_ not passes through origin, default to zero vector
Returns:

T – homogeneous transformation matrix

Return type:

np.array(4,4)

CoordinateTransformations.cartesian2cylinderical module

CoordinateTransformations.cartesian2cylinderical.cartesian2cylindrical(x, y, z)

convert cartesian coordinates to cylindrical coordinates

CoordinateTransformations.cartesian2spherical module

CoordinateTransformations.cartesian2spherical.cartesian2spherical(x, y, z)

convert cartesian coordinates to spherical coordinates

CoordinateTransformations.compound_rotations module

CoordinateTransformations.compound_rotations.compound_rotations(R_AB, R_BC)

perform multiplication of rotations

  • just like adding two rotations
  • i.e. compute R_AC from the knowledge of R_AB and R_BC
Parameters:
  • R_AB (np.array(3,3)) – rotation matrix
  • R_BC (np.array(3,3)) – rotation matrix
Returns:

R_AC – rotation matrix

Return type:

np.array(3,3)

CoordinateTransformations.compound_rotations_v2 module

CoordinateTransformations.compound_rotations_v2.compound_rotations_v2(R_arr)

perform multiplication of rotations (even more than 2)

  • just like adding two or more rotations
  • i.e. compute R_AC from the knowledge of R_AB and R_BC
Parameters:R_arr (np.array) – array of rotation matrices of same shape
Returns:R – rotation matrix
Return type:np.array(3,3)

CoordinateTransformations.compound_transforms module

CoordinateTransformations.compound_transforms.compound_transforms(T_AB, T_BC)

perform multiplication of transforms

  • just like adding two transforms
  • i.e. compute T_AC from the knowledge of T_AB and T_BC
Parameters:
  • T_AB (np.array(4,4)) – transform matrix
  • T_BC (np.array(4,4)) – transform matrix
Returns:

T_AC – homogeneous transform matrix

Return type:

np.array(4,4)

CoordinateTransformations.compound_transforms_v2 module

CoordinateTransformations.compound_transforms_v2.compound_transforms_v2(T_arr)

perform multiplication of transforms (even more than 2)

  • just like adding two or more transforms
  • i.e. compute T_AC from the knowledge of T_AB and T_BC
Parameters:T_arr (np.array) – array of transform matrices of same shape
Returns:T – homogeneous transform matrix
Return type:np.array(4,4)

CoordinateTransformations.cylindrical2cartesian module

CoordinateTransformations.cylindrical2cartesian.cylindrical2cartesian(r, theta, z)

convert cylindrical coordinates to cartesian coordinates

CoordinateTransformations.cylindrical2spherical module

CoordinateTransformations.cylindrical2spherical.cylindrical2spherical(r, theta, z)

convert cylindrical coordinates to spherical coordinates

CoordinateTransformations.euler2rotation module

CoordinateTransformations.euler2rotation.euler2rotation(alpha, phi, theta, unit='rad', order='xyz')

rotation matrix from given euler angles

Parameters:
  • alpha (int/float) – angle of rotation about order[0]
  • phi (int/float) – angle of rotation about order[1]
  • theta (int/float) – angle of rotation about order[2]
  • unit (string) – unit of angle, “deg” or “rad”, default to rad
  • order (string) – order of rotation axis, choose order : “ijk” where i=x/y/z, j=x/y/z, k=x/y/z default to “xyz”
Returns:

R – rotation matrix

Return type:

np.array(3,3)

CoordinateTransformations.euler2transform module

CoordinateTransformations.euler2transform.euler2transform(alpha, phi, theta, unit='rad', order='xyz')

homogeneous transform matrix from given euler angles

Parameters:
  • alpha (int/float) – angle of rotation about order[0]
  • phi (int/float) – angle of rotation about order[1]
  • theta (int/float) – angle of rotation about order[2]
  • unit (string) – unit of angle, “deg” or “rad”, default to rad
  • order (string) – order of rotation axis, choose order : “ijk” where i=x/y/z, j=x/y/z, k=x/y/z default to “xyz”
Returns:

T – transform matrix

Return type:

np.array(4,4)

CoordinateTransformations.inverse_rotation module

CoordinateTransformations.inverse_rotation.inverse_rotation(R_AB)

inverse the rotation

i.e. given R_AB, returns R_BA

Parameters:R_AB (np.array(3,3)) – rotation matrix
Returns:R_BA – rotation matrix
Return type:np.array(3,3)

CoordinateTransformations.inverse_transform module

CoordinateTransformations.inverse_transform.inverse_transform(T_AB)

inverse the trasform matrix

i.e. given T_AB, returns T_BA

Parameters:T_AB (np.array(4,4)) – homogeneous transform matrix
Returns:R_BA – homogeneous transform matrix
Return type:np.array(4,4)

CoordinateTransformations.pure_translation module

CoordinateTransformations.pure_translation.pure_translation(position, translation_vec)

pure translation of point by a vector in same coordinate frame

Parameters:
  • position (np.array(3,1)) – position of point in any coord frame
  • translation_vec (np.array(3,1)) – translation vector in same coord frame
Returns:

tr_vec – translated position of point by trans_vec in same coord frame

Return type:

np.array(3,1)

CoordinateTransformations.rotation2axis_angle module

CoordinateTransformations.rotation2axis_angle.rotation2axis_angle(R, output_unit='rad')

convert rotation matrix into axis-angle rotation

Notes

TODO: handle the case for 0 or 180 degrees

Parameters:
  • R (np.array(3,3)) – rotation matrix
  • output_unit (string) – unit of angle, “deg” or “rad”, defaults to rad
Returns:

  • K_hat (np.array(3,1)) – unit vector, axis around which rotation takes place
  • theta (int/float) – angle of rotation around unit vector

CoordinateTransformations.rotation2euler module

CoordinateTransformations.rotation2euler.rotation2euler(R, output_unit='rad')

returns euler angles (alpha, beta and gamma) given a rotation matrix

Parameters:
  • R (np.array(3,3)) – Rotation Matrix
  • output_unit (string) – unit of the output angles, ‘deg’ or ‘rad’, default to rad
Returns:

  • alpha (int/float) – angle around axis
  • beta (int/float) – angle around axis
  • gamma (int/float) – angle around axis

CoordinateTransformations.rotation2transform module

CoordinateTransformations.rotation2transform.rotation2transform(R)

convert rotation matrix into transform matrix

Parameters:R (np.array(3,3)) – rotation matrix
Returns:T – homogeneous transform matrix
Return type:np.array(4,4)

CoordinateTransformations.rotation_operator module

CoordinateTransformations.rotation_operator.rotation_operator(R, point)

rotation matrix as an operator which will perform rotation to a point or a vector

Parameters:
  • R (np.array(3,3)) – rotation matrix
  • point (np.array(3,1)) – point in 3D space
Returns:

P – new point location rotated by the rotation matrix

Return type:

np.array(3,1)

CoordinateTransformations.spherical2cartesian module

CoordinateTransformations.spherical2cartesian.spherical2cartesian(r, phi, theta)

convert spherical coordinates to cartesian coordinates

CoordinateTransformations.spherical2cylindrical module

CoordinateTransformations.spherical2cylindrical.spherical2cylindrical(r, phi, theta)

convert spherical coordinates to cylindrical coordinates

CoordinateTransformations.transform2axis_angle module

CoordinateTransformations.transform2axis_angle.transform2axis_angle(T, output_unit='rad')

convert transform matrix into axis-angle rotation

Notes

TODO: handle the case for 0 or 180 degrees

Parameters:
  • T (np.array(4,4)) – rotation matrix
  • output_unit (string) – unit of angle, “deg” or “rad”, defaults to rad
Returns:

  • K_hat (np.array(3,1)) – unit vector, axis around which rotation takes place
  • theta (int/float) – angle of rotation around unit vector

CoordinateTransformations.transform2euler module

CoordinateTransformations.transform2euler.transform2euler(T, output_unit='rad')

returns euler angles (alpha, beta and gamma) given a transform matrix

Parameters:
  • T (np.array(4,4)) – transform matrix
  • output_unit (string) – unit of the output angles, ‘deg’ or ‘rad’, default to rad
Returns:

  • alpha (int/float) – angle around axis
  • beta (int/float) – angle around axis
  • gamma (int/float) – angle around axis

CoordinateTransformations.transform2rotation module

CoordinateTransformations.transform2rotation.transform2rotation(T)

convert transform matrix into rotation matrix

Parameters:T (np.array(4,4)) – homogeneous transform matrix
Returns:R – rotation matrix
Return type:np.array(3,3)

CoordinateTransformations.transform2translation_vec module

CoordinateTransformations.transform2translation_vec.transform2translation_vec(T)

gives translation_vec from T

Parameters:T (np.array(4,4)) – homogeneous transform matrix
Returns:translation_vec – translation vector
Return type:np.array(3,1)

CoordinateTransformations.transform_operator module

CoordinateTransformations.transform_operator.transform_operator(T, point)

transform matrix as an operator which will perform tranlation and rotation to a point or a vector

Parameters:
  • T (np.array(4,4)) – tranform matrix
  • point (np.array(3,1)) – point in 3D space
Returns:

P – new point location rotated and translated by the transform matrix

Return type:

np.array(3,1)

Module contents