Trilateration

Example 3.1,Page 47

In [2]:
#initialisation of variable
from math import pi,tan,sqrt,sin,cos
AB=25145.32;
R=6370.0e3;#radius of earth
ha=325.14;

#calculation
theta=AB*cos(3+9.0/60+40.0/3600)/R;
AB_dash=AB/sin(pi/2+theta/2)*sin(pi/2-theta/2-(3+9.0/60+40.0/3600)*pi/180);
CD=AB_dash-AB_dash*ha/R;
S=CD+CD**3/24.0/R**2;

#result
print "sea level length in m",round(S,3)
sea level length in m 25108.53

Example 3.2,Page 50

In [9]:
#initialisation of variable
from math import pi,tan,sqrt,sin,asin
AB=31325.14
R=6370.0e3;#radius of earth
ha=1582.15;
h=2669.17

#calculation
AB_dash=AB-h**2/2/AB;
theta=2*asin(AB_dash/2/R);
AB_dash=AB-(h*sin(theta/2)+h**2/AB/2)
CD=AB_dash-AB_dash*ha/R;
S=CD+CD**3/24.0/R**2;

#result
print "sea level length in m",round(S,3)
sea level length in m 31197.163

Example 3.3,Page 53

In [25]:
#initialisation of variable
from math import pi,tan,sqrt,sin, acos
AB=1525.456;
BC=2176.945;
CD=1697.435;
AD=2401.435;
AC=3073.845;
BD=2483.115;

#calculation
#alpha=A and beta=B and those are angles
A1=acos((CD**2+AC**2-AD**2)/(2*CD*AC));
A1=A1*180/pi;
A2=acos((AD**2+BD**2-AB**2)/(2*AD*BD));
A2=A2*180/pi;
A3=acos((AB**2+AC**2-BC**2)/(2*AB*AC));
A3=A3*180/pi;
A4=acos((BC**2+BD**2-CD**2)/(2*BC*BD));
A4=A4*180/pi;
B1=acos((CD**2+BD**2-BC**2)/(2*CD*BD));
B1=B1*180/pi;
B2=acos((AD**2+AC**2-CD**2)/(2*AD*AC));
B2=B2*180/pi;
B3=acos((AB**2+BD**2-AD**2)/(2*AB*BD));
B3=B3*180/pi;
B4=acos((AC**2+BC**2-AB**2)/(2*AC*BC));
B4=B4*180/pi;
e1=360-A1-A2-A3-A4-B1-B2-B3-B4;#error
e2=A1+B1-A3-B3;#error
e3=A2+B2-A4-B4;#error
#angle update
A1=A1+e1/8-e2/4;
A3=A3+e1/8+e2/4;
B1=B1+e1/8-e2/4;
B3=B3+e1/8+e2/4;
A2=A2+e1/8-e3/4;
B2=B2+e1/8-e3/4;
A4=A4+e1/8+e3/4;
B4=B4+e1/8+e3/4;
#updating sides
AD=1525.456*sin(B3*pi/180)/sin(A2*pi/180);
BD=1525.456*sin(A3*pi/180+B3*pi/180)/sin(A2*pi/180);
AC=1525.456*sin(A4*pi/180+B3*pi/180)/sin(B4*pi/180);
BC=1525.456*sin(A3*pi/180)/sin(B4*pi/180);
CD=BC*sin(A4*pi/180)/sin(B1*pi/180)

#result

print "equation for B2 is wrong"
print "corrected length of AD in m ",round(AD,3)
print "corrected length of AC in m ",round(AC,3)
print "corrected length of BD in m ",round(BD,3)
print "corrected length of BC in m ",round(BC,3)
print "corrected length of CD in m ",round(CD,3)
27.5965629411
equation for B2 is wrong
corrected length of AD in m  2401.251
corrected length of AC in m  3073.446
corrected length of BD in m  2413.581
corrected length of BC in m  2176.758
corrected length of CD in m  1697.416

Example 3.4,Page 59

In [2]:
#initialisation of variable
from math import pi,tan,sqrt,log,sin
#angles found by cosine law
#alpha=A and beta=B and those are angles
A1=45.801596;
A2=40.605250;
A3=50.143258;
A4=43.077646;
B1=48.779868;
B2=44.141587;
B3=49.733152;
B4=37.737035;

#calculation
e1=360-A1-A2-A3-A4-B1-B2-B3-B4;#error
#angle update
A1=A1+e1/8;
A3=A3+e1/8;
B1=B1+e1/8;
B3=B3+e1/8;
A2=A2+e1/8;
B2=B2+e1/8;
A4=A4+e1/8;
B4=B4+e1/8;
E2=log(sin(A1*pi/180),10)*log(sin(A2*pi/180),10)*log(sin(A3*pi/180),10)*log(sin(A4*pi/180),10)-log(sin(B1*pi/180),10)*log(sin(B2*pi/180),10)*log(sin(B3*pi/180),10)*log(sin(B4*pi/180),10);
c3=E2/17.1;
c4=E2/17.0;
A1=A1-c3;
B1=B1+c3;

#result
print "corrected angle A1 in degrees",A1,"corrected angle B1 in degrees",B1
corrected angle A1 in degrees 45.7991704812 corrected angle B1 in degrees 48.7774455188