I'm working on a real-time distance estimation program using data from successive image frames. To do so, I employ Perspective-3-Points, which boils down to solving systems of three nonlinear equations derived from the law of Cosines. I'm using vpasolve, as there are 8 sets of solutions, and while I often get the solutions I expect, I am occasionally getting erroneous values that come with the following warning:
Warning: Solution '[x1 = 50.513354258655913523642438228345, x2 = 70.834152303683331599397540128635, x3 = -3.6823353014471324108432162378347]' seems to be affected by some numeric instability. Inserting this solution into equation '(5682387108428029*x1^2)/36893488147419103232 - (2779811138476361*x1*x2)/9223372036854775808 + (1396576697819169*x2^2)/9223372036854775808 - 3837877865952747/73786976294838206464 = 0' produces the residue '0.074294366099841203751338186504608'.
I attached two sets of very similar variables, one resulting in errors and the other in expected solutions (with the right order of magnitude), to check with the code below:
syms x1 x2 x3
S = vpasolve([F1,F2,F3],[x1, x2, x3]);
sol=double([S.x1 S.x2 S.x3])
Are there any suggestions as to what could be the cause behind the erroneous solutions from vpasolve and how to solve it?