diff --git a/Cargo.toml b/Cargo.toml index 02b0bc4..fb45935 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,3 +15,6 @@ homepage = "https://github.com/pistondevelopers/vecmath" name = "vecmath" path = "src/lib.rs" +[dependencies] + +num = "0.1.21" diff --git a/src/consts.rs b/src/consts.rs index f7394d3..2737591 100644 --- a/src/consts.rs +++ b/src/consts.rs @@ -1,6 +1,6 @@ //! Various useful constants -use std::num::FromPrimitive; +use num::FromPrimitive; /// Useful constants for radians. pub trait Radians: FromPrimitive { @@ -65,7 +65,7 @@ impl Radians for f64 { #[cfg(test)] mod test { use super::{Radians}; - use std::num::Float; + use num::Float; #[test] fn test_f32_deg_to_rad() { diff --git a/src/lib.rs b/src/lib.rs index 8907499..0cbc054 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,6 @@ #![crate_name = "vecmath"] #![deny(missing_docs)] -#![feature(core, std_misc)] +#![feature(core)] //! A simple and generic library for vector math. //! @@ -19,7 +19,9 @@ //! For example, `row_mat2x3_transform_pos2` transforms a position. //! `row_mat2x3_transform_vec2` transforms a vector. -use std::num::{Float, NumCast, ToPrimitive}; +extern crate num; + +use num::{Float, NumCast, ToPrimitive}; pub mod consts; @@ -309,8 +311,8 @@ fn test_row_mat3x4_mul() { /// Constructs identity matrix. #[inline(always)] pub fn mat2x3_id() -> Matrix2x3 { - let one = Float::one(); - let zero = Float::zero(); + let one = T::one(); + let zero = T::zero(); [ [one, zero, zero], [zero, one, zero] @@ -320,8 +322,8 @@ pub fn mat2x3_id() -> Matrix2x3 { /// Constructs identity matrix. #[inline(always)] pub fn mat3x2_id() -> Matrix3x2 { - let one = Float::one(); - let zero = Float::zero(); + let one = T::one(); + let zero = T::zero(); [ [one, zero], [zero, one], @@ -332,8 +334,8 @@ pub fn mat3x2_id() -> Matrix3x2 { /// Constructs identity matrix. #[inline(always)] pub fn mat3_id() -> Matrix3 { - let one = Float::one(); - let zero = Float::zero(); + let one = T::one(); + let zero = T::zero(); [ [one, zero, zero], [zero, one, zero], @@ -344,8 +346,8 @@ pub fn mat3_id() -> Matrix3 { /// Constructs identity matrix. #[inline(always)] pub fn mat3x4_id() -> Matrix3x4 { - let one = Float::one(); - let zero = Float::zero(); + let one = T::one(); + let zero = T::zero(); [ [one, zero, zero, zero], [zero, one, zero, zero], @@ -356,8 +358,8 @@ pub fn mat3x4_id() -> Matrix3x4 { /// Constructs identity matrix. #[inline(always)] pub fn mat4x3_id() -> Matrix4x3 { - let one = Float::one(); - let zero = Float::zero(); + let one = T::one(); + let zero = T::zero(); [ [one, zero, zero], [zero, one, zero], @@ -369,8 +371,8 @@ pub fn mat4x3_id() -> Matrix4x3 { /// Constructs identity matrix. #[inline(always)] pub fn mat4_id() -> Matrix4 { - let one = Float::one(); - let zero = Float::zero(); + let one = T::one(); + let zero = T::zero(); [ [one, zero, zero, zero], [zero, one, zero, zero], @@ -809,21 +811,21 @@ pub fn vec4_len(a: Vector4) -> T { /// Computes the inverse length of a vector. #[inline(always)] pub fn vec2_inv_len(a: Vector2) -> T { - let one: T = Float::one(); + let one = T::one(); one / vec2_len(a) } /// Computes the inverse length of a vector. #[inline(always)] pub fn vec3_inv_len(a: Vector3) -> T { - let one: T = Float::one(); + let one = T::one(); one / vec3_len(a) } /// Computes the inverse length of a vector. #[inline(always)] pub fn vec4_inv_len(a: Vector4) -> T { - let one: T = Float::one(); + let one = T::one(); one / vec4_len(a) } @@ -1325,42 +1327,42 @@ pub fn mat4_det(mat: Matrix4) -> T { /// Computes inverse determinant of a 2x3 matrix. #[inline(always)] pub fn mat2x3_inv_det(mat: Matrix2x3) -> T { - let one: T = Float::one(); + let one = T::one(); one / mat2x3_det(mat) } /// Computes inverse determinant of a 3x2 matrix. #[inline(always)] pub fn mat3x2_inv_det(mat: Matrix3x2) -> T { - let one: T = Float::one(); + let one = T::one(); one / mat3x2_det(mat) } /// Computes inverse determinant of a 3x3 matrix. #[inline(always)] pub fn mat3_inv_det(mat: Matrix3) -> T { - let one: T = Float::one(); + let one = T::one(); one / mat3_det(mat) } /// Computes inverse determinant of a 3x4 matrix. #[inline(always)] pub fn mat3x4_inv_det(mat: Matrix3x4) -> T { - let one: T = Float::one(); + let one = T::one(); one / mat3x4_det(mat) } /// Computes inverse determinant of a 4x3 matrix. #[inline(always)] pub fn mat4x3_inv_det(mat: Matrix4x3) -> T { - let one: T = Float::one(); + let one = T::one(); one / mat4x3_det(mat) } /// Computes the inverse determinant of a 4x4 matrix. #[inline(always)] pub fn mat4_inv_det(mat: Matrix4) -> T { - let one: T = Float::one(); + let one = T::one(); one / mat4_det(mat) }