Skip to content

Commit 702b7e1

Browse files
committed
Merge pull request #69 from ozkriff/master
Updated for latest Rust
2 parents d9967b3 + f6a27cd commit 702b7e1

File tree

10 files changed

+30
-30
lines changed

10 files changed

+30
-30
lines changed

src/cgmath/aabb.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ impl<S: PartOrdPrim> Aabb<S, Vector2<S>, Point2<S>, [S, ..2]> for Aabb2<S> {
9797

9898
impl<S: fmt::Show> fmt::Show for Aabb2<S> {
9999
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
100-
write!(f.buf, "[{} - {}]", self.min, self.max)
100+
write!(f, "[{} - {}]", self.min, self.max)
101101
}
102102
}
103103

@@ -130,6 +130,6 @@ impl<S: PartOrdPrim> Aabb<S, Vector3<S>, Point3<S>, [S, ..3]> for Aabb3<S> {
130130

131131
impl<S: fmt::Show> fmt::Show for Aabb3<S> {
132132
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
133-
write!(f.buf, "[{} - {}]", self.min, self.max)
133+
write!(f, "[{} - {}]", self.min, self.max)
134134
}
135135
}

src/cgmath/angle.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -187,31 +187,31 @@ Angle<S> for Deg<S> {
187187
#[inline] fn full_turn() -> Deg<S> { deg(cast(360).unwrap()) }
188188
}
189189

190-
#[inline] pub fn sin<S: Float>(theta: Rad<S>) -> S { theta.s.sin() }
191-
#[inline] pub fn cos<S: Float>(theta: Rad<S>) -> S { theta.s.cos() }
192-
#[inline] pub fn tan<S: Float>(theta: Rad<S>) -> S { theta.s.tan() }
193-
#[inline] pub fn sin_cos<S: Float>(theta: Rad<S>) -> (S, S) { theta.s.sin_cos() }
190+
#[inline] pub fn sin<S: FloatMath>(theta: Rad<S>) -> S { theta.s.sin() }
191+
#[inline] pub fn cos<S: FloatMath>(theta: Rad<S>) -> S { theta.s.cos() }
192+
#[inline] pub fn tan<S: FloatMath>(theta: Rad<S>) -> S { theta.s.tan() }
193+
#[inline] pub fn sin_cos<S: FloatMath>(theta: Rad<S>) -> (S, S) { theta.s.sin_cos() }
194194

195-
#[inline] pub fn cot<S: Float>(theta: Rad<S>) -> S { tan(theta).recip() }
196-
#[inline] pub fn sec<S: Float>(theta: Rad<S>) -> S { cos(theta).recip() }
197-
#[inline] pub fn csc<S: Float>(theta: Rad<S>) -> S { sin(theta).recip() }
195+
#[inline] pub fn cot<S: FloatMath>(theta: Rad<S>) -> S { tan(theta).recip() }
196+
#[inline] pub fn sec<S: FloatMath>(theta: Rad<S>) -> S { cos(theta).recip() }
197+
#[inline] pub fn csc<S: FloatMath>(theta: Rad<S>) -> S { sin(theta).recip() }
198198

199-
#[inline] pub fn asin<S: Float>(s: S) -> Rad<S> { rad(s.asin()) }
200-
#[inline] pub fn acos<S: Float>(s: S) -> Rad<S> { rad(s.acos()) }
201-
#[inline] pub fn atan<S: Float>(s: S) -> Rad<S> { rad(s.atan()) }
202-
#[inline] pub fn atan2<S: Float>(a: S, b: S) -> Rad<S> { rad(a.atan2(b)) }
199+
#[inline] pub fn asin<S: FloatMath>(s: S) -> Rad<S> { rad(s.asin()) }
200+
#[inline] pub fn acos<S: FloatMath>(s: S) -> Rad<S> { rad(s.acos()) }
201+
#[inline] pub fn atan<S: FloatMath>(s: S) -> Rad<S> { rad(s.atan()) }
202+
#[inline] pub fn atan2<S: FloatMath>(a: S, b: S) -> Rad<S> { rad(a.atan2(b)) }
203203

204204
impl<S: Float + fmt::Show>
205205
fmt::Show for Rad<S> {
206206
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
207-
write!(f.buf, "{} rad", self.s)
207+
write!(f, "{} rad", self.s)
208208
}
209209
}
210210

211211
impl<S: Float + fmt::Show>
212212
fmt::Show for Deg<S> {
213213
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
214-
write!(f.buf, "{}°", self.s)
214+
write!(f, "{}°", self.s)
215215
}
216216
}
217217

src/cgmath/matrix.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -725,15 +725,15 @@ ToQuaternion<S> for Matrix3<S> {
725725

726726
impl<S: PartOrdFloat<S> + fmt::Show> fmt::Show for Matrix2<S> {
727727
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
728-
write!(f.buf, "[[{}, {}], [{}, {}]]",
728+
write!(f, "[[{}, {}], [{}, {}]]",
729729
self.cr(0, 0), self.cr(0, 1),
730730
self.cr(1, 0), self.cr(1, 1))
731731
}
732732
}
733733

734734
impl<S: PartOrdFloat<S> + fmt::Show> fmt::Show for Matrix3<S> {
735735
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
736-
write!(f.buf, "[[{}, {}, {}], [{}, {}, {}], [{}, {}, {}]]",
736+
write!(f, "[[{}, {}, {}], [{}, {}, {}], [{}, {}, {}]]",
737737
self.cr(0, 0), self.cr(0, 1), self.cr(0, 2),
738738
self.cr(1, 0), self.cr(1, 1), self.cr(1, 2),
739739
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> {
742742

743743
impl<S: PartOrdFloat<S> + fmt::Show> fmt::Show for Matrix4<S> {
744744
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
745-
write!(f.buf, "[[{}, {}, {}, {}], [{}, {}, {}, {}], [{}, {}, {}, {}], [{}, {}, {}, {}]]",
745+
write!(f, "[[{}, {}, {}, {}], [{}, {}, {}, {}], [{}, {}, {}, {}], [{}, {}, {}, {}]]",
746746
self.cr(0, 0), self.cr(0, 1), self.cr(0, 2), self.cr(0, 3),
747747
self.cr(1, 0), self.cr(1, 1), self.cr(1, 2), self.cr(1, 3),
748748
self.cr(2, 0), self.cr(2, 1), self.cr(2, 2), self.cr(2, 3),

src/cgmath/partial_ord.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ macro_rules! gen_minmax_for_not_floats (
4646
gen_minmax_for_floats!(f32, f64)
4747
gen_minmax_for_not_floats!(int, i8, i16, i32, i64, uint, u8, u16, u32, u64)
4848

49-
pub trait PartOrdFloat<S> : Float + ApproxEq<S> + PartOrdPrim {}
49+
pub trait PartOrdFloat<S> : FloatMath + ApproxEq<S> + PartOrdPrim {}
5050
impl PartOrdFloat<f32> for f32 {}
5151
impl PartOrdFloat<f64> for f64 {}
5252

src/cgmath/plane.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ ApproxEq<S> for Plane<S> {
124124

125125
impl<S: Clone + fmt::Float> fmt::Show for Plane<S> {
126126
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
127-
write!(f.buf, "{:f}x + {:f}y + {:f}z - {:f} = 0",
127+
write!(f, "{:f}x + {:f}y + {:f}z - {:f} = 0",
128128
self.n.x, self.n.y, self.n.z, self.d)
129129
}
130130
}

src/cgmath/point.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,12 @@ impl<S: PartOrdPrim> Point<S, Vector3<S>, [S, ..3]> for Point3<S> {}
102102

103103
impl<S: fmt::Show> fmt::Show for Point2<S> {
104104
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
105-
write!(f.buf, "[{}, {}]", self.x, self.y)
105+
write!(f, "[{}, {}]", self.x, self.y)
106106
}
107107
}
108108

109109
impl<S: fmt::Show> fmt::Show for Point3<S> {
110110
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
111-
write!(f.buf, "[{}, {}, {}]", self.x, self.y, self.z)
111+
write!(f, "[{}, {}, {}]", self.x, self.y, self.z)
112112
}
113113
}

src/cgmath/projection.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use partial_ord::PartOrdFloat;
2525
///
2626
/// This is the equivalent to the [gluPerspective]
2727
/// (http://www.opengl.org/sdk/docs/man2/xhtml/gluPerspective.xml) function.
28-
pub fn perspective<S: Float, A: Angle<S>>(fovy: A, aspect: S, near: S, far: S) -> Matrix4<S> {
28+
pub fn perspective<S: FloatMath, A: Angle<S>>(fovy: A, aspect: S, near: S, far: S) -> Matrix4<S> {
2929
PerspectiveFov {
3030
fovy: fovy,
3131
aspect: aspect,
@@ -77,7 +77,7 @@ pub struct PerspectiveFov<S, A> {
7777
pub far: S,
7878
}
7979

80-
impl<S: Float, A: Angle<S>> PerspectiveFov<S, A> {
80+
impl<S: FloatMath, A: Angle<S>> PerspectiveFov<S, A> {
8181
pub fn to_perspective(&self) -> Perspective<S> {
8282
let angle = self.fovy.div_s(cast(2).unwrap());
8383
let ymax = self.near * tan(angle.to_rad());
@@ -102,7 +102,7 @@ Projection<S> for PerspectiveFov<S, A> {
102102
}
103103
}
104104

105-
impl<S: Float, A: Angle<S>> ToMatrix4<S> for PerspectiveFov<S, A> {
105+
impl<S: FloatMath, A: Angle<S>> ToMatrix4<S> for PerspectiveFov<S, A> {
106106
fn to_matrix4(&self) -> Matrix4<S> {
107107
let half_turn: A = Angle::turn_div_2();
108108

src/cgmath/quaternion.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ Neg<Quaternion<S>> for Quaternion<S> {
290290

291291
impl<S: fmt::Show> fmt::Show for Quaternion<S> {
292292
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
293-
write!(f.buf, "{} + {}i + {}j + {}k",
293+
write!(f, "{} + {}i + {}j + {}k",
294294
self.s,
295295
self.v.x,
296296
self.v.y,

src/cgmath/transform.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ Transform3<S> for Decomposed<S,Vector3<S>,R> {}
161161
impl<S: fmt::Show + Float, R: fmt::Show + Rotation3<S>>
162162
fmt::Show for Decomposed<S,Vector3<S>,R> {
163163
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
164-
write!(f.buf, "(scale({}), rot({}), disp{})",
164+
write!(f, "(scale({}), rot({}), disp{})",
165165
self.scale, self.rot, self.disp)
166166
}
167167
}

src/cgmath/vector.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,18 +304,18 @@ EuclideanVector<S, [S, ..4]> for Vector4<S> {
304304

305305
impl<S: fmt::Show> fmt::Show for Vector2<S> {
306306
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
307-
write!(f.buf, "[{}, {}]", self.x, self.y)
307+
write!(f, "[{}, {}]", self.x, self.y)
308308
}
309309
}
310310

311311
impl<S: fmt::Show> fmt::Show for Vector3<S> {
312312
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
313-
write!(f.buf, "[{}, {}, {}]", self.x, self.y, self.z)
313+
write!(f, "[{}, {}, {}]", self.x, self.y, self.z)
314314
}
315315
}
316316

317317
impl<S: fmt::Show> fmt::Show for Vector4<S> {
318318
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
319-
write!(f.buf, "[{}, {}, {}, {}]", self.x, self.y, self.z, self.w)
319+
write!(f, "[{}, {}, {}, {}]", self.x, self.y, self.z, self.w)
320320
}
321321
}

0 commit comments

Comments
 (0)