diff --git a/src/lib.rs b/src/lib.rs index 25dedf3e..93c6732d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -144,8 +144,7 @@ pub use traits::{ Transform, Transformation, Translate, Translation, Transpose, - UniformSphereSample, - VecAsPnt, + UniformSphereSample }; pub use structs::{ @@ -335,28 +334,6 @@ pub fn sqdist, V: Norm>(a: &P, b: &P) -> N { a.sqdist(b) } -/* - * Perspective - */ -/// Computes a projection matrix given the frustrum near plane width, height, the field of -/// view, and the distance to the clipping planes (`znear` and `zfar`). -#[deprecated = "Use `Persp3::new(width / height, fov, znear, zfar).as_mat()` instead"] -pub fn perspective3d + Zero + One>(width: N, height: N, fov: N, znear: N, zfar: N) -> Mat4 { - let aspect = width / height; - - let _1: N = one(); - let sy = _1 / (fov * cast(0.5)).tan(); - let sx = -sy / aspect; - let sz = -(zfar + znear) / (znear - zfar); - let tz = zfar * znear * cast(2.0) / (znear - zfar); - - Mat4::new( - sx, zero(), zero(), zero(), - zero(), sy, zero(), zero(), - zero(), zero(), sz, tz, - zero(), zero(), one(), zero()) -} - /* * Translation */ diff --git a/src/structs/dmat.rs b/src/structs/dmat.rs index 7684c2b4..fa74d6c3 100644 --- a/src/structs/dmat.rs +++ b/src/structs/dmat.rs @@ -199,20 +199,6 @@ impl DMat { } impl Indexable<(usize, usize), N> for DMat { - /// Changes the value of a component of the matrix. - /// - /// # Arguments - /// * `rowcol` - 0-based tuple (row, col) to be changed - #[inline] - fn set(&mut self, rowcol: (usize, usize), val: N) { - let (row, col) = rowcol; - assert!(row < self.nrows); - assert!(col < self.ncols); - - let offset = self.offset(row, col); - self.mij[offset] = val - } - /// Just like `set` without bounds checking. #[inline] unsafe fn unsafe_set(&mut self, rowcol: (usize, usize), val: N) { @@ -221,18 +207,6 @@ impl Indexable<(usize, usize), N> for DMat { *self.mij[..].get_unchecked_mut(offset) = val } - /// Reads the value of a component of the matrix. - /// - /// # Arguments - /// * `rowcol` - 0-based tuple (row, col) to be read - #[inline] - fn at(&self, rowcol: (usize, usize)) -> N { - let (row, col) = rowcol; - assert!(row < self.nrows); - assert!(col < self.ncols); - unsafe { self.unsafe_at((row, col)) } - } - /// Just like `at` without bounds checking. #[inline] unsafe fn unsafe_at(&self, rowcol: (usize, usize)) -> N { diff --git a/src/structs/dvec_macros.rs b/src/structs/dvec_macros.rs index 60d8c86d..43f3357e 100644 --- a/src/structs/dvec_macros.rs +++ b/src/structs/dvec_macros.rs @@ -42,22 +42,6 @@ macro_rules! dvec_impl( } impl Indexable for $dvec { - #[inline] - fn at(&self, i: usize) -> N { - assert!(i < self.len()); - unsafe { - self.unsafe_at(i) - } - } - - #[inline] - fn set(&mut self, i: usize, val: N) { - assert!(i < self.len()); - unsafe { - self.unsafe_set(i, val); - } - } - #[inline] fn swap(&mut self, i: usize, j: usize) { assert!(i < self.len()); @@ -147,7 +131,7 @@ macro_rules! dvec_impl( for i in 0..dim { let mut basis_element : $dvec = $dvec::new_zeros(dim); - basis_element.set(i, ::one()); + basis_element[i] = ::one(); res.push(basis_element); } @@ -166,7 +150,7 @@ macro_rules! dvec_impl( for i in 0..dim { let mut basis_element : $dvec = $dvec::new_zeros(self.len()); - basis_element.set(i, ::one()); + basis_element[i] = ::one(); if res.len() == dim - 1 { break; diff --git a/src/structs/mat_macros.rs b/src/structs/mat_macros.rs index 07067519..b7f048a9 100644 --- a/src/structs/mat_macros.rs +++ b/src/structs/mat_macros.rs @@ -264,20 +264,6 @@ macro_rules! indexable_impl( } impl Indexable<(usize, usize), N> for $t { - #[inline] - fn at(&self, (i, j): (usize, usize)) -> N { - unsafe { - mem::transmute::<&$t, &[N; $dim * $dim]>(self)[i + j * $dim] - } - } - - #[inline] - fn set(&mut self, (i, j): (usize, usize), val: N) { - unsafe { - mem::transmute::<&mut $t, &mut [N; $dim * $dim]>(self)[i + j * $dim] = val - } - } - #[inline] fn swap(&mut self, (i1, j1): (usize, usize), (i2, j2): (usize, usize)) { unsafe { @@ -344,7 +330,7 @@ macro_rules! row_impl( #[inline] fn set_row(&mut self, row: usize, v: $tv) { for (i, e) in v.iter().enumerate() { - self.set((row, i), *e); + self[(row, i)] = *e; } } @@ -353,7 +339,7 @@ macro_rules! row_impl( let mut res: $tv = ::zero(); for (i, e) in res.iter_mut().enumerate() { - *e = self.at((row, i)); + *e = self[(row, i)]; } res @@ -385,7 +371,7 @@ macro_rules! col_impl( #[inline] fn set_col(&mut self, col: usize, v: $tv) { for (i, e) in v.iter().enumerate() { - self.set((i, col), *e); + self[(i, col)] = *e; } } @@ -394,7 +380,7 @@ macro_rules! col_impl( let mut res: $tv = ::zero(); for (i, e) in res.iter_mut().enumerate() { - *e = self.at((i, col)); + *e = self[(i, col)]; } res @@ -552,7 +538,7 @@ macro_rules! inv_impl( let mut n0 = k; // index of a non-zero entry while n0 != $dim { - if self.at((n0, k)) != ::zero() { + if self[(n0, k)] != ::zero() { break; } @@ -571,30 +557,30 @@ macro_rules! inv_impl( } } - let pivot = self.at((k, k)); + let pivot = self[(k, k)]; for j in k..$dim { - let selfval = self.at((k, j)) / pivot; - self.set((k, j), selfval); + let selfval = self[(k, j)] / pivot; + self[(k, j)] = selfval; } for j in 0..$dim { - let resval = res.at((k, j)) / pivot; - res.set((k, j), resval); + let resval = res[(k, j)] / pivot; + res[(k, j)] = resval; } for l in 0..$dim { if l != k { - let normalizer = self.at((l, k)); + let normalizer = self[(l, k)]; for j in k..$dim { - let selfval = self.at((l, j)) - self.at((k, j)) * normalizer; - self.set((l, j), selfval); + let selfval = self[(l, j)] - self[(k, j)] * normalizer; + self[(l, j)] = selfval; } for j in 0..$dim { - let resval = res.at((l, j)) - res.at((k, j)) * normalizer; - res.set((l, j), resval); + let resval = res[(l, j)] - res[(k, j)] * normalizer; + res[(l, j)] = resval; } } } @@ -668,7 +654,7 @@ macro_rules! to_homogeneous_impl( for i in 0..$dim { for j in 0..$dim { - res.set((i, j), self.at((i, j))) + res[(i, j)] = self[(i, j)] } } @@ -687,7 +673,7 @@ macro_rules! from_homogeneous_impl( for i in 0..$dim2 { for j in 0..$dim2 { - res.set((i, j), m.at((i, j))) + res[(i, j)] = m[(i, j)] } } @@ -708,7 +694,7 @@ macro_rules! outer_impl( let mut res: $m = ::zero(); for i in 0..Dim::dim(None::<$t>) { for j in 0..Dim::dim(None::<$t>) { - res.set((i, j), self.at(i) * other.at(j)) + res[(i, j)] = self[i] * other[j] } } res diff --git a/src/structs/spec/vec0.rs b/src/structs/spec/vec0.rs index 0169916d..84cf6b8b 100644 --- a/src/structs/spec/vec0.rs +++ b/src/structs/spec/vec0.rs @@ -46,15 +46,6 @@ impl Shape for vec::Vec0 { } impl Indexable for vec::Vec0 { - #[inline] - fn at(&self, _: usize) -> N { - panic!("Cannot index a Vec0.") - } - - #[inline] - fn set(&mut self, _: usize, _: N) { - } - #[inline] fn swap(&mut self, _: usize, _: usize) { } diff --git a/src/structs/vec.rs b/src/structs/vec.rs index 5b67bd24..ff1966ba 100644 --- a/src/structs/vec.rs +++ b/src/structs/vec.rs @@ -13,8 +13,8 @@ use traits::operations::{ApproxEq, POrd, POrdering, Axpy, ScalarAdd, ScalarSub, ScalarDiv, Absolute}; use traits::geometry::{Transform, Rotate, FromHomogeneous, ToHomogeneous, Dot, Norm, Translation, Translate}; -use traits::structure::{Basis, Cast, Dim, Indexable, Iterable, IterableMut, VecAsPnt, Shape, - NumVec, FloatVec, BaseFloat, BaseNum, Bounded}; +use traits::structure::{Basis, Cast, Dim, Indexable, Iterable, IterableMut, Shape, NumVec, + FloatVec, BaseFloat, BaseNum, Bounded}; use structs::pnt::{Pnt1, Pnt2, Pnt3, Pnt4, Pnt5, Pnt6}; #[cfg(feature="arbitrary")] diff --git a/src/structs/vec_macros.rs b/src/structs/vec_macros.rs index fb259110..7f9a5ed8 100644 --- a/src/structs/vec_macros.rs +++ b/src/structs/vec_macros.rs @@ -189,20 +189,6 @@ macro_rules! indexable_impl( } impl Indexable for $t { - #[inline] - fn at(&self, i: usize) -> N { - unsafe { - mem::transmute::<&$t, &[N; $dim]>(self)[i] - } - } - - #[inline] - fn set(&mut self, i: usize, val: N) { - unsafe { - mem::transmute::<&mut $t, &mut [N; $dim]>(self)[i] = val - } - } - #[inline] fn swap(&mut self, i1: usize, i2: usize) { unsafe { @@ -792,7 +778,6 @@ macro_rules! transform_impl( macro_rules! vec_as_pnt_impl( ($tv: ident, $t: ident, $($compN: ident),+) => ( impl $tv { - #[deprecated = "use `na::orig() + this_vector` instead."] #[inline] pub fn to_pnt(self) -> $t { $t::new( @@ -800,7 +785,6 @@ macro_rules! vec_as_pnt_impl( ) } - #[deprecated = "use `&(na::orig() + *this_vector)` instead."] #[inline] pub fn as_pnt(&self) -> &$t { unsafe { @@ -808,18 +792,6 @@ macro_rules! vec_as_pnt_impl( } } } - - impl VecAsPnt<$t> for $tv { - #[inline] - fn to_pnt(self) -> $t { - self.to_pnt() - } - - #[inline] - fn as_pnt(&self) -> &$t { - self.as_pnt() - } - } ) ); diff --git a/src/traits/mod.rs b/src/traits/mod.rs index 15901207..82ed7531 100644 --- a/src/traits/mod.rs +++ b/src/traits/mod.rs @@ -5,8 +5,8 @@ pub use traits::geometry::{AbsoluteRotate, Cross, CrossMatrix, Dot, FromHomogene Transform, Transformation, Translate, Translation, UniformSphereSample}; pub use traits::structure::{FloatVec, FloatPnt, Basis, Cast, Col, Dim, Indexable, Iterable, - IterableMut, Mat, SquareMat, Row, NumVec, NumPnt, PntAsVec, VecAsPnt, - ColSlice, RowSlice, Diag, Eye, Shape, BaseFloat, BaseNum, Bounded}; + IterableMut, Mat, SquareMat, Row, NumVec, NumPnt, PntAsVec, ColSlice, + RowSlice, Diag, Eye, Shape, BaseFloat, BaseNum, Bounded}; pub use traits::operations::{Absolute, ApproxEq, Axpy, Cov, Det, Inv, LMul, Mean, Outer, POrd, RMul, ScalarAdd, ScalarSub, ScalarMul, ScalarDiv, Transpose, EigenQR}; diff --git a/src/traits/structure.rs b/src/traits/structure.rs index 0f0b660f..d1bb1c3f 100644 --- a/src/traits/structure.rs +++ b/src/traits/structure.rs @@ -173,12 +173,6 @@ pub trait Shape: Index { /// Thus, this is the same as the `I` trait but without the syntactic sugar and with a method /// to write to a specific index. pub trait Indexable: Shape + IndexMut { - #[deprecated = "use the Index `[]` overloaded operator instead"] - /// Reads the `i`-th element of `self`. - fn at(&self, i: I) -> N; - #[deprecated = "use the IndexMut `[]` overloaded operator instead"] - /// Writes to the `i`-th element of `self`. - fn set(&mut self, i: I, N); /// Swaps the `i`-th element of `self` with its `j`-th element. fn swap(&mut self, i: I, j: I); @@ -211,16 +205,6 @@ pub trait IterableMut { /* * Vec related traits. */ -/// Trait that relates a point of an affine space to a vector of the associated vector space. -#[deprecated = "This will be removed in the future. Use point + vector operations instead."] -pub trait VecAsPnt

{ - /// Converts this point to its associated vector. - fn to_pnt(self) -> P; - - /// Converts a reference to this point to a reference to its associated vector. - fn as_pnt<'a>(&'a self) -> &'a P; -} - /// Trait grouping most common operations on vectors. pub trait NumVec: Dim + Sub + Add +