bonjour
je souhaite convertir un code java en VBA
puis-je avoir votre aide
Intersection of two paths given start points and bearings
This is a rather more complex calculation than most others on this page, but I've been asked for it a number of times. See below for the JavaScript.
Formula:
Code
d12 = 2.asin( √(sin²(Δlat/2) + cos(lat1).cos(lat2).sin²(Δlon/2)) )
φ1 = acos( sin(lat2) − sin(lat1).cos(d12) / sin(d12).cos(lat1) )
φ2 = acos( sin(lat1) − sin(lat2).cos(d12) / sin(d12).cos(lat2) )
if sin(lon2−lon1) > 0
θ12 = φ1, θ21 = 2.π − φ2
else
θ12 = 2.π − φ1, θ21 = φ2
α1 = (θ1 − θ12 + π) % 2.π − π
α2 = (θ21 − θ2 + π) % 2.π − π
α1 = |α1|
α2 = |α2|
α3 = acos( −cos(α1).cos(α2) + sin(α1).sin(α2).cos(d12) )
d13 = atan2( sin(d12).sin(α1).sin(α2), cos(α2)+cos(α1).cos(α3) )
lat3 = asin( sin(lat1).cos(d13) + cos(lat1).sin(d13).cos(θ1) )
Δlon = atan2( sin(θ1).sin(d13).cos(lat1), cos(d13)−sin(lat1).sin(lat3) )
lon3 = (lon1−Δlon+π) % 2.π − π
where
at1, lon1, θ1 : 1st point & bearing
lat2, lon2, θ2 : 2nd point & bearing
lat3, lon3 : intersection point
% = mod, | | = abs
note – if sin(α1)=0 and sin(α2)=0: infinite solutions
if sin(α1).sin(α2) < 0: ambiguous solution
this formulation is not always well-conditioned for meridional or equatorial lines
merci a vous