use the new rand_macros crate
This commit is contained in:
parent
e712bdee7c
commit
778a3c13aa
6 changed files with 21 additions and 9 deletions
|
@ -18,3 +18,5 @@ name = "cgmath"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
rustc-serialize="*"
|
rustc-serialize="*"
|
||||||
|
rand_macros="*"
|
||||||
|
rand="*"
|
|
@ -24,10 +24,12 @@ use approx::ApproxEq;
|
||||||
use num::{BaseFloat, One, one, Zero, zero};
|
use num::{BaseFloat, One, one, Zero, zero};
|
||||||
|
|
||||||
/// An angle, in radians
|
/// An angle, in radians
|
||||||
#[derive(Copy, Clone, PartialEq, PartialOrd, Hash, RustcEncodable, RustcDecodable, Rand)]
|
#[derive_Rand]
|
||||||
|
#[derive(Copy, Clone, PartialEq, PartialOrd, Hash, RustcEncodable, RustcDecodable)]
|
||||||
pub struct Rad<S> { pub s: S }
|
pub struct Rad<S> { pub s: S }
|
||||||
/// An angle, in degrees
|
/// An angle, in degrees
|
||||||
#[derive(Copy, Clone, PartialEq, PartialOrd, Hash, RustcEncodable, RustcDecodable, Rand)]
|
#[derive_Rand]
|
||||||
|
#[derive(Copy, Clone, PartialEq, PartialOrd, Hash, RustcEncodable, RustcDecodable)]
|
||||||
pub struct Deg<S> { pub s: S }
|
pub struct Deg<S> { pub s: S }
|
||||||
|
|
||||||
/// Create a new angle, in radians
|
/// Create a new angle, in radians
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
#![crate_type = "rlib"]
|
#![crate_type = "rlib"]
|
||||||
#![crate_type = "dylib"]
|
#![crate_type = "dylib"]
|
||||||
#![feature(old_impl_check)]
|
#![feature(old_impl_check, plugin)]
|
||||||
|
|
||||||
//! Computer graphics-centric math.
|
//! Computer graphics-centric math.
|
||||||
//!
|
//!
|
||||||
|
@ -32,6 +32,9 @@
|
||||||
//! These are provided for convenience.
|
//! These are provided for convenience.
|
||||||
|
|
||||||
extern crate "rustc-serialize" as rustc_serialize;
|
extern crate "rustc-serialize" as rustc_serialize;
|
||||||
|
extern crate rand;
|
||||||
|
#[plugin]
|
||||||
|
extern crate rand_macros;
|
||||||
|
|
||||||
// Re-exports
|
// Re-exports
|
||||||
|
|
||||||
|
|
|
@ -30,15 +30,18 @@ use vector::{Vector, EuclideanVector};
|
||||||
use vector::{Vector2, Vector3, Vector4};
|
use vector::{Vector2, Vector3, Vector4};
|
||||||
|
|
||||||
/// A 2 x 2, column major matrix
|
/// A 2 x 2, column major matrix
|
||||||
#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Rand)]
|
#[derive_Rand]
|
||||||
|
#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable)]
|
||||||
pub struct Matrix2<S> { pub x: Vector2<S>, pub y: Vector2<S> }
|
pub struct Matrix2<S> { pub x: Vector2<S>, pub y: Vector2<S> }
|
||||||
|
|
||||||
/// A 3 x 3, column major matrix
|
/// A 3 x 3, column major matrix
|
||||||
#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Rand)]
|
#[derive_Rand]
|
||||||
|
#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable)]
|
||||||
pub struct Matrix3<S> { pub x: Vector3<S>, pub y: Vector3<S>, pub z: Vector3<S> }
|
pub struct Matrix3<S> { pub x: Vector3<S>, pub y: Vector3<S>, pub z: Vector3<S> }
|
||||||
|
|
||||||
/// A 4 x 4, column major matrix
|
/// A 4 x 4, column major matrix
|
||||||
#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Rand)]
|
#[derive_Rand]
|
||||||
|
#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable)]
|
||||||
pub struct Matrix4<S> { pub x: Vector4<S>, pub y: Vector4<S>, pub z: Vector4<S>, pub w: Vector4<S> }
|
pub struct Matrix4<S> { pub x: Vector4<S>, pub y: Vector4<S>, pub z: Vector4<S>, pub w: Vector4<S> }
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,8 @@ use vector::{Vector3, Vector, EuclideanVector};
|
||||||
|
|
||||||
/// A [quaternion](https://en.wikipedia.org/wiki/Quaternion) in scalar/vector
|
/// A [quaternion](https://en.wikipedia.org/wiki/Quaternion) in scalar/vector
|
||||||
/// form.
|
/// form.
|
||||||
#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Rand)]
|
#[derive_Rand]
|
||||||
|
#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable)]
|
||||||
pub struct Quaternion<S> { pub s: S, pub v: Vector3<S> }
|
pub struct Quaternion<S> { pub s: S, pub v: Vector3<S> }
|
||||||
|
|
||||||
/// Represents types which can be expressed as a quaternion.
|
/// Represents types which can be expressed as a quaternion.
|
||||||
|
|
|
@ -178,7 +178,8 @@ pub trait Vector<S: BaseNum>: Array1<S> + Zero + One + Neg<Output=Self> {
|
||||||
// Utility macro for generating associated functions for the vectors
|
// Utility macro for generating associated functions for the vectors
|
||||||
macro_rules! vec(
|
macro_rules! vec(
|
||||||
($Self:ident <$S:ident> { $($field:ident),+ }, $n:expr, $constructor:ident) => (
|
($Self:ident <$S:ident> { $($field:ident),+ }, $n:expr, $constructor:ident) => (
|
||||||
#[derive(PartialEq, Eq, Copy, Clone, Hash, RustcEncodable, RustcDecodable, Rand)]
|
#[derive_Rand]
|
||||||
|
#[derive(PartialEq, Eq, Copy, Clone, Hash, RustcEncodable, RustcDecodable)]
|
||||||
pub struct $Self<S> { $(pub $field: S),+ }
|
pub struct $Self<S> { $(pub $field: S),+ }
|
||||||
|
|
||||||
impl<$S> $Self<$S> {
|
impl<$S> $Self<$S> {
|
||||||
|
|
Loading…
Reference in a new issue