Rotation
- class compas.geometry.Rotation(matrix=None, check=True)[source]
Bases:
compas.geometry.transformations.transformation.TransformationCreate a rotation transformation.
The class contains methods for converting rotation matrices to axis-angle representations, Euler angles, quaternion and basis vectors.
- Parameters
matrix (4x4 matrix-like, optional) – A 4x4 matrix (or similar) representing a 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) TrueAttributes
axis_and_angleReturns the axis and the angle of the
Rotation.axis_angle_vectorReturns the axis-angle vector of the
Rotation.basis_vectorsReturns the basis vectors of the
Rotation.quaternionReturns the Quaternion from the
Rotation.Inherited Attributes
DATASCHEMAThe schema of the data of this object.
JSONSCHEMAThe schema of the JSON representation of the data of this object.
JSONSCHEMANAMEdataReturn a
Transformationobject's to a data dict.determinantThe determinant of the matrix of the transformation.
dtypeThe type of the object in the form of a '2-level' import and a class name.
guidThe globally unique identifier of the object.
jsondefinitionsReusable schema definitions.
jsonstringThe representation of the object data in JSON format.
jsonvalidatorJSON schema validator for draft 7.
listFlattens the 4x4 transformation matrix into a list of 16 numbers.
nameThe name of the object.
projectionThe projection component of the transformation matrix.
rotationThe rotation component of the transformation matrix.
scaleThe scale component of the transformation matrix.
shearThe shear component of the transformation matrix.
translationThe translation component of the transformation matrix.
translation_vectorMethods
Returns Euler angles from the
Rotationaccording to specified axis sequence and rotation type.Calculates a
Rotationfrom a rotation axis and an angle and an optional point of rotation.Calculates a
Rotationfrom an axis-angle vector.Creates a
Rotationfrom basis vectors (= orthonormal vectors).Calculates a
Rotationfrom Euler angles.Computes the rotational transformation from world XY to frame.
Calculates a
Rotationfrom quaternion coefficients.Inherited Methods
Concatenate another transformation to this transformation.
Concatenate two transformations into one
Transformation.Returns a copy of the transformation.
Decompose the
Transformationinto itsScale,Shear,Rotation,TranslationandProjectioncomponents.Computes a change of basis transformation between two frames.
Creates a
Transformationfrom a data dict.Computes 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
Transformationfrom a list of 16 numbers.Creates a
Transformationfrom a 4x4 matrix-like object.Returns the inverse transformation.
Invert this transformation.
Returns the inverse transformation.
Convert a
Transformationobject to a data dict.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 (self.DATASCHEMA).
Validate the object's data against its json schema (self.JSONSCHEMA).