include
include
define PI 3.14159265
using namespace std;
struct Point3D{
double x;
double y;
double z;
};
Point3D convertToCartesian(double latitude, double longitude, double altitude){
Point3D point;
double radius = 6378137.0+altitude; // 地球半径+高度
longitude = longitude * PI / 180.0;
latitude = latitude * PI / 180.0;
point.x = radius * cos(latitude) * cos(longitude);
point.y = radius * cos(latitude) * sin(longitude);
point.z = radius * sin(latitude);
return point;
}
int main() {
double latitude, longitude, altitude;
cout << "输入经度:";
cin >> longitude;
cout << "输入纬度:";
cin >> latitude;
cout << "输入高度(m):";
cin >> altitude;
Point3D point = convertToCartesian(latitude, longitude, altitude);
cout << "笛卡尔坐标系中的坐标为:" << endl;
cout << "X: " << point.x << endl;
cout << "Y: " << point.y << endl;
cout << "Z: " << point.z << endl;
return 0;
}