This topic needs a title

Newsgroups: info.grass.programmer
Path: zorro.cecer.army.mil!shapiro
From: shapiro@zorro.cecer.army.mil (Michael Shapiro)
Subject: Re: basic projection question
Message-ID: <C9tvCB.4Mp@news.cecer.army.mil>
Sender: news@news.cecer.army.mil (Net.Noise owner)
Organization: US Army Corps of Engineers Construction Engineering Research Labs
References: <9307070737.AA12583@bushland.ecn.purdue.edu>
Date: Thu, 8 Jul 1993 04:04:59 GMT
Lines: 44

In <9307070737.AA12583@bushland.ecn.purdue.edu> mccauley@ecn.purdue.edu (Darrell McCauley) writes:

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.

What I think you want is an azimuth calculation and I'm sure this
isn't the right way to do it. There is no formula in GRASS presently
neither for spheres or ellipsoids. Does someone have a reference for
this calculation so it can be coded and added to the GRASS library?

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

--Darrell

--
Michael Shapiro shapiro@zorro.cecer.army.mil
U.S. Army CERL (217) 373-7277
P.O. Box 9005
Champaign, Ill. 61826-9005

"Net.Noise owner" (news@max.cecer.army.mil) writes on 7 Jul 93:

isn't the right way to do it. There is no formula in GRASS presently
neither for spheres or ellipsoids. Does someone have a reference for

thanks Michael - this is the answer I was looking for (not exactly,
because I thought that it would be possible with some of the latest
modifications, but ...).

Also thanks to Jerry for burning so many cycles composing followups.

Michael Shapiro shapiro@zorro.cecer.army.mil

I'll be sure to leave bread crumbs for anyone who makes later
modifications.

--Darrell

On Wed, 7 Jul 1993, Net.Noise owner wrote:

In <9307070737.AA12583@bushland.ecn.purdue.edu> mccauley@ecn.purdue.edu (Darrell McCauley) writes:

>Trying to make my programs more lat-long friendly...
>
> d = G_distance (x1, y1, x2, y2);
>
> angle = 180.0 / 3.14159
> * acos ((G_distance(x1,y1,x2,y1)+G_distance(x1,y2,x2,y2)) /2.0
> / d);

What I think you want is an azimuth calculation and I'm sure this
isn't the right way to do it. There is no formula in GRASS presently
neither for spheres or ellipsoids. Does someone have a reference for
this calculation so it can be coded and added to the GRASS library?
>Is this correct approach? Is there a library function that I am
>missing which would do what I want?

I wonder if I am going to muddle this more. :-()

I do believe that when I was writing the s.surf.krig code that
G_distance did indeed call a function that specified a sphere or
elleipse. You are looking for a spherical or elliptical geometric
function to calculate the distance over a curved surface arn't
you? I am sure these routines are already in GRASS, start looking
in G_distance and follow its calls, I ended up not using it
because I couldn't get it to work properly. s.surf.krig is
written using spherical geometry.

If this response is even close give me a buzz, if not SORRY.

chris