Updated for latest Rust

This commit is contained in:
ozkriff 2014-05-17 00:11:27 +04:00
parent d9967b3f1c
commit f6a27cddba
10 changed files with 30 additions and 30 deletions

View file

@ -97,7 +97,7 @@ impl<S: PartOrdPrim> Aabb<S, Vector2<S>, Point2<S>, [S, ..2]> for Aabb2<S> {
impl<S: fmt::Show> fmt::Show for Aabb2<S> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f.buf, "[{} - {}]", self.min, self.max)
write!(f, "[{} - {}]", self.min, self.max)
}
}
@ -130,6 +130,6 @@ impl<S: PartOrdPrim> Aabb<S, Vector3<S>, Point3<S>, [S, ..3]> for Aabb3<S> {
impl<S: fmt::Show> fmt::Show for Aabb3<S> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f.buf, "[{} - {}]", self.min, self.max)
write!(f, "[{} - {}]", self.min, self.max)
}
}

View file

@ -187,31 +187,31 @@ Angle<S> for Deg<S> {
#[inline] fn full_turn() -> Deg<S> { deg(cast(360).unwrap()) }
}
#[inline] pub fn sin<S: Float>(theta: Rad<S>) -> S { theta.s.sin() }
#[inline] pub fn cos<S: Float>(theta: Rad<S>) -> S { theta.s.cos() }
#[inline] pub fn tan<S: Float>(theta: Rad<S>) -> S { theta.s.tan() }
#[inline] pub fn sin_cos<S: Float>(theta: Rad<S>) -> (S, S) { theta.s.sin_cos() }
#[inline] pub fn sin<S: FloatMath>(theta: Rad<S>) -> S { theta.s.sin() }
#[inline] pub fn cos<S: FloatMath>(theta: Rad<S>) -> S { theta.s.cos() }
#[inline] pub fn tan<S: FloatMath>(theta: Rad<S>) -> S { theta.s.tan() }
#[inline] pub fn sin_cos<S: FloatMath>(theta: Rad<S>) -> (S, S) { theta.s.sin_cos() }
#[inline] pub fn cot<S: Float>(theta: Rad<S>) -> S { tan(theta).recip() }
#[inline] pub fn sec<S: Float>(theta: Rad<S>) -> S { cos(theta).recip() }
#[inline] pub fn csc<S: Float>(theta: Rad<S>) -> S { sin(theta).recip() }
#[inline] pub fn cot<S: FloatMath>(theta: Rad<S>) -> S { tan(theta).recip() }
#[inline] pub fn sec<S: FloatMath>(theta: Rad<S>) -> S { cos(theta).recip() }
#[inline] pub fn csc<S: FloatMath>(theta: Rad<S>) -> S { sin(theta).recip() }
#[inline] pub fn asin<S: Float>(s: S) -> Rad<S> { rad(s.asin()) }
#[inline] pub fn acos<S: Float>(s: S) -> Rad<S> { rad(s.acos()) }
#[inline] pub fn atan<S: Float>(s: S) -> Rad<S> { rad(s.atan()) }
#[inline] pub fn atan2<S: Float>(a: S, b: S) -> Rad<S> { rad(a.atan2(b)) }
#[inline] pub fn asin<S: FloatMath>(s: S) -> Rad<S> { rad(s.asin()) }
#[inline] pub fn acos<S: FloatMath>(s: S) -> Rad<S> { rad(s.acos()) }
#[inline] pub fn atan<S: FloatMath>(s: S) -> Rad<S> { rad(s.atan()) }
#[inline] pub fn atan2<S: FloatMath>(a: S, b: S) -> Rad<S> { rad(a.atan2(b)) }
impl<S: Float + fmt::Show>
fmt::Show for Rad<S> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f.buf, "{} rad", self.s)
write!(f, "{} rad", self.s)
}
}
impl<S: Float + fmt::Show>
fmt::Show for Deg<S> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f.buf, "{}°", self.s)
write!(f, "{}°", self.s)
}
}

View file

@ -725,7 +725,7 @@ ToQuaternion<S> for Matrix3<S> {
impl<S: PartOrdFloat<S> + fmt::Show> fmt::Show for Matrix2<S> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f.buf, "[[{}, {}], [{}, {}]]",
write!(f, "[[{}, {}], [{}, {}]]",
self.cr(0, 0), self.cr(0, 1),
self.cr(1, 0), self.cr(1, 1))
}
@ -733,7 +733,7 @@ impl<S: PartOrdFloat<S> + fmt::Show> fmt::Show for Matrix2<S> {
impl<S: PartOrdFloat<S> + fmt::Show> fmt::Show for Matrix3<S> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f.buf, "[[{}, {}, {}], [{}, {}, {}], [{}, {}, {}]]",
write!(f, "[[{}, {}, {}], [{}, {}, {}], [{}, {}, {}]]",
self.cr(0, 0), self.cr(0, 1), self.cr(0, 2),
self.cr(1, 0), self.cr(1, 1), self.cr(1, 2),
self.cr(2, 0), self.cr(2, 1), self.cr(2, 2))
@ -742,7 +742,7 @@ impl<S: PartOrdFloat<S> + fmt::Show> fmt::Show for Matrix3<S> {
impl<S: PartOrdFloat<S> + fmt::Show> fmt::Show for Matrix4<S> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f.buf, "[[{}, {}, {}, {}], [{}, {}, {}, {}], [{}, {}, {}, {}], [{}, {}, {}, {}]]",
write!(f, "[[{}, {}, {}, {}], [{}, {}, {}, {}], [{}, {}, {}, {}], [{}, {}, {}, {}]]",
self.cr(0, 0), self.cr(0, 1), self.cr(0, 2), self.cr(0, 3),
self.cr(1, 0), self.cr(1, 1), self.cr(1, 2), self.cr(1, 3),
self.cr(2, 0), self.cr(2, 1), self.cr(2, 2), self.cr(2, 3),

View file

@ -46,7 +46,7 @@ macro_rules! gen_minmax_for_not_floats (
gen_minmax_for_floats!(f32, f64)
gen_minmax_for_not_floats!(int, i8, i16, i32, i64, uint, u8, u16, u32, u64)
pub trait PartOrdFloat<S> : Float + ApproxEq<S> + PartOrdPrim {}
pub trait PartOrdFloat<S> : FloatMath + ApproxEq<S> + PartOrdPrim {}
impl PartOrdFloat<f32> for f32 {}
impl PartOrdFloat<f64> for f64 {}

View file

@ -124,7 +124,7 @@ ApproxEq<S> for Plane<S> {
impl<S: Clone + fmt::Float> fmt::Show for Plane<S> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f.buf, "{:f}x + {:f}y + {:f}z - {:f} = 0",
write!(f, "{:f}x + {:f}y + {:f}z - {:f} = 0",
self.n.x, self.n.y, self.n.z, self.d)
}
}

View file

@ -102,12 +102,12 @@ impl<S: PartOrdPrim> Point<S, Vector3<S>, [S, ..3]> for Point3<S> {}
impl<S: fmt::Show> fmt::Show for Point2<S> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f.buf, "[{}, {}]", self.x, self.y)
write!(f, "[{}, {}]", self.x, self.y)
}
}
impl<S: fmt::Show> fmt::Show for Point3<S> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f.buf, "[{}, {}, {}]", self.x, self.y, self.z)
write!(f, "[{}, {}, {}]", self.x, self.y, self.z)
}
}

View file

@ -25,7 +25,7 @@ use partial_ord::PartOrdFloat;
///
/// This is the equivalent to the [gluPerspective]
/// (http://www.opengl.org/sdk/docs/man2/xhtml/gluPerspective.xml) function.
pub fn perspective<S: Float, A: Angle<S>>(fovy: A, aspect: S, near: S, far: S) -> Matrix4<S> {
pub fn perspective<S: FloatMath, A: Angle<S>>(fovy: A, aspect: S, near: S, far: S) -> Matrix4<S> {
PerspectiveFov {
fovy: fovy,
aspect: aspect,
@ -77,7 +77,7 @@ pub struct PerspectiveFov<S, A> {
pub far: S,
}
impl<S: Float, A: Angle<S>> PerspectiveFov<S, A> {
impl<S: FloatMath, A: Angle<S>> PerspectiveFov<S, A> {
pub fn to_perspective(&self) -> Perspective<S> {
let angle = self.fovy.div_s(cast(2).unwrap());
let ymax = self.near * tan(angle.to_rad());
@ -102,7 +102,7 @@ Projection<S> for PerspectiveFov<S, A> {
}
}
impl<S: Float, A: Angle<S>> ToMatrix4<S> for PerspectiveFov<S, A> {
impl<S: FloatMath, A: Angle<S>> ToMatrix4<S> for PerspectiveFov<S, A> {
fn to_matrix4(&self) -> Matrix4<S> {
let half_turn: A = Angle::turn_div_2();

View file

@ -290,7 +290,7 @@ Neg<Quaternion<S>> for Quaternion<S> {
impl<S: fmt::Show> fmt::Show for Quaternion<S> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f.buf, "{} + {}i + {}j + {}k",
write!(f, "{} + {}i + {}j + {}k",
self.s,
self.v.x,
self.v.y,

View file

@ -161,7 +161,7 @@ Transform3<S> for Decomposed<S,Vector3<S>,R> {}
impl<S: fmt::Show + Float, R: fmt::Show + Rotation3<S>>
fmt::Show for Decomposed<S,Vector3<S>,R> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f.buf, "(scale({}), rot({}), disp{})",
write!(f, "(scale({}), rot({}), disp{})",
self.scale, self.rot, self.disp)
}
}

View file

@ -304,18 +304,18 @@ EuclideanVector<S, [S, ..4]> for Vector4<S> {
impl<S: fmt::Show> fmt::Show for Vector2<S> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f.buf, "[{}, {}]", self.x, self.y)
write!(f, "[{}, {}]", self.x, self.y)
}
}
impl<S: fmt::Show> fmt::Show for Vector3<S> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f.buf, "[{}, {}, {}]", self.x, self.y, self.z)
write!(f, "[{}, {}, {}]", self.x, self.y, self.z)
}
}
impl<S: fmt::Show> fmt::Show for Vector4<S> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f.buf, "[{}, {}, {}, {}]", self.x, self.y, self.z, self.w)
write!(f, "[{}, {}, {}, {}]", self.x, self.y, self.z, self.w)
}
}