Class: ReferenceSpace

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
CoreBase
Defined in:
app/models/reference_space.rb

Overview

A reference space is a coordinate system to which we register SectionDataSets and/or Specimens so that we can compare between and/or transfer information between them. A reference space can be constructed from a images of a Specimen, be a virtual space or an external standard space used by the community.

Attributes:

Associations:

Instance Method Summary (collapse)

Instance Method Details

- (Object) transform_from(reference_space, rx, ry, rz)

Transfrom a 3-D position from another reference space to this reference space



27
28
29
30
31
32
33
34
# File 'app/models/reference_space.rb', line 27

def transform_from(reference_space, rx, ry, rz)
  t = ReferenceToReferenceTransform.first(:conditions => {:from_reference_space_id => reference_space.id, :to_reference_space_id => self.id})
  sx = t.t_00 * rx + t.t_01 * ry + t.t_02 * rz + t.t_09
  sy = t.t_03 * rx + t.t_04 * ry + t.t_05 * rz + t.t_10
  sz = t.t_06 * rx + t.t_07 * ry + t.t_08 * rz + t.t_11

  return sx, sy, sz
end

- (Object) transform_to(reference_space, rx, ry, rz)

Transform a 3-D position from this reference space to another reference space



37
38
39
40
41
42
43
44
# File 'app/models/reference_space.rb', line 37

def transform_to(reference_space, rx, ry, rz)
  t = ReferenceToReferenceTransform.first(:conditions => {:to_reference_space_id => reference_space.id, :from_reference_space_id => self.id})
  sx = t.t_00 * rx + t.t_01 * ry + t.t_02 * rz + t.t_09
  sy = t.t_03 * rx + t.t_04 * ry + t.t_05 * rz + t.t_10
  sz = t.t_06 * rx + t.t_07 * ry + t.t_08 * rz + t.t_11

  return sx, sy, sz
end