Function ProjecStéréo(ByVal Lat As Double, ByVal Lon As Double, _
Optional ByVal LatRéf = 46.875, Optional ByVal LonRéf As Double = 1.625) As Variant
Dim XProj As Double, YProj As Double
CalcProjecStéréo XProj, YProj, Lat, Lon, LatRéf, LonRéf
ProjecStéréo = Array(XProj, YProj)
End Function
Sub CalcProjecStéréo(XProj As Double, YProj As Double, ByVal Lat As Double, ByVal Lon As Double, _
Optional ByVal LatRéf As Double = 46.875, Optional ByVal LonRéf As Double = 1.625)
Dim CosLatRéf As Double, SinLatRéf As Double, X As Double, Y As Double, Z As Double, Zr As Double, Éch As Double
Lat = Rad(Lat): Lon = Rad(Lon - LonRéf): LatRéf = Rad(LatRéf): SinLatRéf = Sin(LatRéf): CosLatRéf = Cos(LatRéf)
Y = Sin(Lat): Z = Cos(Lat): X = Sin(Lon) * Z: Z = Cos(Lon) * Z
Zr = Z * CosLatRéf + Y * SinLatRéf: Y = Y * CosLatRéf - Z * SinLatRéf
Éch = 2 / (Zr + 1) * 6368: XProj = X * Éch: YProj = Y * Éch
End Sub
Function Dist(ByVal Lat1 As Double, ByVal Lon1 As Double, ByVal Lat2 As Double, ByVal Lon2 As Double) As Double
Lat1 = Rad(Lat1): Lon1 = Rad(Lon1): Lat2 = Rad(Lat2): Lon2 = Rad(Lon2)
Dist = ACos(Sin(Lat1) * Sin(Lat2) + Cos(Lat1) * Cos(Lat2) * Cos(Lon1 - Lon2)) * 6371
End Function
Private Function Rad(ByVal Deg As Double) As Double
Const K = 14964008 / 857374503: Rad = Deg * K
End Function
Private Function ACos(ByVal X As Double) As Double
On Error Resume Next
Const Pi÷2 = 122925461 / 78256779: ACos = Atn(-X / Sqr(1 - X * X)) + Pi÷2
End Function