天文単位コンバーター
AU・光年・パーセク・kmなどの天文距離単位間で変換します。
変換結果
km1.49598e+8
AU (Astronomical Units)1
light-seconds499.005
light-minutes8.31675
light-hours0.138612
light-days0.00577552
light-years1.5813e-5
parsecs4.8481e-6
参考距離
Earth–Sun distance1 AU
Light from Sun to Earth~8.3 min
Nearest star (Proxima Cen.)4.24 ly
Milky Way diameter~100,000 ly
Andromeda Galaxy~2.537 million ly
よくある質問
コード実装
# Astronomical unit conversions (all in km)
TO_KM = {
"km": 1,
"au": 149_597_870.7,
"ls": 299_792.458, # light-second
"lm": 17_987_547.48, # light-minute
"lh": 1_079_252_848.8, # light-hour
"ld": 25_902_068_371.2, # light-day
"ly": 9_460_730_472_580.8, # light-year
"pc": 30_856_775_814_913.67, # parsec
}
def convert(value, from_unit, to_unit):
km = value * TO_KM[from_unit]
return km / TO_KM[to_unit]
# Examples
print(f"1 AU = {convert(1, 'au', 'km'):,.1f} km")
print(f"1 AU = {convert(1, 'au', 'ls'):.2f} light-seconds")
print(f"1 AU = {convert(1, 'au', 'lm'):.2f} light-minutes")
print(f"Nearest star (4.24 ly) = {convert(4.24, 'ly', 'au'):,.0f} AU")
print(f"1 parsec = {convert(1, 'pc', 'ly'):.2f} light-years")Comments & Feedback
Comments are powered by Giscus. Sign in with GitHub to leave a comment.