0

So no need to see all the code but basically I have an initial point:

import numpy as np

point = np.array([3.0000, 8.0000, 0.0000])

I also have a transformation matrix M which works fine that needs to transform the point into the X-axis only, this yields the following:

[-5.09901951  0.          0.        ] // which is perfectly what I need it to be

Usually in my code I need to perform alterations in the local coordinate then cast it back to global. For that I use the inverse matrix to take it back. However just for testing I will bring back the point unchanged.

//Using numpy:

MInv =np.linalg.inv(M)

now when I use the same function to transform my output to the original state I get:

[ 3.01941932   7.90290338  0.        ] // result should be [3.0000, 8.0000, 0.0000]

Clearly there is a numerical precision problem with using linalg.inv() in numpy. Can someone help me bypass the error ?

Artem Barger
  • 40,769
  • 9
  • 59
  • 81
Hadi Farah
  • 1,091
  • 2
  • 9
  • 27
  • [Start here](https://stackoverflow.com/questions/31256252/why-does-numpy-linalg-solve-offer-more-precise-matrix-inversions-than-numpy-li) and [there](https://www.johndcook.com/blog/2010/01/19/dont-invert-that-matrix/) before doing some basic research on numerical-computing. – sascha Jun 27 '17 at 10:41
  • What is your matrix `M`? To elevate the common floating point error of `1e-16` to a relative error of `1e-2` you will need a condition number of `1e14`, which is almost as singular as you can get with a matrix without invoking division-by-zero errors. – Lutz Lehmann Jun 27 '17 at 10:48
  • @LutzL okay and how do I do that ? – Hadi Farah Jun 27 '17 at 13:25
  • There was no recommendation there, just speculation on the nature of the matrix `M` that you have not provided. – Lutz Lehmann Jun 27 '17 at 14:37
  • problem solved. – Hadi Farah Jun 28 '17 at 12:24

0 Answers0