basic projection question

Darrell McCauley mccauley at ecn.purdue.edu
Wed Jul 7 03:37:21 EDT 1993


Trying to make my programs more lat-long friendly...

  G_begin_distance_calculations();

I need to calculate the angle of a line made between two
points (x1,y1) and (x2,y2).
 
The distance between the points (the hypotenuse in
geometric/planimetric terms) is

  d = G_distance (x1, y1, x2, y2);

In a planimetric projection, the angle (in degrees) would be:

  angle = 180.0 / 3.14159 * acos ( (x1-x2) /d )

but with lat-long I don't believe that this is the case
(because the distance between two longitudes is different,
depending upon what latitude you are at).  Would the 
correct way to compute this angle be:

  angle = 180.0 / 3.14159 
        * acos ((G_distance(x1,y1,x2,y1)+G_distance(x1,y2,x2,y2)) /2.0 
        / d);

(that is, averaging the two distances at lat1 and lat2 to come
up with the numerator for the inverse cosine quotient). 
This approach seems sort of naive but I cannot think of
anything better at the moment.

Is this correct approach? Is there a library function that I am
missing which would do what I want?

--Darrell



More information about the grass-dev mailing list