2

I would like to find the Translation matrix, Rotation Matrix as well as the Scale Matrix. Following is my code,

import numpy as np

def get_rotation_from_homogeneous_transform(transform):
    
    s = transform.shape
    if s[0] != s[1]:
        raise ValueError('Matrix must be a 4x4 homogenous transformation', s)
    n = s[0]
    rotation = transform[0:n - 1, 0:n - 1]
    return rotation

homogeneous_matrix = np.array([[-0.008189, 0.000428, -0.999900, 0.000000],
[0.758580, 0.651582, 0.008000, 0.000000],
 [0.651582, 0.758580, -0.011300, 0.000000],
  [1.294619, 0.885227, 1.358000, 1.000000]]).astype(np.float32).T

rotM = get_rotation_from_homogeneous_transform(homogeneous_matrix)

Did I extract the Rotation Matrix Properly? How can I extract the translation and Scale Matrix as well?

Mr. Randy Tom
  • 311
  • 5
  • 13
  • Does this answer your question? [Numpy matrix rotation for any degrees](https://stackoverflow.com/questions/53171057/numpy-matrix-rotation-for-any-degrees) – RichieV Sep 06 '20 at 00:57
  • also see [how to normalize a numpy array](https://stackoverflow.com/q/1735025/6692898) – RichieV Sep 06 '20 at 00:58
  • 1
    @RichieV No.. None of them is about Rot Matrix Extraction from the homogenous matrix – Mr. Randy Tom Sep 06 '20 at 13:18

0 Answers0