I want to compute offboresight angle in horizontal and vertical planes from an airborne transmitter (TX) pointing towards the ground to a notional receiver (EX) location.
An example is shown below (3D figure and side view of the 3D figure). Here D is the airborne TX at latitude (degrees), longitude (degrees), and altitude (meter) latD, lonD, and hD. The notional RX point A has an latitude (degrees), longitude (degrees), and altitude (meter) latA, lonA, and hA. In the 3D figure, HB and HA are Earth radii where B is the vertical projection of airborne at point D to ground (so HB abd BD are aligned and DB is perpendicular to BC which is tangent to Earth).
The green arrow DN shows the boresight of the airborne TX and it is along DB (pointing to ground). I want to find the offboresight angle in horizontal and vertical planes.
Vertical offboresight angle is an angle formed between the lines DA and DB in the side view cross section picture of the 3D figure. The code below gives "el" as the angle between DE and DB; since DB and BC are 90 deg and BC and DE are parallel, thus DB and DE are also at 90 deg. Hence, the vertical angle <ADB = 90 - <EDA . Hence I subtract "el" from 90 to get the vertical angle.
[az, el,slantRange]=geodetic2aer(latA, lonA, hA, lanD, lonD, hD)
verticalAngle = 90 - abs(el);
I don't know how to get the horizontal angle. If I assume airborne flies along DE, then horizontal angle would be <MDB (angle between DM and DB) where DM is the projection of DA to the horizontal antenna pattern whose boresight is DN. I don't know how to compute this anlge.