Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calculating transformation matrix #15

Open
nagygabor93 opened this issue Aug 24, 2022 · 5 comments
Open

Calculating transformation matrix #15

nagygabor93 opened this issue Aug 24, 2022 · 5 comments
Labels

Comments

@nagygabor93
Copy link

Hi!

First, thank you for the great implementation.

I would like to ask, what is happening here:

a, b, c = radii
r = (a * b * c) ** (1. / 3.)
D = np.array([[r/a, 0., 0.], [0., r/b, 0.], [0., 0., r/c]])
#http://www.cs.brandeis.edu/~cs155/Lecture_07_6.pdf
#affine transformation from ellipsoid to sphere (translation excluded)
TR = evecs.dot(D).dot(evecs.T)

I can not find in the original matlab code this part. Can you explain please what this do ? :)

@aleksandrbazhin
Copy link
Owner

As far as I recall, it is not related to finding the ellipsoid, it is using the ellipsoid found to calibrate the magnetometer. The perfectly calibrated one would be returning such "spherical" data, i.e. when you rotate it by x degrees, the magnetic field data should indicate that. TR is the transformation you would apply to raw data to get the calibrated one.
I think the previous issue / question was about that.

@nagygabor93
Copy link
Author

nagygabor93 commented Aug 24, 2022

Thanks for the answer!

Yes I understand that this is for magnetometer raw data transformation ( I want to use it for that as well! :) ) I just dont understand what are these calculations:


a, b, c = radii
r = (a * b * c) ** (1. / 3.)
D = np.array([[r/a, 0., 0.], [0., r/b, 0.], [0., 0., r/c]])
#http://www.cs.brandeis.edu/~cs155/Lecture_07_6.pdf
#affine transformation from ellipsoid to sphere (translation excluded)
TR = evecs.dot(D).dot(evecs.T)

The ellipsoid_fit function already returns the evecs, that is a transformation matrix in itself isn't it?

@aleksandrbazhin
Copy link
Owner

I think it is just scaling along the principal axes of the ellipsoid we find.

@nagygabor93
Copy link
Author

One more question here. In the original matlab code, it was possible to call the function with the 'xyz' parameter. That way (at least from the code comments) it seems that the algorithm will produce a sphere fitting.

Can you remember why you choose to implement the arbitrary one?

@aleksandrbazhin
Copy link
Owner

As far as I remember, the author created several options for symmetrical ellipsoids, but the most relevant to magnetometer calibration was the arbitrary one. What is the reason in fitting a sphere to the points if you want to find a transformation from the ellipsoid to sphere? If your data fits to sphere, the most arbitrary method will still work, just the axes in the result would be of equal length.
I understand it can be useful sometimes, as well as other options in the original, it just was not useful for me. In the end you can easily substitute the equation yourself. The code in this repo is not perfect, neither it is universal, I just shared what I had.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants