# Converting grid ref to heading/bearing

• February 28th, 2013, 01:36 PM
feralipod
Hi, I'm new, I hope this is the right forum for this!

I am trying to re-create a model I wrote years ago, (lost the source code), One requirement is an algorythm that will calculate the angle, between two points on a plane, from the x,y coordinates of the start and finish; I will be writing in Pascal or Object pascal, but I am NOT asking for code, just the algorythm. However, if you do NOT have the design but do have code, I will be happy to look at that

Thanks,
Jim
• February 28th, 2013, 02:24 PM
S_M_A
Re: Converting grid ref to heading/bearing
I think you have to provide some additional information. Two points make a single line or at least can do so.
• February 28th, 2013, 04:08 PM
feralipod
Re: Converting grid ref to heading/bearing
Thanks s_m_a ??

You're right! The bearing I am calculating is between the line specified by the two points and the X axis West to East. That axis being zero degrees.

This is dictated by the progarming language that I favour where the 0 / (nought) axis is horizontal, not vertical like we use in normal navigation.

I hope that is clear. Sorry for the obvious omission.

I fear I need a spell checker on this interface!

Thanks and best wishes, Jim
• February 28th, 2013, 09:01 PM
Eri523
Re: Converting grid ref to heading/bearing
Sounds like the good ol' conversion from cartesian to polar coordinates (which is independent from any programming language anyway).

HTH
• March 1st, 2013, 02:53 AM
feralipod
Re: Converting grid ref to heading/bearing
Thanks eri523,

I had not come across te cartesian to polor convertion thing but it is allmost exactly what I am doing now with one great difference.

I am NOT calculating the angle as if the start point is at 0.0. If I do that and simple translate the start x,y, it makes my method far neater. Thanks for that.

I think there is another problem with the code which I have not discovered the cause of, I'll be back!

feralipod