scipy.spatial.transform.RigidTransform.
from_translation#
- classmethod RigidTransform.from_translation(cls, translation)#
Initialisierung aus einem Translations-NumPy-Array, ohne Drehung.
Beim Anwenden dieser Transformation auf einen Vektor
vist das Ergebnis dasselbe, als ob die Translation und der Vektor addiert würden. Wenntder Verschiebungsvektor der Translation ist, dann gilt:Tf.from_translation(t).apply(v) == t + v- Parameter:
- translationarray_like, Form (N, 3) oder (3,)
Ein einzelner Translationsvektor oder ein Stapel von Translationsvektoren.
- Rückgabe:
- transform
RigidTransformInstanz
- transform
Beispiele
>>> from scipy.spatial.transform import RigidTransform as Tf >>> import numpy as np
Erstellung einer Transformation aus einem einzelnen Translationsvektor
>>> t = np.array([2, 3, 4]) >>> t + np.array([1, 0, 0]) array([3, 3, 4]) >>> tf = Tf.from_translation(t) >>> tf.apply([1, 0, 0]) array([3., 3., 4.]) >>> tf.single True
Die oberen 3x1 Punkte in der am weitesten rechts liegenden Spalte der Transformationsmatrix sind der Translationsvektor
>>> tf.as_matrix() array([[1., 0., 0., 2.], [0., 1., 0., 3.], [0., 0., 1., 4.], [0., 0., 0., 1.]]) >>> np.allclose(tf.as_matrix()[:3, 3], t) True
Erstellung mehrerer Transformationen aus einem Stapel von Translationsvektoren
>>> t = np.array([[2, 3, 4], [1, 0, 0]]) >>> t + np.array([1, 0, 0]) array([[3, 3, 4], [2, 0, 0]]) >>> tf = Tf.from_translation(t) >>> tf.apply([1, 0, 0]) array([[3., 3., 4.], [2., 0., 0.]]) >>> np.allclose(tf.as_matrix()[:, :3, 3], t) True >>> tf.single False >>> len(tf) 2