Transformation
- class compas.geometry.Transformation[source]
Bases:
DataClass representing a general 4x4 transformation matrix.
It is the base class for transformations like
Rotation,Translation,Scale,Reflection,ProjectionandShear.The class allows to concatenate Transformations by multiplication, to calculate the inverse transformation and to decompose a transformation into its components of rotation, translation, scale, shear, and perspective. The matrix follows the row-major order, such that translation components x, y, z are in the right column of the matrix, i.e.
M[0][3], M[1][3], M[2][3] = x, y, z.- Parameters:
- matrixlist[list[float]], optional
The 4x4 transformation matrix.
- namestr, optional
The name of the transformation.
Examples
>>> from compas.geometry import Frame >>> f1 = Frame([1, 1, 1], [0.68, 0.68, 0.27], [-0.67, 0.73, -0.15]) >>> T = Transformation.from_frame(f1) >>> Sc, Sh, R, Tl, P = T.decomposed() >>> Tinv = T.inverse()
- Attributes:
- scale
compas.geometry.Scale, read-only The scale component of the transformation matrix.
- shear
compas.geometry.Shear, read-only The shear component of the transformation matrix.
- rotation
compas.geometry.Rotation, read-only The rotation component of the transformation matrix.
- translation
compas.geometry.Translation, read-only The translation component of the transformation matrix.
- projection
compas.geometry.Projection, read-only The projection component of the transformation matrix.
- translation_vector
compas.geometry.Vector, read-only The translation component of the transformation matrix as a translation vector.
- basis_vectorstuple[
compas.geometry.Vector,compas.geometry.Vector], read-only The basis vectors from the rotation component of the transformation matrix.
- listlist[float], read-only
Flattens the 4x4 transformation matrix into a list of 16 numbers.
- determinantfloat, read-only
The determinant of the matrix of the transformation.
- scale
Methods
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 a transformation from a rotation represented by Euler angles.
Construct a transformation from world XY to frame.
Construct a transformation between two frames.
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.
Transpose the matrix of this transformation.
Create a transposed copy of this transformation.
Inherited Methods
Converts the instance to a string.
Construct an object of this type from a JSON file.
Construct an object of this type from a JSON string.
Compute a hash of the data for comparison during version control using the sha256 algorithm.
Convert an object to its native data representation and save it to a JSON file.
Convert an object to its native data representation and save it to a JSON string.
Validate the data against the object's data schema.