Rotation#
- class blueprints.Rotation[source]#
Bases:
objectThis class implements multiple functions that operate on a MoveableThings orientation.
- X#
The unit vector \(\vec{\text{id}_x}\) representing the
X-axis.- Type:
np.ndarray
- Y#
The unit vector \(\vec{\text{id}_y}\) representing the
Y-axis.- Type:
np.ndarray
- Z#
The unit vector \(\vec{\text{id}_z}\) representing the
Z-axis.- Type:
np.ndarray
Attributes Summary
Methods Summary
Axis_rot(R)E_rot([alpha, beta, gamma])Constructs the rotation matrix for improper euler angles.
N_rot([node])This method returns the rotation matrix for a given Thing.
X_rot(alpha)Constructs the rotation matrix around the
X-axis for a given angle.Y_rot(beta)Constructs the rotation matrix around the
Y-axis for a given angle.Z_rot(gamma)Constructs the rotation matrix around the
Z-axis for a given angle.angle(a, b[, axis])Computes the angle between two vectors.
euler(vector, alpha, beta, gamma)Rotates a vector according to improper euler angles.
euler_to_quat(alpha, beta, gamma)euler_to_reference_frame(alpha, beta, gamma)This method constructs a reference frame (i.
global_orientation(node)This method calculates the global orientation of a Thing (typically a node in a kinematic tree).
global_rotation_matrix(node)This method calculates the rotation matrix for the global orientation of a Thing (typically a node in e kinematic tree) w.r.t.
quat_to_euler(R, I, J, K)Computes the (improper) euler angles that lead to the given reference frame.
rotate_around_axis(vector, axis, angle)Rotates a vector around an axis for a given angles.
Attributes Documentation
- X = array([1, 0, 0])#
- Y = array([0, 1, 0])#
- Z = array([0, 0, 1])#
Methods Documentation
- classmethod Axis_rot(R)[source]#
- Returns:
The axis of rotation for a given rotation matrix or reference frame
- Return type:
np.ndarray
- classmethod E_rot(alpha=None, beta=None, gamma=None)[source]#
Constructs the rotation matrix for improper euler angles.
- Parameters:
alpha (
float) – The angle around which theX-axis is rotated.beta (
float) – The angle around which theY-axis is rotated.gamma (
float) – The angle around which theZ-axis is rotated.
- Returns:
The rotation matrix for the improper euler angles.
- Return type:
np.ndarray
- classmethod N_rot(node=None)[source]#
This method returns the rotation matrix for a given Thing. If the Thing does not inherit from MoveableThing the identity metrix is returned.
- Parameters:
node (
None,ThingType) – A Thing, typically a node from a kinematic tree.- Returns:
A rotation matrix from the Things orientation.
- Return type:
np.ndarray
- static X_rot(alpha)[source]#
Constructs the rotation matrix around the
X-axis for a given angle.- Parameters:
alpha (
float) – The angle of rotation.- Returns:
The rotation matrix for the given angle.
- Return type:
np.ndarray
- static Y_rot(beta)[source]#
Constructs the rotation matrix around the
Y-axis for a given angle.- Parameters:
beta (
float) – The angle of rotation.- Returns:
The rotation matrix for the given angle.
- Return type:
np.ndarray
- static Z_rot(gamma)[source]#
Constructs the rotation matrix around the
Z-axis for a given angle.- Parameters:
gamma (
float) – The angle of rotation.- Returns:
The rotation matrix for the given angle.
- Return type:
np.ndarray
- classmethod angle(a, b, axis=None)[source]#
Computes the angle between two vectors. If axis is set, the angle is measured according to a rotation around axis from a to b, otherwise the shortest angle is returned.
- Parameters:
a (
np.ndarray) – A vector for which the angle is computed w.r.t. b.b (
np.ndarray) – A vector for which the angle is computed w.r.t. a.axis (
None|np.ndarray, optional) – The axis of rotation can be specified optionally, if this is not done, the resulting angles will be in the range [0, PI).
- Returns:
The resulting angle will be in the range [0, PI) if axis is not specified, otherwise the angle will be in the range [0, TAU).
- Return type:
float
- classmethod euler(vector, alpha, beta, gamma)[source]#
Rotates a vector according to improper euler angles.
- Parameters:
vector (
np.ndarray) – The vector to be rotated.alpha (
float) – The angle along which the vector is rotated on theX-axis.beta (
float) – The angle along which the vector is rotated on theY-axis.gamma (
float) – The angle along which the vector is rotated on theZ-axis.
- Returns:
The rotated vector.
- Return type:
np.ndarray
- classmethod euler_to_quat(alpha, beta, gamma)[source]#
- Parameters:
alpha (
float) – The angle around which theX-axis is rotated.beta (
float) – The angle around which theY-axis is rotated.gamma (
float) – The angle around which theZ-axis is rotated.
- Returns:
The quaternion components for improper euler angles.
- Return type:
tuple[float]
- classmethod euler_to_reference_frame(alpha, beta, gamma)[source]#
This method constructs a reference frame (i. e. the unit vectors for the axis of the local coordinate system) for (improper) euler angles.
- Parameters:
alpha (
float) – The angle by which theX-axis is rotated to reach the reference frame.beta (
float) – The angle by which theY-axis is rotated to reach the reference frame.gamma (
float) – The angle by which theZ-axis is rotated to reach the reference frame.
- Returns:
A tuple of the three unit vectors for the given orientation representing the reference frame.
- Return type:
(np.ndarray,np.ndarray,np.ndarray)
- classmethod global_orientation(node)[source]#
This method calculates the global orientation of a Thing (typically a node in a kinematic tree).
- Parameters:
node (
Thing) – A Thing (typically a node in a kinematic tree) for which the global orientation is calculated w.r.t it’s root.- Returns:
The improper euler angles representing the global orientation.
- Return type:
(float,float,float)
- classmethod global_rotation_matrix(node)[source]#
This method calculates the rotation matrix for the global orientation of a Thing (typically a node in e kinematic tree) w.r.t. to its root.
- Parameters:
node (
Thing) – A Thing (typically a node in a kinematic tree) for which the global orientation is calculated w.r.t it’s root.- Returns:
The global orientation matrix for the node.
- Return type:
np.ndarray
- classmethod quat_to_euler(R, I, J, K)[source]#
- Parameters:
R (
float) – The real rotation angle component of the quaternion.I (
float) – TheX-axis component of the quaternion.J (
float) – TheY-axis component of the quaternion.K (
float) – TheZ-axis component of the quaternion.
- Returns:
The improper euler angles for a given quaternion.
- Return type:
tuple[float]
- classmethod reference_frame_to_euler(R)[source]#
Computes the (improper) euler angles that lead to the given reference frame.
- Parameters:
R (
np.ndarray) – A matrix representing the reference frame as a concatenation of the unit coulmn vectors of the orientations coordinate system.- Returns:
The (improper) euler angles for the given reference frame.
- Return type:
(float,float,float)- Raises:
ArithmeticError –
:raises If the reference frame does not contain orthogonal vectors that do not adhere` to :py:class:`the right hand rule convention am ArithmeticError is raised.:
- classmethod rotate_around_axis(vector, axis, angle)[source]#
Rotates a vector around an axis for a given angles.
- Parameters:
vector (
np.ndarray) – The vector to be rotatedaxis (
np.ndarray) – The axis around which the vector is rotated according to the right hand rule.angle (
float) – The angle by which the vector is rotated.
- Returns:
The rotated vector.
- Return type:
np.ndarray
- __init__()#
- classmethod __new__(*args, **kwargs)#