lemmingapex / trilateration

Solves a formulation of n-D space trilateration problem using a nonlinear least squares optimizer
MIT License
398 stars 106 forks source link

How to get ellipse from trilateration? #14

Closed u4s5 closed 6 years ago

u4s5 commented 7 years ago

Hi! Thank you for the great library! But I have a question. There is no problems with getting centroid from trilateration. But how can I get ellipse? I see that the result of trilateration is Optimum, but I can't understand how to get from there something except centroid. Thank you!

u4s5 commented 7 years ago

My goal is to get approximate circle, within which location is. I see some coordinates in jacobian, but I can't understand clearly what they represent. Or maybe I can use sigma or RMS somehow?

lemmingapex commented 7 years ago

You can find data you seek here:

// error and geometry information; may throw SingularMatrixException depending the threshold argument provided
RealVector standardDeviation = optimum.getSigma(0);
RealMatrix covarianceMatrix = optimum.getCovariances(0);

I don't know exactly how you want to show an error ellipse or circle, as it depends on the data being used, but here's somewhere to start: http://www.visiondummy.com/2014/04/draw-error-ellipse-representing-covariance-matrix/

Let me know if that makes sense.

u4s5 commented 7 years ago

Nice article, it helped me. Thanks a lot! Now I can calculate sizes of axes, using covariance matrix. Also now I can change confidence interval of calculating ellipse. Actually I don't need to show an error ellipse: circle is enough for me, so I'm averaging sizes of axes. But what is in standardDeviation? It is deviation of what?

lemmingapex commented 7 years ago

If you are just interested in a circle (orientation/rotation is irrelevant), you may not need the covariance matrix actually. The standard deviation encodes the length of the semi-major and semi-minor axis. In linear algebra speak: the square roots of the eigenvalues of the covariance matrix are the standard deviations along the principal components.

So now there are a number of ways you might estimate the radius of the error circle you seek. The safest method might be to find the maximum of the squares of the standard deviations. Another method could work by preserving area. (What's the radius of a circle that has an area equal to that of the ellipse?)

This article has some good information: http://www.visiondummy.com/2014/04/geometric-interpretation-covariance-matrix/

Post some picture if you get something working. :) Best of luck.

u4s5 commented 6 years ago

You are right, now I can get error circle, using just standard deviations. Thank you for help! image

quangvi282 commented 6 years ago

hi , can you show me how can get position of esclipe on map