from_components#
- classmethod RigidTransform.from_components(cls, translation, rotation)#
Initialisiert eine starre Transformation aus Übersetzungs- und Rotationskomponenten.
Beim Erstellen einer starren Transformation aus einer Übersetzung und einer Rotation wird die Übersetzung nach der Rotation angewendet, sodass
tf = Tf.from_components(translation, rotation)äquivalent zutf = Tf.from_translation(translation) * Tf.from_rotation(rotation)ist.Beim Anwenden einer Transformation auf einen Vektor
vist das Ergebnis dasselbe, als ob die Transformation auf den Vektor auf folgende Weise angewendet worden wäre:tf.apply(v) == translation + rotation.apply(v)- Parameter:
- translationarray_like, Form (N, 3) oder (3,)
Ein einzelner Translationsvektor oder ein Stapel von Translationsvektoren.
- rotation
RotationInstanz Eine einzelne Rotation oder ein Stapel von Rotationen.
- Rückgabe:
RigidTransformWenn die Rotation einzeln ist und die Übersetzung die Form (3,) hat, wird eine einzelne Transformation zurückgegeben. Andernfalls wird ein Stapel von Transformationen zurückgegeben.
Beispiele
>>> from scipy.spatial.transform import RigidTransform as Tf >>> from scipy.spatial.transform import Rotation as R >>> import numpy as np
Erstellung aus einer einzelnen Rotation und Übersetzung
>>> t = np.array([2, 3, 4]) >>> r = R.from_euler("ZYX", [90, 30, 0], degrees=True) >>> r.as_matrix() array([[ 0. , -1., 0. ], [ 0.8660254, 0., 0.5 ], [-0.5 , 0., 0.8660254 ]]) >>> tf = Tf.from_components(t, r) >>> tf.rotation.as_matrix() array([[ 0. , -1., 0. ], [ 0.8660254, 0., 0.5 ], [-0.5 , 0., 0.8660254 ]]) >>> tf.translation array([2., 3., 4.]) >>> tf.single True
Beim Anwenden einer Transformation auf einen Vektor
vist das Ergebnis dasselbe, als ob die Transformation auf den Vektor auf folgende Weise angewendet worden wäre:tf.apply(v) == translation + rotation.apply(v)>>> r.apply([1, 0, 0]) array([0. , 0.8660254, -0.5 ]) >>> t + r.apply([1, 0, 0]) array([2. , 3.8660254, 3.5 ]) >>> tf.apply([1, 0, 0]) array([2. , 3.8660254, 3.5 ])