Class: Bayonetta::EXPFile2::InterpolationEntry

Inherits:
LibBin::Structure
  • Object
show all
Defined in:
lib/bayonetta/exp.rb

Instance Method Summary collapse

Instance Method Details

#get_value(val) ⇒ Object



213
214
215
216
217
218
219
220
221
222
223
224
225
226
# File 'lib/bayonetta/exp.rb', line 213

def get_value(val)
  @points.each_cons(2) { |left, right|
    if left.v <= val && right.v >= val
      p0 = left.p
      p1 = right.p
      m0 = left.m1
      m1 = right.m0
      t = (val - left.v).to_f / (right.v - left.v)
      return (2 * t*t*t - 3 * t*t + 1)*p0 + (t*t*t - 2 * t*t + t)*m0 + (-2 * t*t*t + 3 * t*t)*p1 + (t*t*t - t * t)*m1
    end

  }
  return 0.0
end