Rotation
- class compas.geometry.Rotation(matrix=None, check=True)[source]
Bases:
Transformation
Class representing a rotation transformation.
The class contains methods for converting rotation matrices to axis-angle representations, Euler angles, quaternion and basis vectors.
- Parameters
matrix (list[list[float]], optional) – A 4x4 matrix (or similar) representing a rotation.
- Attributes
quaternion (
Quaternion
, read-only) – The quaternion from the rotation.axis_and_angle (tuple[
Vector
, float], read-only) – The axis and the angle of the rotation.axis_angle_vector (
Vector
, read-only) – The axis-angle vector of the rotation.basis_vectors (tuple[
Vector
,Vector
], read-only) – The basis vectors of the rotation.
- Raises
ValueError – If the default constructor is used, and the provided transformation matrix is not a rotation.
Examples
>>> from compas.geometry import Frame >>> f1 = Frame([0, 0, 0], [0.68, 0.68, 0.27], [-0.67, 0.73, -0.15]) >>> R = Rotation.from_frame(f1) >>> args = False, 'xyz' >>> alpha, beta, gamma = R.euler_angles(*args) >>> xaxis, yaxis, zaxis = [1, 0, 0], [0, 1, 0], [0, 0, 1] >>> Rx = Rotation.from_axis_and_angle(xaxis, alpha) >>> Ry = Rotation.from_axis_and_angle(yaxis, beta) >>> Rz = Rotation.from_axis_and_angle(zaxis, gamma) >>> f2 = Frame.worldXY() >>> f1 == f2.transformed(Rx * Ry * Rz) True
Methods
Returns Euler angles from the rotation according to specified axis sequence and rotation type.
Construct a rotation transformation from a rotation axis and an angle and an optional point of rotation.
Construct a rotation transformation from an axis-angle vector.
Construct a rotation transformation from basis vectors (= orthonormal vectors).
Construct a rotation transformation from Euler angles.
Construct a rotation transformationn from world XY to frame.
Construct a rotation transformation` from quaternion coefficients.
Inherited Methods
Converts the instance to a string.
Concatenate another transformation to this transformation.
Concatenate two transformations into one Transformation.
Returns a copy of the transformation.
Decompose the Transformation into its components.
Construct a change of basis transformation between two frames.
Construct an object of this type from the provided data.
Construct a transformation between two frames.
Construct an object from serialized data contained in a JSON file.
Construct an object from serialized data contained in a JSON string.
Creates a transformation from a list of 16 numbers.
Creates a transformation from a list[list[float]] object.
Returns the inverse transformation.
Invert this transformation.
Returns the inverse transformation.
Compute a hash of the data for comparison during version control using the sha256 algorithm.
Convert an object to its native data representation.
Serialize the data representation of an object to a JSON file.
Serialize the data representation of an object to a JSON string.
Transpose the matrix of this transformation.
Create a transposed copy of this transformation.
Validate the object's data against its data schema.
Validate the object's data against its json schema.