Translation#
- class named_arrays.transformations.Translation(vector)#
Bases:
AbstractTranslation,Generic[VectorT]A translation-only vector transformation.
Examples
Translate a vector using a single transformation
import matplotlib.pyplot as plt import astropy.units as u import astropy.visualization import named_arrays as na vector = na.Cartesian2dVectorArray( x=12 * u.mm, y=12 * u.mm, ) transformation = na.transformations.Translation(vector) square = na.Cartesian2dVectorArray( x=na.ScalarArray([-10, 10, 10, -10, -10] * u.mm, axes="vertex"), y=na.ScalarArray([-10, -10, 10, 10, -10] * u.mm, axes="vertex"), ) square_transformed = transformation(square) with astropy.visualization.quantity_support(): plt.figure(); plt.gca().set_aspect("equal"); na.plt.plot(square, label="original"); na.plt.plot(square_transformed, label="translated"); plt.legend();
Translate a vector using an array of transformations
vector_2 = na.Cartesian2dVectorArray( x=na.ScalarArray([12, -12] * u.mm, axes="transform"), y=9 * u.mm, ) transformation_2 = na.transformations.Translation(vector_2) square_transformed_2 = transformation_2(square) with astropy.visualization.quantity_support(): plt.figure(); plt.gca().set_aspect("equal"); na.plt.plot(square, label="original"); na.plt.plot(square_transformed_2, axis="vertex", label="translated"); plt.legend();
Attributes
A new transformation that reverses the effect of this transformation.
The shape of the transformation.
A vector representing the translation.
Methods
__init__(vector)Inheritance Diagram

- Parameters:
vector (VectorT)
- vector: VectorT = <dataclasses._MISSING_TYPE object>#
A vector representing the translation.