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>

[551 byte] By [lvguangchuana] at [2007-10-2 16:58:46]
# 1

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.

jschella at 2007-7-13 18:11:53 > top of Java-index,Other Topics,Algorithms...
# 2
Thanks Jschell,Howerver, I can not catch up what formual which I will use.Would you minding explain more detail for me?Thanks
lvguangchuana at 2007-7-13 18:11:53 > top of Java-index,Other Topics,Algorithms...
# 3
> Would you minding explain more detail for me?> And which one of the above algorithms are you interested in?
jschella at 2007-7-13 18:11:53 > top of Java-index,Other Topics,Algorithms...
# 4
Sorry,The simple oneThanks
lvguangchuana at 2007-7-13 18:11:53 > top of Java-index,Other Topics,Algorithms...
# 5

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]

jschella at 2007-7-13 18:11:53 > top of Java-index,Other Topics,Algorithms...