Module: MkCoord

Defined in:
lib/mk_coord.rb,
lib/mk_coord/const.rb,
lib/mk_coord/matrix.rb,
lib/mk_coord/version.rb,
lib/mk_coord/trigonometric.rb

Defined Under Namespace

Modules: Const, Matrix, Trigonometric

Constant Summary collapse

VERSION =
"0.1.6"

Class Method Summary collapse

Class Method Details

.pol2rect(pol, r) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/mk_coord.rb', line 52

def self.pol2rect(pol, r)
  lambda, phi = pol
  mtx = r_y(phi)
  mtx = r_z(-lambda, mtx)
  return rotate(mtx, [r, 0.0, 0.0])
  #return [
  #  r * Math.cos(lambda) * Math.cos(phi),
  #  r * Math.sin(lambda) * Math.cos(phi),
  #  r * Math.sin(phi)
  #]
rescue => e
  raise
end

.pol_ec2eq(pol_ec, eps) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/mk_coord.rb', line 32

def self.pol_ec2eq(pol_ec, eps)
  alpha = compute_alpha(*pol_ec, eps)
  delta = compute_delta(*pol_ec, eps)
  return [alpha, delta]
rescue => e
  raise
end

.pol_eq2ec(pol_eq, eps) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/mk_coord.rb', line 24

def self.pol_eq2ec(pol_eq, eps)
  lambda = compute_lambda(*pol_eq, eps)
  beta   = compute_beta(*pol_eq, eps)
  return [lambda, beta]
rescue => e
  raise
end

.rect2pol(rect) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
# File 'lib/mk_coord.rb', line 40

def self.rect2pol(rect)
  x, y, z = rect
  r = Math.sqrt(x * x + y * y)
  lambda = Math.atan2(y, x)
  phi    = Math.atan2(z, r)
  lambda %= PI2 if lambda < 0
  d = Math.sqrt(x * x + y * y + z * z)
  return [lambda, phi, d]
rescue => e
  raise
end

.rect_ec2eq(rect_ec, eps) ⇒ Object



17
18
19
20
21
22
# File 'lib/mk_coord.rb', line 17

def self.rect_ec2eq(rect_ec, eps)
  mtx = r_x(-eps)
  return rotate(mtx, rect_ec)
rescue => e
  raise
end

.rect_eq2ec(rect_eq, eps) ⇒ Object



10
11
12
13
14
15
# File 'lib/mk_coord.rb', line 10

def self.rect_eq2ec(rect_eq, eps)
  mtx = r_x(eps)
  return rotate(mtx, rect_eq)
rescue => e
  raise
end