diff options
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 -}; |