module ChaosDetector::Utils::LerpUtil

Public Class Methods

delerp(val, min:, max:) click to toggle source
# File lib/chaos_detector/utils/lerp_util.rb, line 6
def delerp(val, min:, max:)
  return 0.0 if min==max
  (val - min).to_f / (max - min)
end
lerp(pct, min:, max:) click to toggle source

Linear interpolation between min and max: @arg pct is percentage where 1.0 represents 100%

# File lib/chaos_detector/utils/lerp_util.rb, line 13
def lerp(pct, min:, max:)
  return 0.0 if min==max
  (max-min) * pct.to_f + min
end