spatialrust_transform/
bounds.rs1use spatialrust_math::{Mat3, Vec3};
4
5#[derive(Clone, Copy, Debug, PartialEq)]
7pub struct Aabb {
8 pub min: Vec3<f32>,
10 pub max: Vec3<f32>,
12}
13
14impl Aabb {
15 #[must_use]
17 pub const fn new(min: Vec3<f32>, max: Vec3<f32>) -> Self {
18 Self { min, max }
19 }
20
21 #[must_use]
23 pub fn center(&self) -> Vec3<f32> {
24 Vec3::new(
25 0.5 * (self.min.x + self.max.x),
26 0.5 * (self.min.y + self.max.y),
27 0.5 * (self.min.z + self.max.z),
28 )
29 }
30
31 #[must_use]
33 pub fn extent(&self) -> Vec3<f32> {
34 Vec3::new(self.max.x - self.min.x, self.max.y - self.min.y, self.max.z - self.min.z)
35 }
36}
37
38#[derive(Clone, Copy, Debug, PartialEq)]
40pub struct Obb {
41 pub center: Vec3<f32>,
43 pub axes: Mat3<f32>,
45 pub half_extents: Vec3<f32>,
47}