basic projection question
mccauley at ecn.purdue.edu
Wed Jul 7 03:37:21 EDT 1993
Trying to make my programs more lat-long friendly...
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
(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?
More information about the grass-dev