HOW TO CHECK THE HEADING OR DIRECTION
hi,ALL
If I have two given coordinates(on real earth).
The distance between these two coordiantes is short(<less than 500 meters).
I want to cacluates the heading.
what I means:
There are A points(-79.345415,43.744741) and B points(-79.345104,43.743497).
If Starts A points to B Points, What is the heading or direction according to north pole.
If Starts B to B, what is the heading or directior according to north pole.
The Heading means is the same as GPS Heading.
Thanks very much>
If the precision isn't fixed you are going to need to deal with that.
Presuming it is.
Given x1,y1 and x2, y2. x1,y1 is the starting point.
Simplistic.
- Compute x1 and x2 to yield -1, 0, 1
- Compute y1 and y2 to yield -1, 0, 1
- Use a two dimensional array with the values in both direction (-1, 0, 1) and then look up the direction in it
Complex.
- The two points represent a directional vector.
- That vector occupies a position in a circle
- Compute the angle in the circle to determine which way it is pointing.
For something more specific more details as to what you think the result should be must be provided.
Pseudo code representation.
> Simplistic.
> - Compute x1 and x2 to yield -1, 0, 1
So but the following in a method.
if (x1 < x2) return -1
else if (x1 == x2) return 0
else return -1
> - Compute y1 and y2 to yield -1, 0, 1
> - Use a two dimensional array with the values in both
> direction (-1, 0, 1) and then look up the direction
> in it
>
offsetx = <your method>
offsety = <your method>
String[][] array = ....
String direction = array[offsetx + 1][offsety+1]