0

for the purpose of converting an image from my robot's camera frame to its base frame, I'm in need of it's rotation matrix, which i have.

However, at some point, i need the inverse of my rotation matrix, which is a 3x3 matrix, to compute some other parameter. The obtained parameters didn't make sense at all, so i checked whether the inverse was actually right and it turns out, it isn't.

when i multiply both matrices, i do not get the identity matrix. Rather, i have a matrix of the form

 ([[  1.00000000e+00,   0.00000000e+00,  -2.77555756e-17],
       [ -1.11022302e-16,   1.00000000e+00,  -2.77555756e-17],
       [  0.00000000e+00,   0.00000000e+00,   1.00000000e+00]]))

which looks weird, but it doesn't contain the 1's on the main diagonal, and some 0s. So i'm not sure if the entire thing is wrong, or only part of it, and either way i don't know how to fix it, any ideas?

lambda
  • 85
  • 1
  • 13
  • 2
    Posting the actual matrix and how you got the inverse would be immensely helpful to answer your question. – Ian Jun 17 '16 at 12:42
  • If you take a close look to the posted matrix, it is very close to the identity matrix. Mind that floating point number arithmetic is approximative. – Willem Van Onsem Jun 17 '16 at 12:44

2 Answers2

1

Your result is the identity matrix. Numbers like "-2.77555756e-17" are the consequences of the finite precision of your computing unit.

You may refer to https://en.wikipedia.org/wiki/Numerical_error and https://en.wikipedia.org/wiki/Round-off_error

pptaszni
  • 5,591
  • 5
  • 27
  • 43
1

Actually, the matrix you show is the identity matrix, within the limits of floating point calculations.

Python stores float numbers in the 8-byte IEEE standard, which can store 15 or 16 significant decimal digits. Most numbers resulting from division cannot be stored exactly, only approximately. When you do calculations with numbers close to 1, you will get "zero" values that are close to 1E-15.

All your "zero" values are smaller than 1E-15 in absolute value, so you should consider them to be zeros. The inexact numbers come from the divisions that occur when calculating the inverse of your matrix.

Rory Daulton
  • 21,934
  • 6
  • 42
  • 50