module CooCoo::Math

Public Class Methods

clamp(n, min, max) click to toggle source
# File lib/coo-coo/math/functions.rb, line 28
def clamp(n, min, max)
  if n < min
    min
  elsif n > max
    max
  else
    n
  end
end
lerp(a, b, t) click to toggle source
# File lib/coo-coo/math/interpolation.rb, line 3
def self.lerp(a, b, t)
  a * (1.0 - t) + b * t
end
max(a, b) click to toggle source
# File lib/coo-coo/math/functions.rb, line 4
def max(a, b)
  if a
    if b
      (a >= b) ? a : b
    else
      a
    end
  else
    b
  end
end
min(a, b) click to toggle source
# File lib/coo-coo/math/functions.rb, line 16
def min(a, b)
  if a
    if b
      (a <= b) ? a : b
    else
      a
    end
  else
    b
  end
end