spherical to 2D Cartesian
if the distance is not too far and not around pole singularities you can convert both line segment and line emitting from your point and perpendicular to your segment to spherical coordinates (if they are not already) and use the 2 angles as Cartesian space (ignoring radius).
compute intersection point
convert back to spherical
compute arclength between point and intersection
hard to say if you're using sphere or WGS84 or what ....
Cartesian 3D
lets have arc segment AB
, sphere of radius R
and center C
(ideally (0,0,0)
) and point P
then I see it like this:
find intersection point P'
between plane ABC
and its normal going through point P
in 3D Cartesian
project it back on sphere surface
For spherical surface is this easy as the projection means just to change the vector P'C
length to R
(if the sphere is centered around (0,0,0)
).
P'' = (R*(P'-C)/|P'-C|) + C
compute arclength between the 2 points |P-P''|
Also simple for spherical surface just compute the angle between vectors P-C
and P''-C
ang = acos(dot(P-C,P''-C)/(R*R)); // [radians]
and convert to arclength
d = ang*R; // [same Units as R]
lat
直到它适合 x,y,z
,你从球形投影开始,然后改变 lat
来最小化距离... - SpektreP,P',P''
是相同的(所以距离为零),因为 P
已经位于弧 AB
上。 P'
不需要位于 AB 线上...那就是那个错误。 - Spektredxt = asin( sin(δ13) ⋅ sin(θ13−θ12) ) ⋅ R
where
δ13 is (angular) distance from start point to third point
θ13 is (initial) bearing from start point to third point
θ12 is (initial) bearing from start point to end point
R is the earth’s radius
您可以使用给定页面上的公式计算所需的距离和方位角。
distance
a = sin²(Δφ/2) + cos φ1 ⋅ cos φ2 ⋅ sin²(Δλ/2)
c = 2 ⋅ atan2( √a, √(1−a) )
d = R ⋅ c
where
φ is latitude, λ is longitude, R is earth’s radius (mean radius = 6,371km);
bearing
θ = atan2( sin Δλ ⋅ cos φ2 , cos φ1 ⋅ sin φ2 − sin φ1 ⋅ cos φ2 ⋅ cos Δλ )
where
φ1,λ1 is the start point, φ2,λ2 the end point (Δλ is the difference in longitude)
请注意,将角度传递给三角函数时需要使用弧度制。