Merge pull request #64 from Connorcpu/master
Updated to latest rust master
This commit is contained in:
commit
4979e3e6c3
@ -6,6 +6,7 @@ extern crate "nalgebra" as na;
|
||||
use std::rand::{IsaacRng, Rng};
|
||||
use test::Bencher;
|
||||
use na::{Vec2, Vec3, Vec4, Mat2, Mat3, Mat4};
|
||||
use std::ops::{Add, Sub, Mul, Div};
|
||||
|
||||
#[path="common/macros.rs"]
|
||||
mod macros;
|
||||
|
@ -6,6 +6,7 @@ extern crate "nalgebra" as na;
|
||||
use std::rand::{IsaacRng, Rng};
|
||||
use test::Bencher;
|
||||
use na::{Quat, UnitQuat, Vec3};
|
||||
use std::ops::{Add, Sub, Mul, Div};
|
||||
|
||||
#[path="common/macros.rs"]
|
||||
mod macros;
|
||||
|
@ -6,6 +6,7 @@ extern crate "nalgebra" as na;
|
||||
use std::rand::{IsaacRng, Rng};
|
||||
use test::Bencher;
|
||||
use na::{Vec2, Vec3, Vec4};
|
||||
use std::ops::{Add, Sub, Mul, Div};
|
||||
|
||||
#[path="common/macros.rs"]
|
||||
mod macros;
|
||||
|
@ -84,6 +84,7 @@ Feel free to add your project to this list if you happen to use **nalgebra**!
|
||||
#![warn(missing_docs)]
|
||||
#![feature(macro_rules)]
|
||||
#![feature(globs)]
|
||||
#![feature(old_orphan_check)]
|
||||
#![doc(html_root_url = "http://nalgebra.org/doc")]
|
||||
|
||||
extern crate "rustc-serialize" as rustc_serialize;
|
||||
@ -92,6 +93,7 @@ extern crate "rustc-serialize" as rustc_serialize;
|
||||
extern crate test;
|
||||
|
||||
use std::cmp;
|
||||
use std::ops::*;
|
||||
pub use traits::{
|
||||
Absolute,
|
||||
AbsoluteRotate,
|
||||
|
@ -2,6 +2,7 @@ use traits::operations::{Transpose, ApproxEq};
|
||||
use traits::structure::{ColSlice, Eye, Indexable, Diag, SquareMat, BaseFloat};
|
||||
use traits::geometry::Norm;
|
||||
use std::cmp::min;
|
||||
use std::ops::*;
|
||||
|
||||
/// Get the householder matrix corresponding to a reflexion to the hyperplane
|
||||
/// defined by `vec`. It can be a reflexion contained in a subspace.
|
||||
|
@ -6,6 +6,7 @@ use std::cmp;
|
||||
use std::iter::repeat;
|
||||
use std::rand::Rand;
|
||||
use std::rand;
|
||||
use std::ops::*;
|
||||
use traits::operations::ApproxEq;
|
||||
use std::mem;
|
||||
use structs::dvec::DVec;
|
||||
@ -15,7 +16,7 @@ use std::fmt::{Show, Formatter, Result};
|
||||
|
||||
|
||||
/// Matrix with dimensions unknown at compile-time.
|
||||
#[deriving(Eq, PartialEq, Clone)]
|
||||
#[derive(Eq, PartialEq, Clone)]
|
||||
pub struct DMat<N> {
|
||||
nrows: uint,
|
||||
ncols: uint,
|
||||
|
@ -7,12 +7,13 @@ use std::rand;
|
||||
use std::slice::{Iter, IterMut};
|
||||
use std::iter::FromIterator;
|
||||
use std::iter::repeat;
|
||||
use std::ops::*;
|
||||
use traits::operations::{ApproxEq, Axpy};
|
||||
use traits::geometry::{Dot, Norm};
|
||||
use traits::structure::{Iterable, IterableMut, Indexable, Shape, BaseFloat, BaseNum, Zero, One};
|
||||
|
||||
/// Heap allocated, dynamically sized vector.
|
||||
#[deriving(Eq, PartialEq, Show, Clone)]
|
||||
#[derive(Eq, PartialEq, Show, Clone)]
|
||||
pub struct DVec<N> {
|
||||
/// Components of the vector. Contains as much elements as the vector dimension.
|
||||
pub at: Vec<N>
|
||||
|
@ -2,6 +2,8 @@
|
||||
|
||||
#![allow(missing_docs)]
|
||||
|
||||
use std::ops::*;
|
||||
|
||||
use std::rand::{Rand, Rng};
|
||||
use structs::mat::{Mat3, Mat4, Mat5};
|
||||
use traits::structure::{Cast, Dim, Col, BaseFloat, BaseNum, One};
|
||||
@ -18,7 +20,7 @@ use structs::rot::{Rot2, Rot3, Rot4};
|
||||
///
|
||||
/// This is the composition of a rotation followed by a translation.
|
||||
/// Isometries conserve angles and distances, hence do not allow shearing nor scaling.
|
||||
#[deriving(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Show, Copy)]
|
||||
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Show, Copy)]
|
||||
pub struct Iso2<N> {
|
||||
/// The rotation applicable by this isometry.
|
||||
pub rotation: Rot2<N>,
|
||||
@ -30,7 +32,7 @@ pub struct Iso2<N> {
|
||||
///
|
||||
/// This is the composition of a rotation followed by a translation.
|
||||
/// Isometries conserve angles and distances, hence do not allow shearing nor scaling.
|
||||
#[deriving(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Show, Copy)]
|
||||
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Show, Copy)]
|
||||
pub struct Iso3<N> {
|
||||
/// The rotation applicable by this isometry.
|
||||
pub rotation: Rot3<N>,
|
||||
@ -41,7 +43,7 @@ pub struct Iso3<N> {
|
||||
/// Four dimensional isometry.
|
||||
///
|
||||
/// Isometries conserve angles and distances, hence do not allow shearing nor scaling.
|
||||
#[deriving(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Show, Copy)]
|
||||
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Show, Copy)]
|
||||
pub struct Iso4<N> {
|
||||
/// The rotation applicable by this isometry.
|
||||
pub rotation: Rot4<N>,
|
||||
|
@ -2,6 +2,8 @@
|
||||
|
||||
#![allow(missing_docs)] // we allow missing to avoid having to document the mij components.
|
||||
|
||||
use std::ops::*;
|
||||
|
||||
use std::mem;
|
||||
use traits::operations::ApproxEq;
|
||||
use std::slice::{Iter, IterMut};
|
||||
@ -17,7 +19,7 @@ use linalg;
|
||||
|
||||
|
||||
/// Special identity matrix. All its operation are no-ops.
|
||||
#[deriving(Eq, PartialEq, RustcDecodable, Clone, Rand, Show, Copy)]
|
||||
#[derive(Eq, PartialEq, RustcDecodable, Clone, Rand, Show, Copy)]
|
||||
pub struct Identity;
|
||||
|
||||
impl Identity {
|
||||
@ -29,7 +31,7 @@ impl Identity {
|
||||
}
|
||||
|
||||
/// Square matrix of dimension 1.
|
||||
#[deriving(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Rand, Show, Copy)]
|
||||
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Rand, Show, Copy)]
|
||||
pub struct Mat1<N> {
|
||||
pub m11: N
|
||||
}
|
||||
@ -73,7 +75,7 @@ outer_impl!(Vec1, Mat1);
|
||||
eigen_qr_impl!(Mat1, Vec1);
|
||||
|
||||
/// Square matrix of dimension 2.
|
||||
#[deriving(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Rand, Show, Copy)]
|
||||
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Rand, Show, Copy)]
|
||||
pub struct Mat2<N> {
|
||||
pub m11: N, pub m21: N,
|
||||
pub m12: N, pub m22: N
|
||||
@ -121,7 +123,7 @@ outer_impl!(Vec2, Mat2);
|
||||
eigen_qr_impl!(Mat2, Vec2);
|
||||
|
||||
/// Square matrix of dimension 3.
|
||||
#[deriving(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Rand, Show, Copy)]
|
||||
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Rand, Show, Copy)]
|
||||
pub struct Mat3<N> {
|
||||
pub m11: N, pub m21: N, pub m31: N,
|
||||
pub m12: N, pub m22: N, pub m32: N,
|
||||
@ -203,7 +205,7 @@ outer_impl!(Vec3, Mat3);
|
||||
eigen_qr_impl!(Mat3, Vec3);
|
||||
|
||||
/// Square matrix of dimension 4.
|
||||
#[deriving(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Rand, Show, Copy)]
|
||||
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Rand, Show, Copy)]
|
||||
pub struct Mat4<N> {
|
||||
pub m11: N, pub m21: N, pub m31: N, pub m41: N,
|
||||
pub m12: N, pub m22: N, pub m32: N, pub m42: N,
|
||||
@ -303,7 +305,7 @@ outer_impl!(Vec4, Mat4);
|
||||
eigen_qr_impl!(Mat4, Vec4);
|
||||
|
||||
/// Square matrix of dimension 5.
|
||||
#[deriving(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Rand, Show, Copy)]
|
||||
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Rand, Show, Copy)]
|
||||
pub struct Mat5<N> {
|
||||
pub m11: N, pub m21: N, pub m31: N, pub m41: N, pub m51: N,
|
||||
pub m12: N, pub m22: N, pub m32: N, pub m42: N, pub m52: N,
|
||||
@ -417,7 +419,7 @@ outer_impl!(Vec5, Mat5);
|
||||
eigen_qr_impl!(Mat5, Vec5);
|
||||
|
||||
/// Square matrix of dimension 6.
|
||||
#[deriving(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Rand, Show, Copy)]
|
||||
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Rand, Show, Copy)]
|
||||
pub struct Mat6<N> {
|
||||
pub m11: N, pub m21: N, pub m31: N, pub m41: N, pub m51: N, pub m61: N,
|
||||
pub m12: N, pub m22: N, pub m32: N, pub m42: N, pub m52: N, pub m62: N,
|
||||
|
@ -5,7 +5,7 @@ use structs::{Pnt3, Vec3, Mat4};
|
||||
/// A 3D orthographic projection stored without any matrix.
|
||||
///
|
||||
/// Reading or modifying its individual properties is cheap but applying the transformation is costly.
|
||||
#[deriving(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Show, Copy)]
|
||||
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Show, Copy)]
|
||||
pub struct Ortho3<N> {
|
||||
width: N,
|
||||
height: N,
|
||||
@ -16,7 +16,7 @@ pub struct Ortho3<N> {
|
||||
/// A 3D orthographic projection stored as a 4D matrix.
|
||||
///
|
||||
/// Reading or modifying its individual properties is costly but applying the transformation is cheap.
|
||||
#[deriving(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Show, Copy)]
|
||||
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Show, Copy)]
|
||||
pub struct OrthoMat3<N> {
|
||||
mat: Mat4<N>
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ use structs::{Pnt3, Vec3, Mat4};
|
||||
/// A 3D perspective projection stored without any matrix.
|
||||
///
|
||||
/// Reading or modifying its individual properties is cheap but applying the transformation is costly.
|
||||
#[deriving(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Show, Copy)]
|
||||
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Show, Copy)]
|
||||
pub struct Persp3<N> {
|
||||
aspect: N,
|
||||
fov: N,
|
||||
@ -15,7 +15,7 @@ pub struct Persp3<N> {
|
||||
/// A 3D perspective projection stored as a 4D matrix.
|
||||
///
|
||||
/// Reading or modifying its individual properties is costly but applying the transformation is cheap.
|
||||
#[deriving(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Show, Copy)]
|
||||
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Show, Copy)]
|
||||
pub struct PerspMat3<N> {
|
||||
mat: Mat4<N>
|
||||
}
|
||||
|
@ -5,6 +5,7 @@
|
||||
use std::mem;
|
||||
use std::slice::{Iter, IterMut};
|
||||
use std::iter::{Iterator, FromIterator};
|
||||
use std::ops::*;
|
||||
use traits::operations::{ApproxEq, POrd, POrdering, Axpy, ScalarAdd, ScalarSub, ScalarMul,
|
||||
ScalarDiv};
|
||||
use traits::structure::{Cast, Dim, Indexable, Iterable, IterableMut, PntAsVec, Shape,
|
||||
@ -14,7 +15,7 @@ use structs::vec::{Vec1, Vec2, Vec3, Vec4, Vec5, Vec6};
|
||||
|
||||
|
||||
/// Point of dimension 0.
|
||||
#[deriving(Eq, PartialEq, RustcDecodable, Clone, Rand, Show, Copy)]
|
||||
#[derive(Eq, PartialEq, RustcDecodable, Clone, Rand, Show, Copy)]
|
||||
pub struct Pnt0<N>;
|
||||
|
||||
impl<N> Pnt0<N> {
|
||||
@ -32,7 +33,7 @@ impl<N> Pnt0<N> {
|
||||
}
|
||||
|
||||
/// Point of dimension 1.
|
||||
#[deriving(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Rand, Show, Copy)]
|
||||
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Rand, Show, Copy)]
|
||||
pub struct Pnt1<N> {
|
||||
/// First component of the point.
|
||||
pub x: N
|
||||
@ -70,7 +71,7 @@ pnt_from_homogeneous_impl!(Pnt1, Pnt2, y, x);
|
||||
num_float_pnt_impl!(Pnt1, Vec1);
|
||||
|
||||
/// Point of dimension 2.
|
||||
#[deriving(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Rand, Show, Copy)]
|
||||
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Rand, Show, Copy)]
|
||||
pub struct Pnt2<N> {
|
||||
/// First component of the point.
|
||||
pub x: N,
|
||||
@ -110,7 +111,7 @@ pnt_from_homogeneous_impl!(Pnt2, Pnt3, z, x, y);
|
||||
num_float_pnt_impl!(Pnt2, Vec2);
|
||||
|
||||
/// Point of dimension 3.
|
||||
#[deriving(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Rand, Show, Copy)]
|
||||
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Rand, Show, Copy)]
|
||||
pub struct Pnt3<N> {
|
||||
/// First component of the point.
|
||||
pub x: N,
|
||||
@ -152,7 +153,7 @@ pnt_from_homogeneous_impl!(Pnt3, Pnt4, w, x, y, z);
|
||||
num_float_pnt_impl!(Pnt3, Vec3);
|
||||
|
||||
/// Point of dimension 4.
|
||||
#[deriving(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Rand, Show, Copy)]
|
||||
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Rand, Show, Copy)]
|
||||
pub struct Pnt4<N> {
|
||||
/// First component of the point.
|
||||
pub x: N,
|
||||
@ -196,7 +197,7 @@ pnt_from_homogeneous_impl!(Pnt4, Pnt5, a, x, y, z, w);
|
||||
num_float_pnt_impl!(Pnt4, Vec4);
|
||||
|
||||
/// Point of dimension 5.
|
||||
#[deriving(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Rand, Show, Copy)]
|
||||
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Rand, Show, Copy)]
|
||||
pub struct Pnt5<N> {
|
||||
/// First component of the point.
|
||||
pub x: N,
|
||||
@ -242,7 +243,7 @@ pnt_from_homogeneous_impl!(Pnt5, Pnt6, b, x, y, z, w, a);
|
||||
num_float_pnt_impl!(Pnt5, Vec5);
|
||||
|
||||
/// Point of dimension 6.
|
||||
#[deriving(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Rand, Show, Copy)]
|
||||
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Rand, Show, Copy)]
|
||||
pub struct Pnt6<N> {
|
||||
/// First component of the point.
|
||||
pub x: N,
|
||||
|
@ -6,6 +6,8 @@ use std::mem;
|
||||
use std::num;
|
||||
use std::rand::{Rand, Rng};
|
||||
use std::slice::{Iter, IterMut};
|
||||
use std::ops::*;
|
||||
use std::iter::FromIterator;
|
||||
use structs::{Vec3, Pnt3, Rot3, Mat3};
|
||||
use traits::operations::{ApproxEq, Inv, POrd, POrdering, Axpy, ScalarAdd, ScalarSub, ScalarMul,
|
||||
ScalarDiv};
|
||||
@ -14,7 +16,7 @@ use traits::structure::{Cast, Indexable, Iterable, IterableMut, Dim, Shape, Base
|
||||
use traits::geometry::{Norm, Rotation, Rotate, Transform};
|
||||
|
||||
/// A quaternion.
|
||||
#[deriving(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Rand, Show, Copy)]
|
||||
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Rand, Show, Copy)]
|
||||
pub struct Quat<N> {
|
||||
/// The scalar component of the quaternion.
|
||||
pub w: N,
|
||||
@ -140,7 +142,7 @@ impl<N: ApproxEq<N> + BaseFloat> Div<Quat<N>, Quat<N>> for Quat<N> {
|
||||
}
|
||||
|
||||
/// A unit quaternion that can represent a 3D rotation.
|
||||
#[deriving(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Show, Copy)]
|
||||
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Show, Copy)]
|
||||
pub struct UnitQuat<N> {
|
||||
q: Quat<N>
|
||||
}
|
||||
|
@ -2,6 +2,8 @@
|
||||
|
||||
#![allow(missing_docs)]
|
||||
|
||||
use std::ops::*;
|
||||
|
||||
use std::rand::{Rand, Rng};
|
||||
use traits::geometry::{Rotate, Rotation, AbsoluteRotate, RotationMatrix, Transform, ToHomogeneous,
|
||||
Norm, Cross};
|
||||
@ -13,7 +15,7 @@ use structs::mat::{Mat2, Mat3, Mat4, Mat5};
|
||||
|
||||
|
||||
/// Two dimensional rotation matrix.
|
||||
#[deriving(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Show, Hash, Copy)]
|
||||
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Show, Hash, Copy)]
|
||||
pub struct Rot2<N> {
|
||||
submat: Mat2<N>
|
||||
}
|
||||
@ -90,7 +92,7 @@ impl<N: BaseFloat> AbsoluteRotate<Vec2<N>> for Rot2<N> {
|
||||
* 3d rotation
|
||||
*/
|
||||
/// Three dimensional rotation matrix.
|
||||
#[deriving(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Show, Hash, Copy)]
|
||||
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Show, Hash, Copy)]
|
||||
pub struct Rot3<N> {
|
||||
submat: Mat3<N>
|
||||
}
|
||||
@ -288,7 +290,7 @@ impl<N: BaseFloat> AbsoluteRotate<Vec3<N>> for Rot3<N> {
|
||||
}
|
||||
|
||||
/// Four dimensional rotation matrix.
|
||||
#[deriving(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Show, Hash, Copy)]
|
||||
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Show, Hash, Copy)]
|
||||
pub struct Rot4<N> {
|
||||
submat: Mat4<N>
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ use traits::operations::{Inv, Transpose};
|
||||
use traits::structure::{Zero, One};
|
||||
use traits::geometry::{Translation, Translate, Rotation, Rotate, Transformation, Transform,
|
||||
AbsoluteRotate};
|
||||
use std::ops::*;
|
||||
|
||||
impl One for mat::Identity {
|
||||
#[inline]
|
||||
|
@ -3,6 +3,7 @@ use structs::pnt::{Pnt2, Pnt3};
|
||||
use structs::mat::{Mat1, Mat2, Mat3};
|
||||
use traits::operations::{Inv, Det, ApproxEq};
|
||||
use traits::structure::{Row, Col, BaseNum};
|
||||
use std::ops::*;
|
||||
|
||||
// some specializations:
|
||||
impl<N: BaseNum + ApproxEq<N>> Inv for Mat1<N> {
|
||||
|
@ -2,6 +2,7 @@ use traits::structure::{Cast, Row, Basis, BaseFloat, Zero, One};
|
||||
use traits::geometry::{Norm, Cross, CrossMatrix, UniformSphereSample};
|
||||
use structs::vec::{Vec1, Vec2, Vec3, Vec4};
|
||||
use structs::mat::Mat3;
|
||||
use std::ops::*;
|
||||
|
||||
impl<N: Copy + Mul<N, N> + Sub<N, N>> Cross<Vec1<N>> for Vec2<N> {
|
||||
#[inline]
|
||||
|
@ -1,6 +1,7 @@
|
||||
use std::mem;
|
||||
use std::slice::{Iter, IterMut};
|
||||
use std::iter::{Iterator, FromIterator};
|
||||
use std::ops::*;
|
||||
use traits::operations::ApproxEq;
|
||||
use traits::structure::{Iterable, IterableMut, Indexable, Basis, Dim, Shape, BaseFloat, BaseNum,
|
||||
Zero, One, Bounded};
|
||||
|
@ -5,6 +5,7 @@
|
||||
use std::mem;
|
||||
use std::slice::{Iter, IterMut};
|
||||
use std::iter::{Iterator, FromIterator};
|
||||
use std::ops::*;
|
||||
use traits::operations::{ApproxEq, POrd, POrdering, Axpy, ScalarAdd, ScalarSub, ScalarMul,
|
||||
ScalarDiv, Absolute};
|
||||
use traits::geometry::{Transform, Rotate, FromHomogeneous, ToHomogeneous, Dot, Norm,
|
||||
@ -15,7 +16,7 @@ use structs::pnt::{Pnt1, Pnt2, Pnt3, Pnt4, Pnt5, Pnt6};
|
||||
|
||||
|
||||
/// Vector of dimension 0.
|
||||
#[deriving(Eq, PartialEq, RustcDecodable, Clone, Rand, Zero, Show, Copy)]
|
||||
#[derive(Eq, PartialEq, RustcDecodable, Clone, Rand, Zero, Show, Copy)]
|
||||
pub struct Vec0<N>;
|
||||
|
||||
impl<N> Vec0<N> {
|
||||
@ -33,7 +34,7 @@ impl<N> Vec0<N> {
|
||||
}
|
||||
|
||||
/// Vector of dimension 1.
|
||||
#[deriving(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Rand, Show, Copy)]
|
||||
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Rand, Show, Copy)]
|
||||
pub struct Vec1<N> {
|
||||
/// First component of the vector.
|
||||
pub x: N
|
||||
@ -82,7 +83,7 @@ num_float_vec_impl!(Vec1);
|
||||
absolute_vec_impl!(Vec1, x);
|
||||
|
||||
/// Vector of dimension 2.
|
||||
#[deriving(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Rand, Zero, Show, Copy)]
|
||||
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Rand, Zero, Show, Copy)]
|
||||
pub struct Vec2<N> {
|
||||
/// First component of the vector.
|
||||
pub x: N,
|
||||
@ -133,7 +134,7 @@ num_float_vec_impl!(Vec2);
|
||||
absolute_vec_impl!(Vec2, x, y);
|
||||
|
||||
/// Vector of dimension 3.
|
||||
#[deriving(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Rand, Zero, Show, Copy)]
|
||||
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Rand, Zero, Show, Copy)]
|
||||
pub struct Vec3<N> {
|
||||
/// First component of the vector.
|
||||
pub x: N,
|
||||
@ -187,7 +188,7 @@ absolute_vec_impl!(Vec3, x, y, z);
|
||||
|
||||
|
||||
/// Vector of dimension 4.
|
||||
#[deriving(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Rand, Zero, Show, Copy)]
|
||||
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Rand, Zero, Show, Copy)]
|
||||
pub struct Vec4<N> {
|
||||
/// First component of the vector.
|
||||
pub x: N,
|
||||
@ -242,7 +243,7 @@ num_float_vec_impl!(Vec4);
|
||||
absolute_vec_impl!(Vec4, x, y, z, w);
|
||||
|
||||
/// Vector of dimension 5.
|
||||
#[deriving(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Rand, Zero, Show, Copy)]
|
||||
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Rand, Zero, Show, Copy)]
|
||||
pub struct Vec5<N> {
|
||||
/// First component of the vector.
|
||||
pub x: N,
|
||||
@ -299,7 +300,7 @@ num_float_vec_impl!(Vec5);
|
||||
absolute_vec_impl!(Vec5, x, y, z, w, a);
|
||||
|
||||
/// Vector of dimension 6.
|
||||
#[deriving(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Rand, Zero, Show, Copy)]
|
||||
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Rand, Zero, Show, Copy)]
|
||||
pub struct Vec6<N> {
|
||||
/// First component of the vector.
|
||||
pub x: N,
|
||||
|
@ -1,5 +1,6 @@
|
||||
//! Traits of operations having a well-known or explicit geometric meaning.
|
||||
|
||||
use std::ops::*;
|
||||
|
||||
use traits::structure::{BaseFloat, Mat};
|
||||
|
||||
@ -82,7 +83,7 @@ pub trait Rotate<V> {
|
||||
///
|
||||
/// Those operations are automatically implemented in term of the `Rotation` and `Translation`
|
||||
/// traits.
|
||||
pub trait RotationWithTranslation<LV: Neg<LV> + Copy, AV>: Rotation<AV> + Translation<LV> {
|
||||
pub trait RotationWithTranslation<LV: Neg<LV> + Copy, AV>: Rotation<AV> + Translation<LV> + Sized {
|
||||
/// Applies a rotation centered on a specific point.
|
||||
///
|
||||
/// # Arguments
|
||||
|
@ -1,10 +1,13 @@
|
||||
//! Low level operations on vectors and matrices.
|
||||
|
||||
use std::num::{Float, SignedInt};
|
||||
use std::ops::*;
|
||||
use std::cmp::*;
|
||||
use std::cmp::Ordering::*;
|
||||
use traits::structure::SquareMat;
|
||||
|
||||
/// Result of a partial ordering.
|
||||
#[deriving(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Show, Copy)]
|
||||
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Show, Copy)]
|
||||
pub enum POrdering {
|
||||
/// Result of a strict comparison.
|
||||
PartialLess,
|
||||
@ -149,7 +152,7 @@ pub trait POrd {
|
||||
}
|
||||
|
||||
/// Trait for testing approximate equality
|
||||
pub trait ApproxEq<Eps> {
|
||||
pub trait ApproxEq<Eps>: Sized {
|
||||
/// Default epsilon for approximation.
|
||||
fn approx_epsilon(unused_self: Option<Self>) -> Eps;
|
||||
|
||||
|
@ -4,6 +4,7 @@ use std::f32;
|
||||
use std::f64;
|
||||
use std::num::{Int, Float, FloatMath};
|
||||
use std::slice::{Iter, IterMut};
|
||||
use std::ops::*;
|
||||
use traits::operations::{RMul, LMul, Axpy, Transpose, Inv, Absolute};
|
||||
use traits::geometry::{Dot, Norm, Orig};
|
||||
|
||||
@ -268,7 +269,7 @@ pub trait NumPnt<N, V>:
|
||||
}
|
||||
|
||||
/// Trait of points with components implementing the `BaseFloat` trait.
|
||||
pub trait FloatPnt<N: BaseFloat, V: Norm<N>>: NumPnt<N, V> {
|
||||
pub trait FloatPnt<N: BaseFloat, V: Norm<N>>: NumPnt<N, V> + Sized {
|
||||
/// Computes the square distance between two points.
|
||||
#[inline]
|
||||
fn sqdist(&self, other: &Self) -> N {
|
||||
|
Loading…
Reference in New Issue
Block a user