pub struct Interval {
	pub min: f64,
	pub max: f64,
}

impl Interval {
	pub const fn new(min: f64, max: f64) -> Self {
		Self { min, max }
	}

	pub fn size(&self) -> f64 {
		self.max - self.min
	}

	pub fn contains(&self, value: f64) -> bool {
		self.min <= value && value <= self.max
	}

	pub fn surrounds(&self, value: f64) -> bool {
		self.min < value && value < self.max
	}

	pub fn clamp(&self, value: f64) -> f64 {
		value.clamp(self.min, self.max)
	}
}

pub const EMPTY: Interval = Interval::new(f64::INFINITY, -f64::INFINITY);
pub const WORLD: Interval = Interval::new(0.001, f64::INFINITY);
pub const UNIVERSE: Interval = Interval::new(-f64::INFINITY, f64::INFINITY);
