# View Angle Calculation

In Calculating View Angle? the accepted answer contains the following calculations:

Given two points (x,y,z) and (x',y',z') in an earth-centered coordinate system, the vector from the first to the second is (dx,dy,dz) = (x'-x, y'-y, z'-z)

And then provides an example:

The XYZ coordinates of the airplanes are (x,y,z) = (1285410, -4797210, 3994830) and (x',y',z') = (1202990, -4824940, 3999870), respectively (in the ITRF00 datum, which uses the GRS80 ellipsoid). The pilot's view vector therefore is (dx,dy,dz) = (-82404.5, -27735.3, 5034.56).

What am I missing such that:

1202990 - 1285410 = -82404.5 (vice -82420)

-4824940 - -4797210 = -27735.3 (vice -27730)

3999870 - 3994830 = 5034.56 (vice 5040) ?

The ECEF coordinates that @whuber provided appear to have been rounded to the nearest 10 meters. Looking at the revisions to the answer reveals that originally, the reference points that he used were `(N39°, W75°, 4000m)` and `(N39°, W76°, 12000m)`, translating to ECEF coordinates:

``````(1285408.203, -4797208.722, 3994834.304)
(1202993.662, -4824944.042, 3999868.867)
``````

The vectors are then:

``````dX = -82414.541
dY = -27735.320
dZ = 5034.563
``````

So they all match except dX which looks like a typo.

EDIT

After checking @whuber 's answer more carefully, I noticed that there is a slight issue with the methodology. The vector that is used is from the center of the Earth to the reference point, but that vector is not the appropriate "up" direction to base the calculation on. On the ellipsoid, the normal does not pass through the center of the Earth, except for the Equator or the Poles:

That difference amounts to around 0.2° at most.

To get a slightly better result, you can use the following normal vector components:

``````x = cos(lat)*cos(lon)
y = cos(lat)*sin(lon)
z = sin(lat)
``````

Also, you can take a look at this answer on Math that shows an alternative approach for the calculation of the distance and angles.

• Thanks for taking the time to share your knowledge! I hope to be able to do the same. Mar 2, 2019 at 20:26
• You're welcome. Also, you can have a look at my answer on Math StackExchange, which describes the full formulas as well. Mar 2, 2019 at 20:28