Added centers of bounding box
This commit is contained in:
parent
8062de7e21
commit
4ddbbbcc3e
|
@ -94,6 +94,7 @@ macro_rules! make_bounding_box {
|
||||||
}
|
}
|
||||||
ret
|
ret
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -103,6 +104,21 @@ make_bounding_box!(BoundingBox2, Vector2, 2);
|
||||||
make_bounding_box!(BoundingBox3, Vector3, 3);
|
make_bounding_box!(BoundingBox3, Vector3, 3);
|
||||||
make_bounding_box!(BoundingBox4, Vector4, 4);
|
make_bounding_box!(BoundingBox4, Vector4, 4);
|
||||||
|
|
||||||
|
macro_rules! impl_center {
|
||||||
|
($name: ident, $vector: ident, $f: tt) => {
|
||||||
|
impl $name<$f> {
|
||||||
|
/// Returns the center of the bounding box.
|
||||||
|
pub fn center(&self) -> $vector<$f> {
|
||||||
|
(self.min + self.max) / 2.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl_center!(BoundingBox2, Vector2, f32);
|
||||||
|
impl_center!(BoundingBox2, Vector2, f64);
|
||||||
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue