Created
April 29, 2009 00:47
-
-
Save jarodl/103500 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def deg2ra(num) | |
if num < 0 | |
deg = deg + 360 | |
elsif num > 360 | |
puts "input should not exceed 360!" | |
end | |
hour = (num/15).to_i() | |
min = ((num-15*hour)*4).to_i() | |
sec = (4*num-60*hour-min)*60 | |
final = "#{hour}h#{min}m#{sec}s" | |
end | |
def deg2dec(num) | |
num = num.to_f() | |
if num < 0 then | |
sign = "-" | |
num = num*(-1) | |
else | |
sign = "+" | |
end | |
if num > 180 | |
puts "input should not exceed 180!" | |
elsif num > 90 | |
# exceeds 90, so convert to - dec | |
num -= 90 | |
sign = "-" | |
end | |
hour = num.to_i() | |
min = (( num - num.to_i() ) * 60).to_i() | |
sec = ( (num-num.to_i() ) * 60 - min ) * 60 | |
sign + "#{hour}h#{min}m#{sec}s" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment