added antialiasing

This commit is contained in:
2023-01-29 20:06:49 +01:00
parent 7a4dd5a1b9
commit 95f5132d1d
9 changed files with 637 additions and 566 deletions

26
src/rtweekend.rs Normal file
View File

@@ -0,0 +1,26 @@
use rand::prelude::*;
// 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
}