Module: CooCoo::Math
- Defined in:
- lib/coo-coo/math/functions.rb,
lib/coo-coo/math/interpolation.rb,
lib/coo-coo/math/abstract_vector.rb
Defined Under Namespace
Classes: AbstractVector
Class Method Summary collapse
Class Method Details
.clamp(n, min, max) ⇒ Object
28 29 30 31 32 33 34 35 36 |
# 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) ⇒ Object
3 4 5 |
# 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) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 |
# 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) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# 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 |