26 lines
547 B
Rust
26 lines
547 B
Rust
use rand::Rng;
|
|
|
|
// Constants
|
|
pub const INFINITY: f64 = std::f64::INFINITY;
|
|
pub const PI: f64 = std::f64::consts::PI;
|
|
|
|
// Utility Functions
|
|
pub fn degrees_to_radians(degrees: f64) -> f64 {
|
|
degrees * std::f64::consts::PI / 180.0
|
|
}
|
|
|
|
// PLEASE CHANGE
|
|
pub fn random_f64() -> f64 {
|
|
rand::thread_rng().gen()
|
|
}
|
|
|
|
// PLEASE CHANGE
|
|
pub fn random_range_f64(min: f64, max: f64) -> f64 {
|
|
rand::thread_rng().gen_range(min, max)
|
|
}
|
|
|
|
pub fn clamp(x: f64, min: f64, max: f64) -> f64 {
|
|
if x < min { return min; }
|
|
if x > max { return max; }
|
|
x
|
|
} |