Class: Chem::Molecule::EpsParameter

Inherits:
Object
  • Object
show all
Defined in:
lib/chem/db/eps.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeEpsParameter

Returns a new instance of EpsParameter.



126
127
128
129
130
131
# File 'lib/chem/db/eps.rb', line 126

def initialize
  @size = Vector[100.0, 100.0]
  @diff = 1.0
  @orig_pt = Vector[0.0, 0.0]
  @margin = 10.0
end

Instance Attribute Details

#diffObject

Returns the value of attribute diff.



124
125
126
# File 'lib/chem/db/eps.rb', line 124

def diff
  @diff
end

#fit_boxObject

Returns the value of attribute fit_box.



124
125
126
# File 'lib/chem/db/eps.rb', line 124

def fit_box
  @fit_box
end

#heightObject

Returns the value of attribute height.



124
125
126
# File 'lib/chem/db/eps.rb', line 124

def height
  @height
end

#marginObject

Returns the value of attribute margin.



124
125
126
# File 'lib/chem/db/eps.rb', line 124

def margin
  @margin
end

#minObject

Returns the value of attribute min.



124
125
126
# File 'lib/chem/db/eps.rb', line 124

def min
  @min
end

#orig_ptObject

Returns the value of attribute orig_pt.



124
125
126
# File 'lib/chem/db/eps.rb', line 124

def orig_pt
  @orig_pt
end

#widthObject

Returns the value of attribute width.



124
125
126
# File 'lib/chem/db/eps.rb', line 124

def width
  @width
end

#x_maxObject

Returns the value of attribute x_max.



124
125
126
# File 'lib/chem/db/eps.rb', line 124

def x_max
  @x_max
end

#y_maxObject

Returns the value of attribute y_max.



124
125
126
# File 'lib/chem/db/eps.rb', line 124

def y_max
  @y_max
end

Instance Method Details

#calc_bounding_box_size(nodes) ⇒ Object



133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# File 'lib/chem/db/eps.rb', line 133

def calc_bounding_box_size nodes
  # Shocking code :P
  min = Vector[ 1.0 / 0,  1.0 / 0]
  max = Vector[-1.0 / 0, -1.0 / 0]
  nodes.each do |atom|
    min[0] = min[0] > atom.x ? atom.x : min[0]
    max[0] = max[0] < atom.x ? atom.x : max[0]
    min[1] = min[1] > atom.y ? atom.y : min[1]
    max[1] = max[1] < atom.y ? atom.y : max[1]
  end

  diff = 1.0

  ratio = Vector[1.0, 1.0]

  if @fit_box
    if ((max[0] - min[0]) / (max[1] - min[1])) >
        (@size[0]  - @margin * 2)/ (@size[1] - @margin * 2)
      diff = (@size[0] - @margin * 2) / (max[0] - min[0])
      ratio[1] = @size[1] - @margin * 2 - (max[1] - min[1]) * diff
    else
      diff = (@size[1] - @margin * 2) / (max[1] - min[1])
      ratio[0] = @size[0] - @margin * 2 - (max[0] - min[1]) * diff
    end
  end
  [ratio, min]
end