Advertisement
Guest User

Untitled

a guest
Aug 28th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. #! /usr/local/bin/ruby
  2. # coding: utf-8
  3. #---------------------------------------------------------------------------------
  4. #= 赤道・黄道座標変換
  5. #
  6. # date name version
  7. # 2016.08.29 mk-mode.com 1.00 新規作成
  8. #
  9. # Copyright(C) 2016 mk-mode.com All Rights Reserved.
  10. #---------------------------------------------------------------------------------
  11. #++
  12. require "mk_coord"
  13.  
  14. class CoordConversion
  15. # 黄道傾斜角(単位: rad)
  16. # (Math::PI は MkCoord::Const::PI と置き換えてもよい)
  17. EPS = 23.43929 * Math::PI / 180.0
  18. # 元の赤道直交座標
  19. POS = [
  20. 0.99443659220700997281,
  21. -0.03816291768957833647,
  22. -0.01655177670960058384
  23. ] # <= ある日の地球重心から見た太陽重心の位置(単位: AU)
  24.  
  25. def exec
  26. puts "元の赤道直交座標:\n #{POS}"
  27. rect_ec = MkCoord.rect_eq2ec(POS, EPS)
  28. puts "黄道直交座標に変換:\n #{rect_ec}"
  29. rect_eq = MkCoord.rect_ec2eq(rect_ec, EPS)
  30. puts "赤道直交座標に戻す:\n #{rect_eq}"
  31. *pol_eq, r = MkCoord.rect2pol(rect_eq)
  32. puts "赤道極座標に変換:\n #{pol_eq[0, 2]} (R = #{r})"
  33. pol_ec = MkCoord.pol_eq2ec(pol_eq[0, 2], EPS)
  34. puts "黄道極座標に変換:\n #{pol_ec[0, 2]}"
  35. pol_eq = MkCoord.pol_ec2eq(pol_ec, EPS)
  36. puts "赤道極座標に戻す:\n #{pol_eq[0, 2]}"
  37. rect_eq = MkCoord.pol2rect(pol_eq[0, 2], r)
  38. puts "赤道直交座標に戻す:\n #{rect_eq}"
  39. rescue => e
  40. puts "[#{e.class}] #{e.message}"
  41. e.backtrace.each { |tr| $stderr.puts "\t#{tr}" }
  42. exit 1
  43. end
  44. end
  45.  
  46. exit 0 unless __FILE__ == $0
  47. CoordConversion.new.exec
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement