Fixed all the warnings, compile issues, and tests

This commit is contained in:
Dzmitry Malyshau 2015-04-04 22:14:03 -04:00
parent b56ad542b3
commit 498df01729
9 changed files with 22 additions and 28 deletions

View file

@ -63,6 +63,8 @@ pub use sphere::Sphere;
pub use approx::ApproxEq;
pub use num::*;
pub use rust_num::{One, Zero, one, zero};
// Modules
mod array;

View file

@ -455,29 +455,29 @@ impl<S: BaseFloat> Sub for Matrix4<S> {
fn sub(self, other: Matrix4<S>) -> Matrix4<S> { self.sub_m(&other) }
}
impl<S: Neg> Neg for Matrix2<S> {
type Output = Matrix2<S::Output>;
impl<S: Neg<Output = S>> Neg for Matrix2<S> {
type Output = Matrix2<S>;
#[inline]
fn neg(self) -> Matrix2<S::Output> {
fn neg(self) -> Matrix2<S> {
Matrix2::from_cols(self.x.neg(), self.y.neg())
}
}
impl<S: Neg> Neg for Matrix3<S> {
type Output = Matrix3<S::Output>;
impl<S: Neg<Output = S>> Neg for Matrix3<S> {
type Output = Matrix3<S>;
#[inline]
fn neg(self) -> Matrix3<S::Output> {
fn neg(self) -> Matrix3<S> {
Matrix3::from_cols(self.x.neg(), self.y.neg(), self.z.neg())
}
}
impl<S: Neg> Neg for Matrix4<S> {
type Output = Matrix4<S::Output>;
impl<S: Neg<Output = S>> Neg for Matrix4<S> {
type Output = Matrix4<S>;
#[inline]
fn neg(self) -> Matrix4<S::Output> {
fn neg(self) -> Matrix4<S> {
Matrix4::from_cols(self.x.neg(), self.y.neg(), self.z.neg(), self.w.neg())
}
}

View file

@ -261,7 +261,8 @@ impl<
R: Rotation<S, V, P> + Clone,
> ToComponents<S, V, P, R> for Decomposed<S, V, R> {
fn decompose(&self) -> (V, R, V) {
(Vector::from_value(self.scale), self.rot.clone(), self.disp.clone())
let v: V = one();
(v.mul_s(self.scale), self.rot.clone(), self.disp.clone())
}
}

View file

@ -26,7 +26,7 @@
//!
//! assert_eq!(Vector2::new(1.0f64, 0.0f64), Vector2::unit_x());
//! assert_eq!(vec3(0.0f64, 0.0f64, 0.0f64), zero());
//! assert_eq!(Vector::from_value(1.0f64), vec2(1.0, 1.0));
//! assert_eq!(Vector2::from_value(1.0f64), vec2(1.0, 1.0));
//! ```
//!
//! Vectors can be manipulated with typical mathematical operations (addition,
@ -76,7 +76,7 @@
//!
//! // Scalar multiplication can return a new object, or be done in place
//! // to avoid an allocation:
//! let mut c: Vector4<f64> = Vector::from_value(3.0);
//! let mut c = Vector4::from_value(3f64);
//! let d: Vector4<f64> = c.mul_s(2.0);
//! c.mul_self_s(2.0);
//! assert_eq!(c, d);
@ -339,11 +339,11 @@ macro_rules! vec(
fn sub(self, v: $Self_<S>) -> $Self_<S> { self.sub_v(&v) }
}
impl<S: Neg> Neg for $Self_<S> {
type Output = $Self_<S::Output>;
impl<S: Neg<Output = S>> Neg for $Self_<S> {
type Output = $Self_<S>;
#[inline]
fn neg(self) -> $Self_<S::Output> { $Self_::new($(-self.$field),+) }
fn neg(self) -> $Self_<S> { $Self_::new($(-self.$field),+) }
}
impl<S: BaseNum> Mul for $Self_<S> {

View file

@ -13,9 +13,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#![feature(core)]
extern crate cgmath;
use cgmath::*;

View file

@ -13,8 +13,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#![feature(core)]
extern crate cgmath;
use cgmath::{ToMatrix4, ToMatrix3};

View file

@ -17,7 +17,6 @@
extern crate cgmath;
use cgmath::*;
use std::num::Float;
#[test]
fn test_intersection() {

View file

@ -50,7 +50,7 @@ fn test_components() {
disp: Vector3::new(6.0f64,-7.0,8.0)
};
let (scale, rot, disp) = t.decompose();
assert_eq!(scale, Vector::from_value(t.scale));
assert_eq!(scale, Vector3::from_value(t.scale));
assert_eq!(rot, t.rot);
assert_eq!(disp, t.disp);
}

View file

@ -13,14 +13,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#![feature(core)]
#[macro_use]
extern crate cgmath;
use cgmath::*;
use std::f64;
use std::num::Float;
#[test]
fn test_constructor() {
@ -31,9 +28,9 @@ fn test_constructor() {
#[test]
fn test_from_value() {
assert_eq!(Vector::from_value(102isize), Vector2::new(102isize, 102isize));
assert_eq!(Vector::from_value(22isize), Vector3::new(22isize, 22isize, 22isize));
assert_eq!(Vector::from_value(76.5f64), Vector4::new(76.5f64, 76.5f64, 76.5f64, 76.5f64));
assert_eq!(Vector2::from_value(102isize), Vector2::new(102isize, 102isize));
assert_eq!(Vector3::from_value(22isize), Vector3::new(22isize, 22isize, 22isize));
assert_eq!(Vector4::from_value(76.5f64), Vector4::new(76.5f64, 76.5f64, 76.5f64, 76.5f64));
}
#[test]