Module: Three::MathUtils
- Defined in:
- lib/three/math/math_utils.rb
Constant Summary collapse
- DEG2RAD =
Math::PI / 180.0
- RAD2DEG =
180.0 / Math::PI
Class Method Summary collapse
- .clamp(value, min, max) ⇒ Object
- .deg_to_rad(degrees) ⇒ Object
- .euclidean_modulo(n, m) ⇒ Object
- .generate_uuid ⇒ Object
- .lerp(x, y, t) ⇒ Object
- .rad_to_deg(radians) ⇒ Object
Class Method Details
.clamp(value, min, max) ⇒ Object
12 13 14 |
# File 'lib/three/math/math_utils.rb', line 12 def clamp(value, min, max) [[value, min].max, max].min end |
.deg_to_rad(degrees) ⇒ Object
24 25 26 |
# File 'lib/three/math/math_utils.rb', line 24 def deg_to_rad(degrees) degrees * DEG2RAD end |
.euclidean_modulo(n, m) ⇒ Object
16 17 18 |
# File 'lib/three/math/math_utils.rb', line 16 def euclidean_modulo(n, m) ((n % m) + m) % m end |
.generate_uuid ⇒ Object
32 33 34 |
# File 'lib/three/math/math_utils.rb', line 32 def generate_uuid SecureRandom.uuid end |
.lerp(x, y, t) ⇒ Object
20 21 22 |
# File 'lib/three/math/math_utils.rb', line 20 def lerp(x, y, t) (1 - t) * x + t * y end |
.rad_to_deg(radians) ⇒ Object
28 29 30 |
# File 'lib/three/math/math_utils.rb', line 28 def rad_to_deg(radians) radians * RAD2DEG end |