我搜索得很远,但还没有找到合适的答案来解决这个问题.给定球体上的两条线,每条线由它们的起点和终点定义,确定它们是否以及它们相交的位置.我发现这个网站(http://mathforum.org/library/drmath/view/62205.html)运行了两个大圆的交叉点的良好算法,虽然我坚持确定是否给定点位于大圆的有限部分.
我发现有几个网站声称他们已经实现了这个,包括这里和stackexchange上的一些问题,但它们似乎总是回到两个大圆圈的交叉点.
我写的python类如下,似乎几乎可以工作:
class Geodesic(Boundary):
def _SecondaryInitialization(self):
self.theta_1 = self.point1.theta
self.theta_2 = self.point2.theta
self.phi_1 = self.point1.phi
self.phi_2 = self.point2.phi
sines = math.sin(self.phi_1) * math.sin(self.phi_2)
cosines = math.cos(self.phi_1) * math.cos(self.phi_2)
self.d = math.acos(sines - cosines * math.cos(self.theta_2 - self.theta_1))
self.x_1 = math.cos(self.theta_1) * math.cos(self.phi_1)
self.x_2 = math.cos(self.theta_2) * math.cos(self.phi_2)
self.y_1 = math.sin(self.theta_1) * math.cos(self.phi_1)
self.y_2 = math.sin(self.theta_2) * math.cos(self.phi_2)
self.z_1 = math.sin(self.phi_1)
self.z_2 = math.sin(self.phi_2)
self.theta_wraps = (self.theta_2 - self.theta_1 > PI)
self.phi_wraps = ((self.phi_1 < self.GetParametrizedCoords(0.01).phi and
self.phi_2 …Run Code Online (Sandbox Code Playgroud)