Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /usr/local/bin/ruby
- # coding: utf-8
- #---------------------------------------------------------------------------------
- #= 赤道・黄道座標変換
- #
- # date name version
- # 2016.08.29 mk-mode.com 1.00 新規作成
- #
- # Copyright(C) 2016 mk-mode.com All Rights Reserved.
- #---------------------------------------------------------------------------------
- #++
- require "mk_coord"
- class CoordConversion
- # 黄道傾斜角(単位: rad)
- # (Math::PI は MkCoord::Const::PI と置き換えてもよい)
- EPS = 23.43929 * Math::PI / 180.0
- # 元の赤道直交座標
- POS = [
- 0.99443659220700997281,
- -0.03816291768957833647,
- -0.01655177670960058384
- ] # <= ある日の地球重心から見た太陽重心の位置(単位: AU)
- def exec
- puts "元の赤道直交座標:\n #{POS}"
- rect_ec = MkCoord.rect_eq2ec(POS, EPS)
- puts "黄道直交座標に変換:\n #{rect_ec}"
- rect_eq = MkCoord.rect_ec2eq(rect_ec, EPS)
- puts "赤道直交座標に戻す:\n #{rect_eq}"
- *pol_eq, r = MkCoord.rect2pol(rect_eq)
- puts "赤道極座標に変換:\n #{pol_eq[0, 2]} (R = #{r})"
- pol_ec = MkCoord.pol_eq2ec(pol_eq[0, 2], EPS)
- puts "黄道極座標に変換:\n #{pol_ec[0, 2]}"
- pol_eq = MkCoord.pol_ec2eq(pol_ec, EPS)
- puts "赤道極座標に戻す:\n #{pol_eq[0, 2]}"
- rect_eq = MkCoord.pol2rect(pol_eq[0, 2], r)
- puts "赤道直交座標に戻す:\n #{rect_eq}"
- rescue => e
- puts "[#{e.class}] #{e.message}"
- e.backtrace.each { |tr| $stderr.puts "\t#{tr}" }
- exit 1
- end
- end
- exit 0 unless __FILE__ == $0
- CoordConversion.new.exec
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement