Advertisement

Ellipse fitting

Started by January 05, 2025 12:52 AM
57 comments, last by taby 1 week, 6 days ago

You seriously need to get Quantum Computing for Computer Scientists. It will teach you the importance of linear algebra. I used Eigen to code like 80% of the exercises.

Don’t pirate the book… the PDF has intentional errors to fuck with your mind. The hardcover is best.

Check out my Huffman codec:

https://github.com/sjhalayka/qc_for_cs/blob/main/pd_10_3_2.cpp

taby said:

The equation is now $A x^2 + C y^2 + E y + 1 = 0$.

JoeJ said:

Idk, but sounds reasonable to me. Though, the -1 feels confusing.

It's a matter of algebra. The equation is $A x^2 + C y^2 + Ey + 1 = 0$, which becomes simply $A x^2 + C y^2 + Ey = -1$.

Advertisement

I'm sure that it's been done before, but still… I think that it should be called the ace method LOL

taby said:
That’s deadly awesome man. Yes, the Jacobi SVD algorithm is not clear to me. If you still have it, please post your solver code.

It's gone becasue i've switched from accuracy to faster approximations. And the solver i did myself was specific to the problem, like always. I'm not familiar with the algebra to express various problems in matrix form, and then using general solvers, sadly.

The SVD algorithm i was talking about earlier is restricted to a 3x3 matrix, and afaik it works by using 3D rotation maths internally.
It is very fast, and there is SIMD optimized source code.
You could not use it for your ellipse problem i guess, but for example:

Find an ellipsoid to fit some given distribution, e.g. mass particles, or colors, a force field.
This gives the ideal orientation to represent moment of inertia for a rigid body made of said particles, or most important colors you want to preserve with compression, or the anisotropic stress caused from the force field.
It can detect edges, give primary curvature directions, and things like that. But it must be a 3D problem.

LOL it just so happens that we’re dealing with a 3x3 matrix!! :)

Ah, then you could use it i guess. For a speed up. Results are probably the same. I have compared it back then against Eigen SVD.

Advertisement

The whole point of using someone else’s code would be for learning purposes more than anything else. Thanks… I’ll check it out when I’m home on the PC.

Sorry… duplicate post.

I found that for 3x3 real matrices that there is an analytical solution called Cramer’s rule. It may not be the fastest, but it does the trick. It’s easier to understand, because it’s not a numerical solution like the Jacobi SVD solver for instance.

Can you see this chat?

https://copilot.microsoft.com/chats/DTnhCjxD8VeybTBRZATBm

Advertisement