Converting grid ref to heading/bearing
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Converting grid ref to heading/bearing

  1. #1
    Join Date
    Feb 2013
    Posts
    4

    Converting grid ref to heading/bearing

    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

  2. #2
    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    3,642

    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.
    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are, by
    definition, not smart enough to debug it.
    - Brian W. Kernighan

    To enhance your chance's of getting an answer be sure to read
    http://www.codeguru.com/forum/announ...nouncementid=6
    and http://www.codeguru.com/forum/showthread.php?t=366302 before posting

    Refresh your memory on formatting tags here
    http://www.codeguru.com/forum/misc.php?do=bbcode

    Get your free MS compiler here
    http://www.microsoft.com/visualstudio/eng/downloads

  3. #3
    Join Date
    Feb 2013
    Posts
    4

    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

  4. #4
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,594

    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
    I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.

    This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.

  5. #5
    Join Date
    Feb 2013
    Posts
    4

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center