Sunday, October 15, 2006

Math problem

Dear Lazyweb!

I would like to find the symbolic solution for XT0, YT0, dSX, dSY, qX and qY to this set of equations, in a numerically stable way:

XT0 + real_X1*dSX*Cos[qX] + real_Y1*dSY*Sin[qY] == own_X1,
YT0 - real_X1*dSX*Sin[qX] + real_Y1*dSY*Cos[qY] == own_Y1,
XT0 + real_X2*dSX*Cos[qX] + real_Y2*dSY*Sin[qY] == own_X2,
YT0 - real_X2*dSX*Sin[qX] + real_Y2*dSY*Cos[qY] == own_Y2,
XT0 + real_X3*dSX*Cos[qX] + real_Y3*dSY*Sin[qY] == own_X3,
YT0 - real_X3*dSX*Sin[qX] + real_Y3*dSY*Cos[qY] == own_Y3

Mathematica seems to not come back at all when asked for a solution, Maxima (in Debian) refuses cooporation, Maple produces a solution by approximating Sin and Cos with polynoms (which is not good enough for the whole range of [-Pi .. +Pi] and furthermore is not numerically stable.

This is for finding the parameters for the transformation between two different coordinate systems of maps. The real_* and the own_* coordinates are three identical points on both maps. A numeric solution (with simulated annealing from the gnu scientific library) exists but seems to be not exact enough. See also


At 3:17 PM, Blogger Tomaz Solc said...

Here is an analytical solution to your problem:

tan(qX) = -(H-F*D/B)/(G-F*C/B)
tan(qY) = (G-E*C/A)/(H-E*D/A)

dSX = (G-F*C/B)/(E-F*A/B)/cos(qX)
dSY = (H-E*D/A)/(F-E*B/A)/cos(qY)


A = real_X1-real_X2
B = real_Y1-real_Y2
C = own_X1-own_X2
D = own_Y1-own_Y2
E = real_X2-real_X3
F = real_Y2-real_Y3
G = own_X2-own_X3
H = own_Y2-own_Y3

When you have qX, qY, dSX and dSY it is then trivial to solve for XT0 and YT0.

These solutions do not hold for some special cases (for example when dSX or dSY = 0 and obviously also when you get division by zero in the formulas above).

I also suggest you verify my results before using them. I may have made a mistake somewhere.


Post a Comment

<< Home