[英]manual input for (ddd mm.m) convert to radians or decimal degrees? In python
我正在編寫一個 Python 程序,用於使用六分儀觀測作為手動輸入的天文導航。 我使用 angular 表格 (ddd mm.m) 或度數、分鍾數和十進制分鍾數。 我正在使用數學庫在我的代碼中進行進一步的計算。 當在程序轉換中實現緯度/經度時,你會建議我做什么,將它們轉換為弧度還是十進制度可以?
我的測試 position DR:27°40.0'N; 102°22.5'W
# DR: Dead Reckoning
latDR1 = input(float('div latidude degrees as (dd)')) #27
latDR2 = input(float('div latitude minutes as (mm.m)'))#40.0
latDR3 = input('div latitude hemisphere N/S')#N
latDR = float(latDR1+(latDR2/60))
if latDR3 == S: -(latDR);
else: # here the error shows:
else:
^
IndentationError: unexpected indent
latDR
lonDR1 = input(float('div longditude degrees as (ddd)'))#102
lonDR2 = input(float('div longditude minutes as (mm.m)'))#22.5
lonDR3 = input('div longditude hemisphere E/W')#W
lonDR = float(latDR1+(latDR2/60))
if latDR3 == W: -(latDR);
else:
latDR
DR = (latDR, lonDR)
這取決於您以后要對緯度和經度值做什么。 通常三角函數( sin
、 cos
、 tan
等)需要它們,這些函數需要 arguments 為弧度。 這很容易用math.radians()
完成,計算后的結果可以用math.degrees()
轉換回來顯示。
忠告:當您按原樣讀取六十進制值時,您需要先將度數、分鍾和秒(或十進制分鍾)組合成十進制度,然后為您的符號約定應用否定或-1
乘數(北& East +ve 在您的情況下;其他選擇可用於經度...)如果適用。 例如,如果你有 27deg 45.0' S,你想要-1 * (27.0 + (45.0/60.0)) = -27.75
而不是-27.0 + (45.0/60.0) = -26.25
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.