[GRASS-dev] calculating bearing

Is there a simple formula to calculate bearing if you have the beginning xy of a line and the ending xy of the line?

Michael


Michael Barton, Professor of Anthropology
School of Human Evolution & Social Change
Center for Social Dynamics & Complexity
Arizona State University

phone: 480-965-6213
fax: 480-965-7671
www: http://www.public.asu.edu/~cmbarton

Michael Barton wrote:

Is there a simple formula to calculate bearing if you have the
beginning xy of a line and the ending xy of the line?

trig: angle = atan(y/x) [or atan2()]

see Glynn's warnings in the archives about that going undefined at places.

see also:
  g.manual m.cogo

it gets ugly with lat/lon great circle calculations as the bearing isn't
steady. (but there are map projections that help with that)

I've got some matlab functions for doing this if m.cogo isn't your cup
of tea.

Hamish

On Wed, May 16, 2007 at 08:40:06PM +1200, Hamish wrote:

Michael Barton wrote:
>
> Is there a simple formula to calculate bearing if you have the
> beginning xy of a line and the ending xy of the line?

trig: angle = atan(y/x) [or atan2()]

see Glynn's warnings in the archives about that going undefined at places.

see also:
  g.manual m.cogo

it gets ugly with lat/lon great circle calculations as the bearing isn't
steady. (but there are map projections that help with that)

I've got some matlab functions for doing this if m.cogo isn't your cup
of tea.

Would you mind to add more examples to the m.cogo page?
At least I don't really understand how to use it.

Markus

I'm doing a measure tool for wxgrass at the moment and realized that I have
the xy endpoints of each segment being passed to the MeasureDist method. If
there is an easy way to do so, it seems handy to add bearing to the output
along with segment length. Do you think that it is enough of a problem with
latlon regions that I shouldn't add it in?

Michael

On 5/16/07 1:40 AM, "Hamish" <hamish_nospam@yahoo.com> wrote:

Michael Barton wrote:

Is there a simple formula to calculate bearing if you have the
beginning xy of a line and the ending xy of the line?

trig: angle = atan(y/x) [or atan2()]

see Glynn's warnings in the archives about that going undefined at places.

see also:
  g.manual m.cogo

it gets ugly with lat/lon great circle calculations as the bearing isn't
steady. (but there are map projections that help with that)

I've got some matlab functions for doing this if m.cogo isn't your cup
of tea.

Hamish

__________________________________________
Michael Barton, Professor of Anthropology
School of Human Evolution & Social Change
Center for Social Dynamics & Complexity
Arizona State University

phone: 480-965-6213
fax: 480-965-7671
www: http://www.public.asu.edu/~cmbarton

Michael Barton wrote:

I'm doing a measure tool for wxgrass at the moment and realized that I
have the xy endpoints of each segment being passed to the MeasureDist
method. If there is an easy way to do so, it seems handy to add
bearing to the output along with segment length. Do you think that it
is enough of a problem with latlon regions that I shouldn't add it in?

just skip bearing output for lat/lon locations.

this seems like a great task for trying out the Python SWIG interface to
libgis rather than reimplement algorithms in the GUI code.

see lib/gis/distance.c
    lib/gis/geodist.c

Hamish

Michael:

> > Is there a simple formula to calculate bearing if you have the
> > beginning xy of a line and the ending xy of the line?

Hamish:

> see also:
> g.manual m.cogo

Markus:

Would you mind to add more examples to the m.cogo page?
At least I don't really understand how to use it.

I've never actually used it myself, sorry.

Hamish

Thanks. I've incorporated this into the measurement tool for wxgrass (for
non-latlon regions).

Michael

On 5/16/07 1:40 AM, "Hamish" <hamish_nospam@yahoo.com> wrote:

Michael Barton wrote:

Is there a simple formula to calculate bearing if you have the
beginning xy of a line and the ending xy of the line?

trig: angle = atan(y/x) [or atan2()]

see Glynn's warnings in the archives about that going undefined at places.

see also:
  g.manual m.cogo

it gets ugly with lat/lon great circle calculations as the bearing isn't
steady. (but there are map projections that help with that)

I've got some matlab functions for doing this if m.cogo isn't your cup
of tea.

Hamish

__________________________________________
Michael Barton, Professor of Anthropology
School of Human Evolution & Social Change
Center for Social Dynamics & Complexity
Arizona State University

phone: 480-965-6213
fax: 480-965-7671
www: http://www.public.asu.edu/~cmbarton