Module: VORuby::CoordinateSystems::Equatorial

Defined in:
lib/voruby/spacetime/spacetime.rb

Defined Under Namespace

Modules: Exception Classes: Declination, RADecPosition, RightAscension

Class Method Summary collapse

Class Method Details

.fk4_rotation_angles(equinox1, equinox2 = 2000.0) ⇒ Object



268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
# File 'lib/voruby/spacetime/spacetime.rb', line 268

def self.fk4_rotation_angles(equinox1, equinox2=2000.0)
  deg_to_rad = Math::PI / 180.0
  sec_to_rad = deg_to_rad / 3600.0
  t = 0.001 * (equinox2 - equinox1)
  st = 0.001 * (equinox1 - 1900.0)

  a = sec_to_rad * t *
    (23042.53 +
      st * (139.75 + 0.06 * st) +
      t * (30.23 - 0.27 * st + 18.0 * t))
  b = sec_to_rad * t * t * (79.27 + 0.66 * st + 0.32 * t) + a
  c = sec_to_rad * t *
    (20046.85 -
      st * (85.33 + 0.37 * st) +
      t * (-42.67 - 0.37 * st - 41.8 * t))
    
  return [a, b, c]
end

.fk5_rotation_angles(equinox1, equinox2 = 2000.0) ⇒ Object



249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
# File 'lib/voruby/spacetime/spacetime.rb', line 249

def self.fk5_rotation_angles(equinox1, equinox2=2000.0)
  deg_to_rad = Math::PI / 180.0
  sec_to_rad = deg_to_rad / 3600.0
  t = 0.001 * (equinox2 - equinox1)
  st = 0.001 * (equinox1 - 2000.0)

  a = sec_to_rad * t *
    (23062.181 +
      st * (139.656 + 0.0139 * st) +
      t * (30.188 - 0.344 * st + 17.998))
  b = sec_to_rad * t * t * (79.280 + 0.410 * st + 0.205 * t) + a
  c = sec_to_rad * t *
    (20043.109 -
      st * (85.33 + 0.217 * st) +
      t * (-42.665 - 0.217 * st - 41.833 * t))
    
  return [a, b, c]
end

.looks_like_decimal?(decimal) ⇒ Boolean

Returns true if the provided string looks like it’s in standard decimal format.

Returns:

  • (Boolean)


225
226
227
228
# File 'lib/voruby/spacetime/spacetime.rb', line 225

def self.looks_like_decimal?(decimal)
  return true if decimal.to_s.match(/^[+-]?\d+(\.\d*)?$/)
  return false
end

.looks_like_sexigesimal?(sexig, sep = '(:|(\s)+)') ⇒ Boolean

Returns true if the provided string looks like it’s in standard sexigesimal format.

Returns:

  • (Boolean)


218
219
220
221
# File 'lib/voruby/spacetime/spacetime.rb', line 218

def self.looks_like_sexigesimal?(sexig, sep='(:|(\s)+)')
   return true if sexig.match(/^[+-]?\d+#{sep}\d+#{sep}\d+/)
   return false
end

.precession_matrix(equinox1, equinox2 = 2000.0, system = :fk5) ⇒ Object

Default is to J2000.0 (i.e. equinox2=2000.0, system=:fk5)



231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
# File 'lib/voruby/spacetime/spacetime.rb', line 231

def self.precession_matrix(equinox1, equinox2=2000.0, system=:fk5)
  a, b, c = (system == :fk4)? Equatorial::fk4_rotation_angles(equinox1, equinox2): Equatorial::fk5_rotation_angles(equinox1, equinox2)

  sina = Math.sin(a)
  sinb = Math.sin(b)
  sinc = Math.sin(c)

  cosa = Math.cos(a)
  cosb = Math.cos(b)
  cosc = Math.cos(c)

  Matrix.rows([
    [cosa*cosb*cosc-sina*sinb, sina*cosb+cosa*sinb*cosc,  cosa*sinc],
    [-cosa*sinb-sina*cosb*cosc, cosa*cosb-sina*sinb*cosc, -sina*sinc],
    [-cosb*sinc, -sinb*sinc, cosc]
  ])
end