Translation

class compas.geometry.Translation[source]

Bases: Transformation

Class representing a translation transformation.

Parameters:
matrixlist[list[float]], optional

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

checkbool, optional

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

namestr, optional

The name of the transformation.

Raises:
ValueError

If check is True and the provided transformation matrix is not a translation.

Examples

>>> T = Translation.from_vector([1, 2, 3])
>>> T[0, 3] == 1
True
>>> T[1, 3] == 2
True
>>> T[2, 3] == 3
True
>>> from compas.geometry import Vector
>>> T = Translation.from_vector(Vector(1, 2, 3))
>>> T[0, 3] == 1
True
>>> T[1, 3] == 2
True
>>> T[2, 3] == 3
True
>>> T = Translation([[1, 0, 0, 1], [0, 1, 0, 2], [0, 0, 1, 3], [0, 0, 0, 1]])
>>> T[0, 3] == 1
True
>>> T[1, 3] == 2
True
>>> T[2, 3] == 3
True
Attributes:
translation_vectorcompas.geometry.Vector

The translation vector.

Methods

from_vector

Create a translation transformation from a translation vector.

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_euler_angles

Construct a transformation from a rotation represented by Euler angles.

from_frame

Construct a transformation from world XY to frame.

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.