Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated for latest Rust #69

Merged
merged 1 commit into from
May 16, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/cgmath/aabb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down Expand Up @@ -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)
}
}
26 changes: 13 additions & 13 deletions src/cgmath/angle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/cgmath/matrix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -725,15 +725,15 @@ 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))
}
}

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))
Expand All @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion src/cgmath/partial_ord.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}

2 changes: 1 addition & 1 deletion src/cgmath/plane.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
4 changes: 2 additions & 2 deletions src/cgmath/point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
6 changes: 3 additions & 3 deletions src/cgmath/projection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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());
Expand All @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion src/cgmath/quaternion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/cgmath/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/cgmath/vector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}