2

I'm building an Android AR-App (yes, another one), but I'm more interested in understanding the math behind it than using frameworks (knowing this and this).

Given to locations (lat1,long1) and (lat2,long2) I'm searching for the direction vector (x,y,z) from Location1 to Location2.

Using this Site I can calculate the distance and (inital) bearing between Location1 and Location2.

Now I develop two approaches (neglecting altitude)

x = distHaversine(lat1,long1,lat1,long2);
z = distHaversine(lat1,long1,lat2,long1);
if (lat1 < lat2)
  z *= -1;
if (long1 > long2)
  x *= -1;

and

distance = distHaversine(lat1,long1,lat2,long2);
angle = 90.0-bearing(lat1,long1,lat2,long2);
x = cos(angle)*distance;
z = sin(angle)*distance;

but now I'm stucked and irritated... shouldnt' the result be the same? Where do I find my error in reasoning? How do I calcuate the direction vector (or rather: Why didnt work my second approach?)?

Thanks for your help

Community
  • 1
  • 1
Hackbard_C
  • 121
  • 1

0 Answers0