Class: Array2dSimple::NormalizedArray2d

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/array_2d_simple/normalized_array_2d.rb

Instance Method Summary collapse

Instance Method Details

#[](x, y) ⇒ Object



5
6
7
# File 'lib/array_2d_simple/normalized_array_2d.rb', line 5

def [] x, y
  normalized_by_rc y,x
end

#normalized_by_rc(r, c) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/array_2d_simple/normalized_array_2d.rb', line 9

def normalized_by_rc r,c
  value = get_by_rc(r,c)
  # value = max if value == Float::INFINITY
  # value = min if value == -Float::INFINITY # Does this work?
  if value and value.respond_to?(:to_f)
    return (value.to_f - min) / (max - min).to_f 
   else
    return 0.0
  end
end