to_str for Aabbs

This commit is contained in:
Risto Saarelma 2014-02-07 08:50:10 +02:00
parent 907165075c
commit 57ff382cf1

View file

@ -18,6 +18,7 @@
use point::{Point, Point2, Point3}; use point::{Point, Point2, Point3};
use vector::{Vector, Vec2, Vec3}; use vector::{Vector, Vec2, Vec3};
use array::build; use array::build;
use std::fmt;
use std::num::{zero, one}; use std::num::{zero, one};
use std::iter::Iterator; use std::iter::Iterator;
@ -91,6 +92,12 @@ impl<S: Primitive> Aabb<S, Vec2<S>, Point2<S>, [S, ..2]> for Aabb2<S> {
#[inline] fn max<'a>(&'a self) -> &'a Point2<S> { &self.mx } #[inline] fn max<'a>(&'a self) -> &'a Point2<S> { &self.mx }
} }
impl<S: fmt::Show> ToStr for Aabb2<S> {
fn to_str(&self) -> ~str {
format!("[{} - {}]", self.mn.to_str(), self.mx.to_str())
}
}
#[deriving(Clone, Eq)] #[deriving(Clone, Eq)]
pub struct Aabb3<S> { pub struct Aabb3<S> {
mn: Point3<S>, mn: Point3<S>,
@ -113,3 +120,9 @@ impl<S: Primitive> Aabb<S, Vec3<S>, Point3<S>, [S, ..3]> for Aabb3<S> {
#[inline] fn min<'a>(&'a self) -> &'a Point3<S> { &self.mn } #[inline] fn min<'a>(&'a self) -> &'a Point3<S> { &self.mn }
#[inline] fn max<'a>(&'a self) -> &'a Point3<S> { &self.mx } #[inline] fn max<'a>(&'a self) -> &'a Point3<S> { &self.mx }
} }
impl<S: fmt::Show> ToStr for Aabb3<S> {
fn to_str(&self) -> ~str {
format!("[{} - {}]", self.mn.to_str(), self.mx.to_str())
}
}