math - 在给定起始坐标、范围、方位角和仰角的情况下获取 ECEF XYZ

标签 math coordinates geospatial

我在查找有关将 RAE 转换为 XYZ 的任何内容时遇到问题。

如果我在 WGS84 椭球体上,比如位置 -742507、-5462738、3196706,我检测到一个距离为 30 公里、方位角为 310 度、仰角为 18 度的物体,我如何将其转换为 ECEF XYZ坐标?

谢谢。

最佳答案

似乎没有直接的过程可以做到这一点。我发现的最佳方法是从 RAE 坐标转换为 SEZ 坐标,然后从 SEZ 坐标转换为 ECR 坐标。这是我修改为 C++ 以实现此目的的一些 C# 代码:

void main() {
    // NOTE: distances are in meters, while angles are in degrees
    double siteECR[] = { -763997.48, -5458565.87, 3196706.0 };
    double objRAE[]  = { 30000.0, 310.0, 18.0 };
    double objECR[]  = { 0.0, 0.0, 0.0 };

    // Should return ~[-764142.7629, -5458517.683, 3217218.18] in objECR
    RAEtoECR(siteECR, objRAE, objECR);
}

/************************************************************************************************************************/
/*  Converts a Range, Azimuth, Elevation location to a Latitude, Longitude, Altitude location         */
/*  siteLLA - array holding the Latitude, Longitude, and Altitude of the site location in degrees and meters      */
/*  rae     - array holding the Range, Azimuth, and Elevation, in degrees, of the object viewed from the site location  */
/*  objECR  - destination array to hold the ECR X, Y, Z location in meters             */
/************************************************************************************************************************/
void RAEtoECR(double siteECR[], double rae[], double objECR[]) {
    double tempSEZ[] = { 0.0, 0.0, 0.0 };
    double siteLLA[] = { 0.0, 0.0, 0.0 };

    ECRtoLLA(siteECR, siteLLA);
    RAEtoSEZ(siteLLA, objRAE, tempSEZ);
    SEZtoECR(siteLLA, tempSEZ, objECR);
}

/************************************************************************************************************************/
/*  Converts a Range, Azimuth, Elevation location to a South, East, Zenith location          */
/*  siteLLA - array holding the Latitude, Longitude, and Altitude of the site location in degrees and meters   */
/*  rae     - array holding the Range, Azimuth, and Elevation, in degrees, of the object viewed from the site location  */
/*  sez     - destination array to hold the South, East, and Zenith coordinates of the object being viewed in meters */
/************************************************************************************************************************/
void RAEtoSEZ(double siteLLA[], double rae[], double sez[]) {
    double range, azimuth, elevation;
    range   = rae[0];
    azimuth   = rae[1];
    elevation = rae[2];

    // Compute needed math
    double slat = sin(Deg2Rad(siteLLA[0]));
    double slon = sin(Deg2Rad(siteLLA[1]));
    double clat = cos(Deg2Rad(siteLLA[0]));
    double clon = cos(Deg2Rad(siteLLA[1]));

    // Convert to radians
    azimuth   = DEG2RAD(azimuth);
    elevation = DEG2RAD(elevation);

    // Convert
    sez[0] = -range * cos(elevation) * cos(azimuth);
    sez[1] =  range * cos(elevation) * sin(azimuth);
    sez[2] =  range * sin(elevation);
}

/************************************************************************************************************************/
/*  Converts a South, East, Zenith location to an ECR X, Y, Z location              */
/*  siteLLA - array holding the Latitude, Longitude, and Altitude of the site location in degrees and meters      */
/*  sez     - array holding the South, East, and Zenith coordinates of the object being viewed in meters       */
/*  ecr     - destination array to hold the ECR X, Y, Z location in meters             */
/************************************************************************************************************************/
void SEZtoECR(double siteLLA[], double sez[], double ecr[]) {
    // Convert siteLLA to XYZ
    double[] siteXYZ = { 0.0, 0.0, 0.0 };
    LLAtoECR(siteLLA, siteXYZ);

    double south, east, zenith;
    south  = sez[0];
    east   = sez[1];
    zenith = sez[2];

    // Compute needed math
    double slat = sin(Deg2Rad(siteLLA[0]));
    double slon = sin(Deg2Rad(siteLLA[1]));
    double clat = cos(Deg2Rad(siteLLA[0]));
    double clon = cos(Deg2Rad(siteLLA[1]));

    // Convert
    ecr[0] = ( slat * clon * south) + (-slon * east) + (clat * clon * zenith) + siteXYZ[0];
    ecr[1] = ( slat * slon * south) + ( clon * east) + (clat * slon * zenith) + siteXYZ[1];
    ecr[2] = (-clat *        south) + ( slat * zenith) + siteXYZ[2];
}

关于math - 在给定起始坐标、范围、方位角和仰角的情况下获取 ECEF XYZ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3612749/

相关文章:

algorithm - 圆-圆交点

mysql - MySQL中concat字段的求和

python - Mosaic `st_buffer` 不返回点或多边形类型的几何图形

使用 lat 和 lng 小数搜索时,MySQL 查询返回 0 行

python - Scipy:如何将 KD-Tree 距离从查询转换为千米(Python/Pandas)

c++ - 为什么在使用模板递归检查数字是否为 3 的幂时需要特殊情况?

javascript - 如何检查一个数字是否位于数学级数的两个成员之间?例如A.P.、G.P.或任何其他进展

css - 如何使用剪辑路径创建 CSS 面包屑?

r - 我想使用 RNetLogo 包从 NetLogo 中提取坐标数据

Javascript ontouchstart/move/end - 得到奇怪的结果