scipy.spatial.transform.Rotation.

from_matrix#

classmethod Rotation.from_matrix(cls, matrix)#

Initialisierung aus einer Rotationsmatrix.

Rotationen in 3 Dimensionen können durch 3 x 3 orthogonale Matrizen [1] dargestellt werden. Wenn die Eingabe nicht orthogonal ist, wird eine Annäherung erstellt, indem die Eingabematrix unter Verwendung der in [2] beschriebenen Methode orthogonalisiert und dann die orthogonalen Rotationsmatrizen mit dem in [3] beschriebenen Algorithmus in Quaternionen umgewandelt werden. Matrizen müssen rechtshändig sein.

Parameter:
matrixarray_like, Form (N, 3, 3) oder (3, 3)

Eine einzelne Matrix oder ein Stapel von Matrizen, wobei matrix[i] die i-te Matrix ist.

Rückgabe:
rotationRotation Instanz

Objekt, das die durch die Rotationsmatrizen dargestellten Rotationen enthält.

Hinweise

Diese Funktion wurde früher from_dcm genannt.

Hinzugefügt in Version 1.4.0.

Referenzen

[3]

F. Landis Markley, „Unit Quaternion from Rotation Matrix“, Journal of guidance, control, and dynamics, Bd. 31.2, S. 440-442, 2008.

Beispiele

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

Initialisierung einer einzelnen Rotation

>>> r = R.from_matrix([
... [0, -1, 0],
... [1, 0, 0],
... [0, 0, 1]])
>>> r.single
True
>>> r.as_matrix().shape
(3, 3)

Mehrere Rotationen in einem einzigen Objekt initialisieren

>>> r = R.from_matrix([
... [
...     [0, -1, 0],
...     [1, 0, 0],
...     [0, 0, 1],
... ],
... [
...     [1, 0, 0],
...     [0, 0, -1],
...     [0, 1, 0],
... ]])
>>> r.as_matrix().shape
(2, 3, 3)
>>> r.single
False
>>> len(r)
2

Wenn die Eingabematrizen nicht speziell orthogonal sind (orthogonal mit Determinante +1), wird eine speziell orthogonale Schätzung gespeichert.

>>> a = np.array([
... [0, -0.5, 0],
... [0.5, 0, 0],
... [0, 0, 0.5]])
>>> np.linalg.det(a)
0.125
>>> r = R.from_matrix(a)
>>> matrix = r.as_matrix()
>>> matrix
array([[ 0., -1.,  0.],
       [ 1.,  0.,  0.],
       [ 0.,  0.,  1.]])
>>> np.linalg.det(matrix)
1.0

Es ist auch möglich, einen Stapel zu haben, der eine einzelne Rotation enthält

>>> r = R.from_matrix([[
... [0, -1, 0],
... [1, 0, 0],
... [0, 0, 1]]])
>>> r.as_matrix()
array([[[ 0., -1.,  0.],
        [ 1.,  0.,  0.],
        [ 0.,  0.,  1.]]])
>>> r.as_matrix().shape
(1, 3, 3)