MATLAB: Need help finding the cartesian coordinates of a projectile in flight.

azimuthelevation angleintersection of two linesMATLAB

I am given the location of 2 observers on the ground (xy-plane, so z=0), and an azimuth angle (in degrees) as well as an elevation angle (in degrees) from each observer to a projectile in flight. How do I find where these 2 lines of sight intersect? (which would be the x,y,z location of the projectile)
Given Info:
x_obs1 = 671.4971
y_obs1 = 717.2387
z_obs1 = 0
az_obs1 = 75.1148
el_obs1 = 9.3679
x_obs2 = -1.2075*10^3
y_obs2 = 1.6302*10^3
z_obs2 = 0
az_obs2 = -6.4515
el_obs2 = 3.2086
My main problem is that due to the fact that the number have decimals the lines of sight never perfectly intersect. How do I tell if they intersect within 1 or 2 units? (basically if the projectile had a finite volume)

Best Answer

Hi Evan,
Assume the two ground positions are p1 and p2. This method uses the 3d triangle p1,p2,and p3 (the intersection point), assumes that the triangle is closed, and calculates the distances {p1 to p3) and (p2 to p3). Then p3 itself can be calculated two different ways, based on starting from either p1 or p2. These agree reasonably well. For the final result you might consider the average of those two calculations of p3..
x1 = 671.4971;
y1 = 717.2387;
z1 = 0;
az1 = 75.1148;
el1 = 9.3679;
x2 = -1.2075*10^3;
y2 = 1.6302*10^3;
z2 = 0;
az2 = -6.4515;
el2 = 3.2086;
p1 = [x1 y1 0];
p2 = [x2 y2 0];
u1 = [cosd(el1)*cosd(az1) cosd(el1)*sind(az1) sind(el1)];
u2 = [cosd(el2)*cosd(az2) cosd(el2)*sind(az2) sind(el2)];
vgrd = p2-p1;
dgrd = norm(vgrd);
ugrd = vgrd/dgrd;
theta1 = acosd(dot(u1,ugrd));
theta2 = acosd(dot(u2,-ugrd));
phi = 180 - theta1 - theta2;
d2 = dgrd*sind(theta1)/sind(phi);
d1 = dgrd*sind(theta2)/sind(phi);
p3_1 = p1 + d1*u1 % these should agree
p3_2 = p2 + d2*u2
p3_1 - p3_2 % difference is fairly small
norm((p3_1 - p3_2))*2/(d1 + d2) % relative error