1

I'm working on indoor navigation application using the wifi trilateration ,

I have 3 access points I get the lat&lng for each

            //1 
    double Lat0 = 26.0475994;
    double Lng0 = 50.5101893;

            //2 

    double Lat1 = 26.0474428;
    double Lng1 = 50.5096745;

        //3
    double Lat2 = 26.0477956;
    double Lng2 = 50.5097067;

I need to convert each lat & lng to its x,y,z coordinates , can any one help me with this formula ? I saw a previous post here but I'm not getting correct results

plus if I get x,y is ot possible to convert it to it's lat & lng ?

thanks

Community
  • 1
  • 1

1 Answers1

0

To convert from latitude and longitude to x and y coordinates you can use the following formula:

x = (radius of earth) * cos(latitude) * cos(longitude) //radians 
y = (radius of earth) * cos(latitude) * sin(longitude)

To convert back:

lat  = asin(y / (radius of earth)) // degrees
nong = atan(2 * x / y)             // degrees
ByteHamster
  • 4,884
  • 9
  • 38
  • 53