Rotation

class compas.geometry.Rotation[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:
matrixlist[list[float]], optional

A 4x4 matrix (or similar) representing a rotation.

checkbool, optional

If True, the provided matrix will be checked for validity.

namestr, optional

The name of the transformation.

Attributes:
quaternioncompas.geometry.Quaternion, read-only

The quaternion from the rotation.

axis_and_angletuple[compas.geometry.Vector, float], read-only

The axis and the angle of the rotation.

axis_angle_vectorcompas.geometry.Vector, read-only

The axis-angle vector of the rotation.

basis_vectorstuple[compas.geometry.Vector, compas.geometry.Vector], read-only

The basis vectors of the rotation.

Raises:
ValueError

If check is True 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

euler_angles

Returns Euler angles from the rotation according to specified axis sequence and rotation type.

from_axis_and_angle

Construct a rotation transformation from a rotation axis and an angle and an optional point of rotation.

from_axis_angle_vector

Construct a rotation transformation from an axis-angle vector.

from_basis_vectors

Construct a rotation transformation from basis vectors (= orthonormal vectors).

from_euler_angles

Construct a rotation transformation from Euler angles.

from_frame

Construct a rotation transformationn from world XY to frame.

from_quaternion

Construct a rotation transformation` from quaternion coefficients.

Inherited Methods

ToString

Converts the instance to a string.

concatenate

Concatenate another transformation to this transformation.

concatenated

Concatenate two transformations into one Transformation.

copy

Returns a copy of the transformation.

decomposed

Decompose the Transformation into its components.

from_change_of_basis

Construct a change of basis transformation between two frames.

from_frame_to_frame

Construct a transformation between two frames.

from_json

Construct an object of this type from a JSON file.

from_jsonstring

Construct an object of this type from a JSON string.

from_list

Creates a transformation from a list of 16 numbers.

from_matrix

Creates a transformation from a list[list[float]] object.

inverse

Returns the inverse transformation.

invert

Invert this transformation.

inverted

Returns the inverse transformation.

sha256

Compute a hash of the data for comparison during version control using the sha256 algorithm.

to_json

Convert an object to its native data representation and save it to a JSON file.

to_jsonstring

Convert an object to its native data representation and save it to a JSON string.

transpose

Transpose the matrix of this transformation.

transposed

Create a transposed copy of this transformation.

validate_data

Validate the data against the object's data schema.