大地坐标系(WGS84)转空间直角坐标系(笛卡尔坐标系XYZ)

以Unity为例
float[] get_coordinate( float lat, float lon,float H1)
{
//H指的就是距离海平面的大地高,N+H也就是当前测点与地心的矢径
float f = 1f / 298.257223563f;
float b = 6378245f * (1 - f);
float e = Mathf.Sqrt(6378245f * 6378245f - b * b) / 6378245f;
float N = 6378245f / Mathf.Sqrt(1 - e * e * Mathf.Sin(lat * Mathf.PI / 180) * Mathf.Sin(lat * Mathf.PI / 180));
float WGS84_X = (N + H1) * Mathf.Cos(lat * Mathf.PI / 180) * Mathf.Cos(lon * Mathf.PI / 180);
float WGS84_Y = (N + H1) * Mathf.Cos(lat * Mathf.PI / 180) * Mathf.Sin(lon * Mathf.PI / 180);
float WGS84_Z = (N * (1 - (e * e)) + H1) * Mathf.Sin(lat * Mathf.PI / 180);
float[] res = { WGS84_X, WGS84_Y, WGS84_Z };
return res;
}
for (int i = -90; i