Module: Miriad::AngleConversion

Defined in:
lib/miriad.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.d2h(d) ⇒ Object

Convert degrees to hours



69
# File 'lib/miriad.rb', line 69

def d2h(d) d/15.0; end

.d2r(d) ⇒ Object

Convert degrees to radians



61
# File 'lib/miriad.rb', line 61

def d2r(d) d*Math::PI/180; end

.d_to_dms(fr) ⇒ Object

Convert possibly non-integer degrees fr to [degrees, minutes, seconds] where degrees and minutes are integers.



31
32
33
34
35
36
37
# File 'lib/miriad.rb', line 31

def d_to_dms(fr)
  sign = fr <=> 0
  fr *= sign
  d = fr.to_i; fr %= 1; fr *= 60
  m = fr.to_i; fr %= 1; fr *= 60
  return d*sign, m, fr
end

.dms_to_d(*args) ⇒ Object

Convert degrees, minutes, seconds to possibly non-integer degrees. Missing arguments are assumed to be 0.



46
47
48
49
50
51
52
53
# File 'lib/miriad.rb', line 46

def dms_to_d(*args)
  d = 0.to_r
  d += args.shift unless args.empty?
  sign = d < 0 ? -1 : 1
  d += args.shift * Rational(sign,60) unless args.empty?
  d += args.shift * Rational(sign,3600) unless args.empty?
  return d
end

.h2d(h) ⇒ Object

Convert hours to degrees



71
# File 'lib/miriad.rb', line 71

def h2d(h) h*15.0; end

.h2r(h) ⇒ Object

Convert hours to radians



65
# File 'lib/miriad.rb', line 65

def h2r(h) h*Math::PI/12; end

.h_to_hms(fr) ⇒ Object

Convert possibly non-integer hours fr to [hours, minutes, seconds] where hours and minutes are integers.



42
# File 'lib/miriad.rb', line 42

def h_to_hms(fr); d_to_dms(fr); end

.r2d(r) ⇒ Object

Convert radians to degrees



63
# File 'lib/miriad.rb', line 63

def r2d(r) r*180/Math::PI; end

.r2h(r) ⇒ Object

Convert radians to hours



67
# File 'lib/miriad.rb', line 67

def r2h(r) r*12/Math::PI; end

Instance Method Details

#hms_to_h(*args) ⇒ Object

Convert hours, minutes, seconds to possibly non-integer hours. Missing arguments are assumed to be 0.



58
# File 'lib/miriad.rb', line 58

def hms_to_h(*args); dms_to_d(*args); end