compas.geometry.Translation
- class compas.geometry.Translation(matrix=None)[source]
Bases:
compas.geometry.transformations.transformation.TransformationCreate a translation transformation.
- Parameters
matrix (4x4 matrix-like, optional) – A 4x4 matrix (or similar) representing a translation.
- Raises
ValueError – If the default constructor is used, 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 TrueMethods
concatenate(other)Concatenate another transformation to this transformation.
concatenated(other)Concatenate two transformations into one
Transformation.copy()Returns a copy of the transformation.
decomposed()Decompose the
Transformationinto itsScale,Shear,Rotation,TranslationandProjectioncomponents.from_change_of_basis(frame_from, frame_to)Computes a change of basis transformation between two frames.
from_data(data)Creates a
Transformationfrom 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
Transformationfrom a list of 16 numbers.from_matrix(matrix)Creates a
Transformationfrom a 4x4 matrix-like object.from_vector(vector)Create a translation transformation from a translation vector.
inverse()Returns the inverse transformation.
invert()Invert this transformation.
inverted()Returns the inverse transformation.
to_data()Convert a
Transformationobject 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()Transpose the matrix of this transformation.
transposed()Create a transposed copy of this transformation.
validate_data()Validate the object’s data against its data schema (self.DATASCHEMA).
validate_json()Validate the object’s data against its json schema (self.JSONSCHEMA).
Attributes
DATASCHEMAThe schema of the data of this object.
JSONSCHEMAThe schema of the JSON representation of the data of this object.
basis_vectorsThe basis vectors from the rotation component of the transformation matrix.
dataReturn 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.
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_vectorThe translation vector.