Rename dimensional acessors

index->i
col->c
row->r
elem->cr
This commit is contained in:
Brendan Zabarauskas 2013-07-22 14:41:31 +10:00
parent 1538e6e528
commit c206d7dc3c
6 changed files with 757 additions and 808 deletions

View file

@ -76,12 +76,12 @@ impl<T:Clone + Float> Frustum<T> {
/// Extracts frustum planes from a projection matrix
pub fn from_matrix(mat: Mat4<T>) -> Frustum<T> {
Frustum {
left: Plane3::from_vec4(mat.row(3).add_v(&mat.row(0)).normalize()),
right: Plane3::from_vec4(mat.row(3).sub_v(&mat.row(0)).normalize()),
bottom: Plane3::from_vec4(mat.row(3).add_v(&mat.row(1)).normalize()),
top: Plane3::from_vec4(mat.row(3).sub_v(&mat.row(1)).normalize()),
near: Plane3::from_vec4(mat.row(3).add_v(&mat.row(2)).normalize()),
far: Plane3::from_vec4(mat.row(3).sub_v(&mat.row(2)).normalize()),
left: Plane3::from_vec4(mat.r(3).add_v(&mat.r(0)).normalize()),
right: Plane3::from_vec4(mat.r(3).sub_v(&mat.r(0)).normalize()),
bottom: Plane3::from_vec4(mat.r(3).add_v(&mat.r(1)).normalize()),
top: Plane3::from_vec4(mat.r(3).sub_v(&mat.r(1)).normalize()),
near: Plane3::from_vec4(mat.r(3).add_v(&mat.r(2)).normalize()),
far: Plane3::from_vec4(mat.r(3).sub_v(&mat.r(2)).normalize()),
}
}
}

View file

@ -19,12 +19,12 @@ macro_rules! impl_dimensioned(
($Self:ident, $T:ty, $n:expr) => (
impl<T> Dimensioned<$T,[$T,..$n]> for $Self<T> {
#[inline]
pub fn index<'a>(&'a self, i: uint) -> &'a $T {
pub fn i<'a>(&'a self, i: uint) -> &'a $T {
&'a self.as_slice()[i]
}
#[inline]
pub fn index_mut<'a>(&'a mut self, i: uint) -> &'a mut $T {
pub fn mut_i<'a>(&'a mut self, i: uint) -> &'a mut $T {
&'a mut self.as_mut_slice()[i]
}
@ -99,9 +99,9 @@ macro_rules! impl_swap_components(
impl<T:Clone> SwapComponents for $Self<T> {
#[inline]
pub fn swap(&mut self, a: uint, b: uint) {
let tmp = self.index(a).clone();
*self.index_mut(a) = self.index(b).clone();
*self.index_mut(b) = tmp;
let tmp = self.i(a).clone();
*self.mut_i(a) = self.i(b).clone();
*self.mut_i(b) = tmp;
}
}
)

File diff suppressed because it is too large Load diff

View file

@ -41,8 +41,8 @@ pub mod point;
pub mod ray;
pub trait Dimensioned<T,Slice> {
pub fn index<'a>(&'a self, i: uint) -> &'a T;
pub fn index_mut<'a>(&'a mut self, i: uint) -> &'a mut T;
pub fn i<'a>(&'a self, i: uint) -> &'a T;
pub fn mut_i<'a>(&'a mut self, i: uint) -> &'a mut T;
pub fn as_slice<'a>(&'a self) -> &'a Slice;
pub fn as_mut_slice<'a>(&'a mut self) -> &'a mut Slice;
}

View file

@ -114,19 +114,19 @@ impl<T:Clone + Float> Quat<T> {
/// The sum of this quaternion and `other`
#[inline]
pub fn add_q(&self, other: &Quat<T>) -> Quat<T> {
Quat::new(*self.index(0) + *other.index(0),
*self.index(1) + *other.index(1),
*self.index(2) + *other.index(2),
*self.index(3) + *other.index(3))
Quat::new(*self.i(0) + *other.i(0),
*self.i(1) + *other.i(1),
*self.i(2) + *other.i(2),
*self.i(3) + *other.i(3))
}
/// The sum of this quaternion and `other`
#[inline]
pub fn sub_q(&self, other: &Quat<T>) -> Quat<T> {
Quat::new(*self.index(0) - *other.index(0),
*self.index(1) - *other.index(1),
*self.index(2) - *other.index(2),
*self.index(3) - *other.index(3))
Quat::new(*self.i(0) - *other.i(0),
*self.i(1) - *other.i(1),
*self.i(2) - *other.i(2),
*self.i(3) - *other.i(3))
}
/// The the result of multipliplying the quaternion by `other`

File diff suppressed because it is too large Load diff