scipy.spatial.transform.RigidTransform.

from_rotation#

classmethod RigidTransform.from_rotation(cls, rotation)#

Initialisieren aus einer Drehung, ohne Translation.

Beim Anwenden dieser Transformation auf einen Vektor v ist das Ergebnis dasselbe, als ob die Drehung auf den Vektor angewendet worden wäre. Tf.from_rotation(r).apply(v) == r.apply(v)

Parameter:
rotationRotation Instanz

Eine einzelne Rotation oder ein Stapel von Rotationen.

Rückgabe:
transformRigidTransform Instanz

Beispiele

>>> from scipy.spatial.transform import RigidTransform as Tf
>>> from scipy.spatial.transform import Rotation as R
>>> import numpy as np

Erstellen einer Transformation aus einer einzelnen Drehung

>>> r = R.from_euler("ZYX", [90, 30, 0], degrees=True)
>>> r.apply([1, 0, 0])
array([0.       , 0.8660254, -0.5     ])
>>> tf = Tf.from_rotation(r)
>>> tf.apply([1, 0, 0])
array([0.       , 0.8660254, -0.5     ])
>>> tf.single
True

Die obere 3x3-Untermatrix der Transformationsmatrix ist die Rotationsmatrix

>>> np.allclose(tf.as_matrix()[:3, :3], r.as_matrix(), atol=1e-12)
True

Erstellen mehrerer Transformationen aus einem Stapel von Rotationen

>>> r = R.from_euler("ZYX", [[90, 30, 0], [45, 30, 60]], degrees=True)
>>> r.apply([1, 0, 0])
array([[0.        , 0.8660254 , -0.5       ],
       [0.61237244, 0.61237244, -0.5       ]])
>>> tf = Tf.from_rotation(r)
>>> tf.apply([1, 0, 0])
array([[0.        , 0.8660254 , -0.5       ],
       [0.61237244, 0.61237244, -0.5       ]])
>>> tf.single
False
>>> len(tf)
2