Class: Chem::Molecule::EpsParameter
- Inherits:
-
Object
- Object
- Chem::Molecule::EpsParameter
- Defined in:
- lib/chem/db/eps.rb
Instance Attribute Summary collapse
-
#diff ⇒ Object
Returns the value of attribute diff.
-
#fit_box ⇒ Object
Returns the value of attribute fit_box.
-
#height ⇒ Object
Returns the value of attribute height.
-
#margin ⇒ Object
Returns the value of attribute margin.
-
#min ⇒ Object
Returns the value of attribute min.
-
#orig_pt ⇒ Object
Returns the value of attribute orig_pt.
-
#width ⇒ Object
Returns the value of attribute width.
-
#x_max ⇒ Object
Returns the value of attribute x_max.
-
#y_max ⇒ Object
Returns the value of attribute y_max.
Instance Method Summary collapse
- #calc_bounding_box_size(nodes) ⇒ Object
-
#initialize ⇒ EpsParameter
constructor
A new instance of EpsParameter.
Constructor Details
#initialize ⇒ EpsParameter
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
#diff ⇒ Object
Returns the value of attribute diff.
124 125 126 |
# File 'lib/chem/db/eps.rb', line 124 def diff @diff end |
#fit_box ⇒ Object
Returns the value of attribute fit_box.
124 125 126 |
# File 'lib/chem/db/eps.rb', line 124 def fit_box @fit_box end |
#height ⇒ Object
Returns the value of attribute height.
124 125 126 |
# File 'lib/chem/db/eps.rb', line 124 def height @height end |
#margin ⇒ Object
Returns the value of attribute margin.
124 125 126 |
# File 'lib/chem/db/eps.rb', line 124 def margin @margin end |
#min ⇒ Object
Returns the value of attribute min.
124 125 126 |
# File 'lib/chem/db/eps.rb', line 124 def min @min end |
#orig_pt ⇒ Object
Returns the value of attribute orig_pt.
124 125 126 |
# File 'lib/chem/db/eps.rb', line 124 def orig_pt @orig_pt end |
#width ⇒ Object
Returns the value of attribute width.
124 125 126 |
# File 'lib/chem/db/eps.rb', line 124 def width @width end |
#x_max ⇒ Object
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_max ⇒ Object
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 |