Class: Osgb::Helmert

Inherits:
Object
  • Object
show all
Defined in:
lib/osgb/helmert.rb

Constant Summary collapse

@@instances =
{}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, attributes) ⇒ Helmert



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/osgb/helmert.rb', line 6

def initialize(name, attributes)
  @name = name
  @tx = attributes[:tx]
  @ty = attributes[:ty]
  @tz = attributes[:tz]
  @rx = (attributes[:rx]/3600).to_radians
  @ry = (attributes[:ry]/3600).to_radians
  @rz = (attributes[:rz]/3600).to_radians
  @s = attributes[:s]
  @@instances[name] = self
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/osgb/helmert.rb', line 3

def name
  @name
end

#rxObject

Returns the value of attribute rx.



3
4
5
# File 'lib/osgb/helmert.rb', line 3

def rx
  @rx
end

#ryObject

Returns the value of attribute ry.



3
4
5
# File 'lib/osgb/helmert.rb', line 3

def ry
  @ry
end

#rzObject

Returns the value of attribute rz.



3
4
5
# File 'lib/osgb/helmert.rb', line 3

def rz
  @rz
end

#sObject

Returns the value of attribute s.



3
4
5
# File 'lib/osgb/helmert.rb', line 3

def s
  @s
end

#txObject

Returns the value of attribute tx.



3
4
5
# File 'lib/osgb/helmert.rb', line 3

def tx
  @tx
end

#tyObject

Returns the value of attribute ty.



3
4
5
# File 'lib/osgb/helmert.rb', line 3

def ty
  @ty
end

#tzObject

Returns the value of attribute tz.



3
4
5
# File 'lib/osgb/helmert.rb', line 3

def tz
  @tz
end

Class Method Details

.[](name) ⇒ Object



29
30
31
# File 'lib/osgb/helmert.rb', line 29

def self.[](name)
  @@instances[name]
end

Instance Method Details

#s1Object



18
19
20
# File 'lib/osgb/helmert.rb', line 18

def s1
  s/1e6 + 1
end

#transform(x, y, z) ⇒ Object



22
23
24
25
26
27
# File 'lib/osgb/helmert.rb', line 22

def transform(x,y,z)
  xp = tx + x*s1 - y*rz + z*ry
  yp = ty + x*rz + y*s1 - z*rx
  zp = tz - x*ry + y*rx + z*s1
  [xp, yp, zp]
end