GPS coordinates turn ECEF Earth coordinates

Source: Internet
Author: User

#include "stdafx.h"

#include <math.h>


#define PI 3.14159

/*

This program is mainly a function to convert from GPS coordinates to three-dimensional coordinates of the Earth.

*/


void Gps2ecef (double latitude, double longitude, double height, double &x, double &y, double &z)

{

Double A = 6378137;

Double b = 6356752.314245;

Double E = (a*a-b*b)/(A*A);


Double coslat = cos (latitude*pi/180);

Double Sinlat = sin (latitude*pi/180);

Double coslong = cos (longitude*pi/180);

Double Sinlong = sin (longitude*pi/180);


Double N = A/(sqrt (1-e*sinlat*sinlat));

Double NH = N + height;


X = NH * Coslat * coslong;

Y = NH * Coslat * sinlong;

Z = (b*b*n/(a*a) + height) * Sinlat;

}


int _tmain (int argc, _tchar* argv[])

{

Double latitude = 22.4331034196;

Double longitude = 113.3957986107;

Double h = 23.3;

Double XX = 0.0;

Double YY = 0.0;

Double ZZ = 0.0;

GPS2ECEF (latitude, longitude, H, XX, YY, ZZ);

return 0;

}


GPS coordinates turn ECEF Earth coordinates

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.