[英]How to interpolate ECEF coordinates on an WGS84 ellipsoid
Is there a direct method (not involving converting the coordinates to lat/lon) to interpolate between 2 ECEF coordinates (xyz) in order for the interpolated point to be located on the WGS84 ellispoid. 是否有直接方法(不涉及将坐标转换为经度/纬度)在2个ECEF坐标(xyz)之间进行插值,以使插值点位于WGS84椭球上。 The original 2 points are computed from geodetic coordinates. 原始的2个点是根据大地坐标计算的。
Interpolating on a sphere seem obvious but I can't seem to derive a solution for the ellipsoid. 在球体上进行插值似乎很明显,但我似乎无法得出椭球的解。
Thank you in advance. 先感谢您。
Let assume you got 2 points p0(x,y,z)
and p1(x,y,z)
and want to interpolate some p(t)
where t=<0.0,1.0>
between the two. 假设您有2个点p0(x,y,z)
和p1(x,y,z)
并希望在其中t=<0.0,1.0>
位置插值一些p(t)
。
you can: 您可以:
rescale your ellipsoid to sphere 将您的椭球重新缩放为球形
simply like this: 就像这样:
const double mz=6378137.00000/6356752.31414; // [m] equatoreal/polar radius of Earth p0.z*=mz; p1.z*=mz;
now you got Cartesian coordinates refering to spherical Earth model. 现在您获得了参照球面地球模型的笛卡尔坐标。
interpolate 插
simple linear interpolation would do 简单的线性插值就可以
p(t) = p0+(p1-p0)*t
but of coarse you also need to normalize to earth curvature so: 但粗略的还需要归一化为地球曲率,因此:
r0 = |p0| r1 = |p1| p(t) = p0+(p1-p0)*t r(t) = r0+(r1-r0)*t p(t)*=r/|p(t)|
where |p0|
|p0|
means length of vector p0
. 表示向量p0
长度。
rescale back to ellipsoid 重新缩放回椭球
by dividing with the same value 用相同的值除
p(t).z/=mz
This is simple and cheap but the interpolated path will not have linear time scale. 这既简单又便宜,但是内插路径不会具有线性时间标度。
Here C++ example: 这里是C ++示例:
void XYZ_interpolate(double *pt,double *p0,double *p1,double t)
{
const double mz=6378137.00000/6356752.31414;
const double _mz=6356752.31414/6378137.00000;
double p[3],r,r0,r1;
// compute spherical radiuses of input points
r0=sqrt((p0[0]*p0[0])+(p0[1]*p0[1])+(p0[2]*p0[2]*mz*mz));
r1=sqrt((p1[0]*p1[0])+(p1[1]*p1[1])+(p1[2]*p1[2]*mz*mz));
// linear interpolation
r = r0 +(r1 -r0 )*t;
p[0]= p0[0]+(p1[0]-p0[0])*t;
p[1]= p0[1]+(p1[1]-p0[1])*t;
p[2]=(p0[2]+(p1[2]-p0[2])*t)*mz;
// correct radius and rescale back
r/=sqrt((p[0]*p[0])+(p[1]*p[1])+(p[2]*p[2]));
pt[0]=p[0]*r;
pt[1]=p[1]*r;
pt[2]=p[2]*r*_mz;
}
And preview: 并预览:
Yellow squares are the used p0,p1
Cartesian coordinates, the White curve is the interpolated path where t=<0.0,1.0>
... 黄色正方形是使用的p0,p1
直角坐标,白色曲线是t=<0.0,1.0>
...的插补路径。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.