繁体   English   中英

寻找大圆交的第一点

[英]Finding the first point of great circle Intersection

我有一个一直在试图解决的问题,我无法给出答案。 我已经在Matlab中编写了一个函数,给定两个纬度/经度点和两个方位角,将返回交点的两个大圆点。

但是,我真正需要的是沿着两个初始标题的第一个大圆交点。 即,如果两架飞机在经纬点1和经纬点2开始,并且初始轴承分别为方位1和方位2,那么这两个大圆交点中的哪一个是它们遇到的第一个? 有很多解决方案(使用强效碱)可以使我接近两点,但实际上我并不关心哪个离我更近,我关心的是在给定的特定起点和标题下我会首先遇到哪个。 在许多情况下,两个交叉点中的最接近点实际上是遇到的第二个交叉点。

现在,我意识到我可以使用很多条件语句来处理不同的情况,但是我认为必须有一种方法来处理我所有交叉产品的顺序(下面给出的功能代码),但是我根本无法提出正确的解决方案! 我还应该提到,此函数将在大型计算密集型模型中使用,因此我认为此问题的解决方案必须相当优雅/快速。 谁能帮助我解决这个问题?

以下不是我的功能代码(我无法在此处列出),而是我的功能所基于的伪代码:

 %Given inputs of lat1,lon1,Bearing1,lat2,lon2,Bearing2:
%Calculate arbitrary secondary point along same initial bearing from first
%point
dAngle = 45;
lat3 = asind( sind(lat1)*cosd(dAngle) + cosd(lat1)*sind(dAngle)*cosd(Bearing1));
lon3 = lon1 + atan2( sind(Bearing1)*sind(dAngle)*cosd(lat1), cosd(dAngle)-sind(lat1)*sind(lat3) )*180/pi;
lat4 = asind( sind(lat2)*cosd(dAngle) + cosd(lat2)*sind(dAngle)*cosd(Bearing2));
lon4 = lon2 + atan2( sind(Bearing2)*sind(dAngle)*cosd(lat2), cosd(dAngle)-sind(lat2)*sind(lat4) )*180/pi;


%% Calculate unit vectors
% We now have two points defining each of the two great circles.  We need
% to calculate unit vectors from the center of the Earth to each of these
% points
[Uvec1(1),Uvec1(2),Uvec1(3)] = sph2cart(lon1*pi/180,lat1*pi/180,1);
[Uvec2(1),Uvec2(2),Uvec2(3)] = sph2cart(lon2*pi/180,lat2*pi/180,1);
[Uvec3(1),Uvec3(2),Uvec3(3)] = sph2cart(lon3*pi/180,lat3*pi/180,1);
[Uvec4(1),Uvec4(2),Uvec4(3)] = sph2cart(lon4*pi/180,lat4*pi/180,1);


%% Cross product
%Need to calculate the the "plane normals" for each of the two great
%circles
N1 = cross(Uvec1,Uvec3);
N2 = cross(Uvec2,Uvec4);


%% Plane of intersecting line
%With two plane normals, the cross prodcut defines their intersecting line
L = cross(N1,N2);
L = L./norm(L);
L2 = -L;
L2 = L2./norm(L2);


%% Convert normalized intersection line to geodetic coordinates
[lonRad,latRad,~]=cart2sph(L(1),L(2),L(3));
lonDeg = lonRad*180/pi;
latDeg = latRad*180/pi;
[lonRad,latRad,~]=cart2sph(L2(1),L2(2),L2(3));
lonDeg2 = lonRad*180/pi;
latDeg2 = latRad*180/pi;

更新:Mathworks论坛上的一位用户指出:

实际上,它们各自可能达到不同的观点。 我可能误解了这个问题,但是您的措辞暗示这两个轨迹将趋向同一点,这是不正确的。 如果您将第一个点成像在一个交点之后,而第二个点成像在另一个交点之后,则您遇到的情况是,每个“平面”都将朝着起点处最接近另一个平面的交点行进。

我没有考虑这个。 实际上,每个平面最有可能先与一个不同的大圆相交相交。 这使事情变得更加复杂...

大概您有一个平面方向的速度矢量(您要寻找第一个交点的方向-“地球表面的轴承矢量”)。 您实际上并没有指定。 让我们称之为v

您还具有两个点P1P2的笛卡尔坐标,以及平面的初始位置P0 假定每个都已经在单位球体上(长度= 1)。

现在我们想知道哪个是到P1或P2的较短距离,所以我们需要知道角度“从法向矢量的方向看”。 为此,我们既需要sin ,也需要cos -然后我们可以使用atan2找到角度。 我们从叉积获得sin (记住所有向量都已归一化),从点积获得cos 为了得到“从正确方向看”的sin ,我们将点积与法向矢量相乘。

这是一段将所有内容组合在一起的代码-我对点和方向矢量使用非常简单的坐标,因此我可以在脑海中确认这给出了正确的答案:

% sample points of P0...P2 and v
P0 = [1 0 0];
P1 = [0 1 0];
P2 = [0 -1 0];
v = [0 1 0];
% compute the "start direction normal":
n0 = cross(P0, v);
n0 = n0 / norm( n0 );  % unit vector 

% compute cross and dot products:
cr01 = cross(P0, P1);
cr02 = cross(P0, P2);
cos01 = dot(P0, P1);
cos02 = dot(P0, P2);

% to get sin with correct sign, take dot product with direction normal:
sin01 = dot(cr01, n0);
sin02 = dot(cr02, n0);
% note - since P0 P1 and P2 are all in the same plane
% cr02 and cr02 are either pointing in the same direction as n0
% or the opposite direction. In the latter case we get a sign flip for the sin
% in the former case this does nothing

% Now get the angle, mapped from 0 to 2 pi:
ang1 = mod(atan2(sin01, cos01), 2*pi);
ang2 = mod(atan2(sin02, cos02), 2*pi);

if( ang1 < ang2 ) 
  fprintf(1,'point 1 is reached first\n');
  % point 1 is the first one reached
else
  fprintf(1,'point 2 is reached first\n');
  % point 2 is the first
end

当您更改速度矢量的方向(指向P2而不是P1)时,程序正确地告诉您“首先到达点2”。

让我知道这是否适合您!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM