# Transformation

class compas.geometry.Transformation(matrix=None)[source]

The Transformation represents a 4x4 transformation matrix.

It is the base class for transformations like Rotation, Translation, Scale, Reflection, Projection and Shear.

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, M, M = x, y, z.

Parameters

matrix (list of list of float, optional) – The 4x4 transformation matrix.

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()


Methods

 concatenate(other) Concatenate another transformation to this transformation. concatenated(other) Concatenate two transformations into one Transformation. Returns a copy of the transformation. Decompose the Transformation into its Scale, Shear, Rotation, Translation and Projection components. from_change_of_basis(frame_from, frame_to) Computes a change of basis transformation between two frames. from_data(data) Creates a Transformation from a data dict. from_euler_angles(euler_angles[, static, ...]) Construct a transformation from a rotation represented by Euler angles. from_frame(frame) Computes a transformation from world XY to frame. from_frame_to_frame(frame_from, frame_to) Computes a transformation between two frames. from_json(filepath) Construct an object from serialized data contained in a JSON file. from_jsonstring(string) Construct an object from serialized data contained in a JSON string. from_list(numbers) Creates a Transformation from a list of 16 numbers. from_matrix(matrix) Creates a Transformation from a 4x4 matrix-like object. Returns the inverse transformation. Invert this transformation. Returns the inverse transformation. Convert a Transformation object to a data dict. to_json(filepath[, pretty]) Serialize the data representation of an object to a JSON file. to_jsonstring([pretty]) 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).