diff options
author | Rosyid Haryadi <rosyid_haryadi@protonmail.com> | 2025-03-03 23:07:03 +0700 |
---|---|---|
committer | Rosyid Haryadi <rosyid_haryadi@protonmail.com> | 2025-03-03 23:07:03 +0700 |
commit | 5fd5bb979765ec47e04e3f1f34d362d8d0c9c41e (patch) | |
tree | ca82c91e210d1cb1af98a8a4c23172aab2393b52 /src/interval.rs | |
parent | 210259c586ba950392bb5ae413d050da2f9bb430 (diff) |
refactor move interval related to calculus.rs
Diffstat (limited to 'src/interval.rs')
-rw-r--r-- | src/interval.rs | 50 |
1 files changed, 0 insertions, 50 deletions
diff --git a/src/interval.rs b/src/interval.rs deleted file mode 100644 index 21c5f6e..0000000 --- a/src/interval.rs +++ /dev/null @@ -1,50 +0,0 @@ -pub struct Interval { - pub min: f32, - pub max: f32, -} - -#[allow(unused)] -impl Interval { - pub fn new(min: f32, max: f32) -> Self { - Self { min, max } - } - - pub fn size(&self) -> f32 { - self.max - self.min - } - - pub fn contains(&self, x: f32) -> bool { - self.min <= x && x <= self.max - } - - pub fn surrounds(&self, x: f32) -> bool { - self.min < x && x < self.max - } - - pub fn clamp(&self, x: f32) -> f32 { - if x < self.min { return self.min } - if x > self.max { return self.max } - x - } -} - -impl Default for Interval { - fn default() -> Self { - Self { - min: f32::NEG_INFINITY, - max: f32::INFINITY - } - } -} - -#[allow(unused)] -pub const INTERVAL_EMPTY: Interval = Interval { - min: f32::INFINITY, - max: f32::NEG_INFINITY -}; - -#[allow(unused)] -pub const INTERVAL_UNIVERSE: Interval = Interval { - min: f32::NEG_INFINITY, - max: f32::INFINITY -}; |