Hi
Zephyr,
Thanks for answer! What do you exactly mean with (north being at 0)?
My Problem is;
if my way horizantal like this bearing from X to x2 => 90 and from X to x3 => 270. I see my arrow in left and right not in front of my car. (my arrow in the wrong place)
--------------------------------------------
x1 X x2
--------------------------------------------
if my way; X to X1 => 0 and X to X2 => 180. And my arrow in the right place, in front or back of my car.
| x1 |
| |
| X |
| |
| x2 |
| |
Do you have any advice? Thanks a lot!
Gülsün
My code calculating bearing in java
double dLon = Math.toRadians(Double.valueOf(point2.getLon())-Double.valueOf(point1.getLon()));
double y = Math.sin(dLon) * Math.cos(Double.valueOf(point2.getLat()));
double x = Math.cos(Double.valueOf(point1.getLat()))*Math.sin(Double.valueOf(point2.getLat())) -
Math.sin(Double.valueOf(point1.getLat()))*Math.cos(Double.valueOf(point2.getLat()))*Math.cos(Double.valueOf(dLon));
double brng = Math.atan2(y, x);
return (Math.toDegrees(brng));