scipy.spatial.transform.RigidTransform.

from_matrix#

classmethod RigidTransform.from_matrix(cls, matrix)#

Initialisierung aus einer 4x4 Transformationsmatrix.

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

Eine einzelne Transformationsmatrix oder ein Stapel von Transformationsmatrizen.

Rückgabe:
transformRigidTransform Instanz

Hinweise

4x4 Starrkörpertransformationsmatrizen haben die Form

[R | t] [0 | 1]

wobei R eine 3x3 Rotationsmatrix und t ein 3x1 Translationsvektor [tx, ty, tz] ist. Da Rotationsmatrizen echt orthogonal sein müssen, wird die Rotationskomponente vor der Initialisierung mittels Singulärwertzerlegung orthonormalisiert.

Beispiele

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

Erstellen einer Transformation aus einer einzelnen Matrix

>>> m = np.array([[0, 1, 0, 2],
...               [0, 0, 1, 3],
...               [1, 0, 0, 4],
...               [0, 0, 0, 1]])
>>> tf = Tf.from_matrix(m)
>>> tf.as_matrix()
array([[0., 1., 0., 2.],
       [0., 0., 1., 3.],
       [1., 0., 0., 4.],
       [0., 0., 0., 1.]])
>>> tf.single
True

Erstellen einer Transformation aus einem Stapel von Matrizen

>>> m = np.array([np.eye(4), np.eye(4)])
>>> tf = Tf.from_matrix(m)
>>> tf.as_matrix()
array([[[1., 0., 0., 0.],
        [0., 1., 0., 0.],
        [0., 0., 1., 0.],
        [0., 0., 0., 1.]],
       [[1., 0., 0., 0.],
        [0., 1., 0., 0.],
        [0., 0., 1., 0.],
        [0., 0., 0., 1.]]])
>>> tf.single
False
>>> len(tf)
2

Matrizen mit einer Rotationskomponente, die nicht echt orthogonal ist, werden vor der Initialisierung mittels Singulärwertzerlegung orthogonalisiert

>>> tf = Tf.from_matrix(np.diag([2, 2, 2, 1]))
>>> tf.as_matrix()
array([[1., 0., 0., 0.],
       [0., 1., 0., 0.],
       [0., 0., 1., 0.],
       [0., 0., 0., 1.]])