九色国产,午夜在线视频,新黄色网址,九九色综合,天天做夜夜做久久做狠狠,天天躁夜夜躁狠狠躁2021a,久久不卡一区二区三区

打開APP
userphoto
未登錄

開通VIP,暢享免費電子書等14項超值服

開通VIP
兩點經(jīng)緯度計算方位角(VBA代碼)
Sub Sample_Point2Azimuth()
    
    Dim lon_A As Double, lat_A As Double, lon_B As Double, lat_B As Double
    
    FinalRow_B = Sheets('程序示例').Cells(Rows.Count, 2).End(xlUp).Row
    Sheets('程序示例').Range('D2', 'D' & FinalRow_B).ClearContents
    
    For i = 2 To FinalRow_B
        lon_A = Sheets('程序示例').Cells(1, 'G').Value
        lat_A = Sheets('程序示例').Cells(1, 'H').Value
        lon_B = Sheets('程序示例').Cells(i, 'B').Value
        lat_B = Sheets('程序示例').Cells(i, 'C').Value
        Sheets('程序示例').Cells(i, 'D').Value = Point2Azimuth(lon_A, lat_A, lon_B, lat_B)
    Next i
    
End Sub
Function Point2Azimuth(lon_A As Double, lat_A As Double, lon_B As Double, lat_B As Double)
    
    '其中A為原始點,B為目標點。
    Dim PI As Double
    PI = 3.14159265358979
    If lon_A > 0 And lon_A < 360 And lat_A > 0 And lat_A < 360 Then
        If lon_B > 0 And lon_B < 360 And lat_B > 0 And lat_B < 360 Then
        '判斷目標點在原始點的第幾象限,或者正東南西北
            If lat_B > lat_A Then
                If lon_B > lon_A Then
                    '東北方
                        Point2Azimuth = 0
                        lat_A = lat_A * PI / 180
                        lon_A = lon_A * PI / 180
                        lat_B = lat_B * PI / 180
                        lon_B = lon_B * PI / 180
                        
                        Point2Azimuth = Sin(lat_A) * Sin(lat_B) + Cos(lat_A) * Cos(lat_B) * Cos(lon_B - lon_A)
                        Point2Azimuth = Sqr(1 - Point2Azimuth * Point2Azimuth)
                        Point2Azimuth = Cos(lat_B) * Sin(lon_B - lon_A) / Point2Azimuth
                        Point2Azimuth = Application.Asin(Point2Azimuth) * 180 / PI
                ElseIf lon_B < lon_A Then
                    '西北方
                        Point2Azimuth = 0
                        lat_A = lat_A * PI / 180
                        lon_A = lon_A * PI / 180
                        lat_B = lat_B * PI / 180
                        lon_B = lon_B * PI / 180
                        
                        Point2Azimuth = Sin(lat_A) * Sin(lat_B) + Cos(lat_A) * Cos(lat_B) * Cos(lon_B - lon_A)
                        Point2Azimuth = Sqr(1 - Point2Azimuth * Point2Azimuth)
                        Point2Azimuth = Cos(lat_B) * Sin(lon_B - lon_A) / Point2Azimuth
                        Point2Azimuth = Application.Asin(Point2Azimuth) * 180 / PI
                        Point2Azimuth = Point2Azimuth + 360
                ElseIf lon_B = lon_A Then
                    '正北方
                    Point2Azimuth = 0
                Else
                    'Nothing
                End If
            ElseIf lat_B < lat_A Then
                If lon_B > lon_A Then
                    '東南方
                        Point2Azimuth = 0
                        lat_A = lat_A * PI / 180
                        lon_A = lon_A * PI / 180
                        lat_B = lat_B * PI / 180
                        lon_B = lon_B * PI / 180
                        
                        Point2Azimuth = Sin(lat_A) * Sin(lat_B) + Cos(lat_A) * Cos(lat_B) * Cos(lon_B - lon_A)
                        Point2Azimuth = Sqr(1 - Point2Azimuth * Point2Azimuth)
                        Point2Azimuth = Cos(lat_B) * Sin(lon_B - lon_A) / Point2Azimuth
                        Point2Azimuth = Application.Asin(Point2Azimuth) * 180 / PI
                        Point2Azimuth = Point2Azimuth + 90
                ElseIf lon_B < lon_A Then
                    '西南方
                        Point2Azimuth = 0
                        lat_A = lat_A * PI / 180
                        lon_A = lon_A * PI / 180
                        lat_B = lat_B * PI / 180
                        lon_B = lon_B * PI / 180
                        
                        Point2Azimuth = Sin(lat_A) * Sin(lat_B) + Cos(lat_A) * Cos(lat_B) * Cos(lon_B - lon_A)
                        Point2Azimuth = Sqr(1 - Point2Azimuth * Point2Azimuth)
                        Point2Azimuth = Cos(lat_B) * Sin(lon_B - lon_A) / Point2Azimuth
                        Point2Azimuth = Application.Asin(Point2Azimuth) * 180 / PI
                        Point2Azimuth = Point2Azimuth + 270
                ElseIf lon_B = lon_A Then
                    '正南方
                    Point2Azimuth = 180
                Else
                    'Nothing
                End If
            ElseIf lat_B = lat_A Then
                If lon_B > lon_A Then
                    '正東方
                    Point2Azimuth = 90
                ElseIf lon_B < lon_A Then
                    '正西方
                    Point2Azimuth = 270
                ElseIf lon_B = lon_A Then
                    '原始點
                    Point2Azimuth = -3
                Else
                    'Nothing
                End If
            End If
        
        Else
            '目標點B經(jīng)緯度無效
            Point2Azimuth = -2
        End If
    Else
        '原始點A經(jīng)緯度無效
        Point2Azimuth = -1
                
    End If
       
End Function
本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊舉報。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
IOS根據(jù)兩個經(jīng)緯度計算相距距離
WGS84,GCJ02, BD09坐標轉(zhuǎn)換 (轉(zhuǎn))
地理坐標點距離近似計算
根據(jù)兩點經(jīng)緯度計算距離
C#實現(xiàn)地圖坐標系的轉(zhuǎn)換(WGS-84、GCJ-02、BD-09)
地球坐標,火星坐標,百度坐標轉(zhuǎn)換
更多類似文章 >>
生活服務(wù)
熱點新聞
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點擊這里聯(lián)系客服!

聯(lián)系客服