Fix to make it work with the new compiler.
This commit is contained in:
parent
854dda73bf
commit
cfd7bac305
21
doc/rust.css
21
doc/rust.css
|
@ -12,41 +12,38 @@ body {
|
|||
}
|
||||
|
||||
h1 {
|
||||
font-size: 20pt;
|
||||
margin-top: 2em;
|
||||
font-size: 24pt;
|
||||
margin-top: 1.6em;
|
||||
padding-left: 0.4em;
|
||||
line-height: 1.6em;
|
||||
background-color:#FFF2CE;
|
||||
border-radius: 0.2em;
|
||||
border: 1px solid rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 15pt;
|
||||
margin-top: 2em;
|
||||
padding-left: 0.4em;
|
||||
font-size: 16pt;
|
||||
margin-top: 1.6em;
|
||||
padding: 0.2em 0.5em;
|
||||
background-color:#FFF2CE;
|
||||
border-radius: 0.4em;
|
||||
border: 1px solid rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
|
||||
h2 code {
|
||||
color: #097334;
|
||||
font-size: 15pt;
|
||||
font-size: 16pt;
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-size: 13pt;
|
||||
font-size: 14pt;
|
||||
color: black;
|
||||
background-color:#D9E7FF;
|
||||
border-radius: 0.4em;
|
||||
border: 1px solid rgba(0, 0, 0, 0.15);
|
||||
padding: 0 0.4em 0 0.4em;
|
||||
padding: 0.2em 0.5em;
|
||||
}
|
||||
|
||||
h3 code {
|
||||
color: #541800;
|
||||
font-size: 13pt;
|
||||
font-size: 14pt;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ impl<M: Copy> Rotmat<M>
|
|||
{
|
||||
#[inline(always)]
|
||||
fn submat(&self) -> M
|
||||
{ self.submat }
|
||||
{ copy self.submat }
|
||||
}
|
||||
|
||||
pub fn rotmat2<N: Copy + Trigonometric + Neg<N>>(angle: N) -> Rotmat<Mat2<N>>
|
||||
|
@ -31,7 +31,7 @@ pub fn rotmat2<N: Copy + Trigonometric + Neg<N>>(angle: N) -> Rotmat<Mat2<N>>
|
|||
let sia = angle.sin();
|
||||
|
||||
Rotmat
|
||||
{ submat: Mat2::new(coa, -sia, sia, coa) }
|
||||
{ submat: Mat2::new(copy coa, -sia, copy sia, copy coa) }
|
||||
}
|
||||
|
||||
pub fn rotmat3<N: Copy + Trigonometric + Neg<N> + One + Sub<N, N> + Add<N, N> +
|
||||
|
@ -39,9 +39,9 @@ pub fn rotmat3<N: Copy + Trigonometric + Neg<N> + One + Sub<N, N> + Add<N, N> +
|
|||
(axis: &Vec3<N>, angle: N) -> Rotmat<Mat3<N>>
|
||||
{
|
||||
let _1 = One::one::<N>();
|
||||
let ux = axis.x;
|
||||
let uy = axis.y;
|
||||
let uz = axis.z;
|
||||
let ux = copy axis.x;
|
||||
let uy = copy axis.y;
|
||||
let uz = copy axis.z;
|
||||
let sqx = ux * ux;
|
||||
let sqy = uy * uy;
|
||||
let sqz = uz * uz;
|
||||
|
@ -74,7 +74,7 @@ Rotation<Vec1<N>> for Rotmat<Mat2<N>>
|
|||
|
||||
#[inline(always)]
|
||||
fn rotated(&self, rot: &Vec1<N>) -> Rotmat<Mat2<N>>
|
||||
{ rotmat2(rot.x) * *self }
|
||||
{ rotmat2(copy rot.x) * *self }
|
||||
|
||||
#[inline(always)]
|
||||
fn rotate(&mut self, rot: &Vec1<N>)
|
||||
|
@ -153,7 +153,7 @@ impl<M: Copy> DeltaTransform<M> for Rotmat<M>
|
|||
{
|
||||
#[inline(always)]
|
||||
fn delta_transform(&self) -> M
|
||||
{ self.submat }
|
||||
{ copy self.submat }
|
||||
}
|
||||
|
||||
impl<M: RMul<V> + Copy, V: Copy> DeltaTransformVector<V> for Rotmat<M>
|
||||
|
|
|
@ -20,7 +20,7 @@ impl<M: Copy, V: Copy> Transform<M, V>
|
|||
{
|
||||
#[inline(always)]
|
||||
pub fn new(mat: &M, trans: &V) -> Transform<M, V>
|
||||
{ Transform { submat: *mat, subtrans: *trans } }
|
||||
{ Transform { submat: copy *mat, subtrans: copy *trans } }
|
||||
}
|
||||
|
||||
impl<M:Dim, V> Dim for Transform<M, V>
|
||||
|
@ -118,7 +118,7 @@ impl<M: Copy, V> DeltaTransform<M> for Transform<M, V>
|
|||
{
|
||||
#[inline(always)]
|
||||
fn delta_transform(&self) -> M
|
||||
{ self.submat }
|
||||
{ copy self.submat }
|
||||
}
|
||||
|
||||
impl<M: RMul<V> + Copy, V> DeltaTransformVector<V> for Transform<M, V>
|
||||
|
@ -141,7 +141,7 @@ Inv for Transform<M, V>
|
|||
#[inline(always)]
|
||||
fn inverse(&self) -> Transform<M, V>
|
||||
{
|
||||
let mut res = *self;
|
||||
let mut res = copy *self;
|
||||
|
||||
res.invert();
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ Inv for Mat1<N>
|
|||
#[inline(always)]
|
||||
fn inverse(&self) -> Mat1<N>
|
||||
{
|
||||
let mut res : Mat1<N> = *self;
|
||||
let mut res : Mat1<N> = copy *self;
|
||||
|
||||
res.invert();
|
||||
|
||||
|
@ -94,7 +94,7 @@ impl<N:Copy> Transpose for Mat1<N>
|
|||
{
|
||||
#[inline(always)]
|
||||
fn transposed(&self) -> Mat1<N>
|
||||
{ *self }
|
||||
{ copy *self }
|
||||
|
||||
#[inline(always)]
|
||||
fn transpose(&mut self)
|
||||
|
@ -131,13 +131,13 @@ impl<N: Copy> Flatten<N> for Mat1<N>
|
|||
|
||||
#[inline(always)]
|
||||
fn from_flattened(l: &[N], off: uint) -> Mat1<N>
|
||||
{ Mat1::new(l[off]) }
|
||||
{ Mat1::new(copy l[off]) }
|
||||
|
||||
#[inline(always)]
|
||||
fn flatten(&self) -> ~[N]
|
||||
{ ~[ self.m11 ] }
|
||||
{ ~[ copy self.m11 ] }
|
||||
|
||||
#[inline(always)]
|
||||
fn flatten_to(&self, l: &mut [N], off: uint)
|
||||
{ l[off] = self.m11 }
|
||||
{ l[off] = copy self.m11 }
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ ScalarMul<N> for Vec1<N>
|
|||
|
||||
#[inline(always)]
|
||||
fn scalar_mul_inplace(&mut self, s: &N)
|
||||
{ self.x *= *s; }
|
||||
{ self.x = self.x * copy *s; }
|
||||
}
|
||||
|
||||
|
||||
|
@ -64,7 +64,7 @@ ScalarDiv<N> for Vec1<N>
|
|||
|
||||
#[inline(always)]
|
||||
fn scalar_div_inplace(&mut self, s: &N)
|
||||
{ self.x /= *s; }
|
||||
{ self.x = self.x / copy *s; }
|
||||
}
|
||||
|
||||
impl<N: Copy + Add<N, N>>
|
||||
|
@ -76,7 +76,7 @@ ScalarAdd<N> for Vec1<N>
|
|||
|
||||
#[inline(always)]
|
||||
fn scalar_add_inplace(&mut self, s: &N)
|
||||
{ self.x += *s; }
|
||||
{ self.x = self.x + copy *s; }
|
||||
}
|
||||
|
||||
impl<N: Copy + Sub<N, N>>
|
||||
|
@ -88,14 +88,14 @@ ScalarSub<N> for Vec1<N>
|
|||
|
||||
#[inline(always)]
|
||||
fn scalar_sub_inplace(&mut self, s: &N)
|
||||
{ self.x -= *s; }
|
||||
{ self.x = self.x - copy *s; }
|
||||
}
|
||||
|
||||
impl<N: Copy + Add<N, N>> Translation<Vec1<N>> for Vec1<N>
|
||||
{
|
||||
#[inline(always)]
|
||||
fn translation(&self) -> Vec1<N>
|
||||
{ *self }
|
||||
{ copy *self }
|
||||
|
||||
#[inline(always)]
|
||||
fn translated(&self, t: &Vec1<N>) -> Vec1<N>
|
||||
|
@ -103,7 +103,7 @@ impl<N: Copy + Add<N, N>> Translation<Vec1<N>> for Vec1<N>
|
|||
|
||||
#[inline(always)]
|
||||
fn translate(&mut self, t: &Vec1<N>)
|
||||
{ *self += *t }
|
||||
{ *self = *self + copy *t }
|
||||
}
|
||||
|
||||
impl<N:Copy + Mul<N, N>> Dot<N> for Vec1<N>
|
||||
|
@ -140,7 +140,7 @@ Norm<N> for Vec1<N>
|
|||
{
|
||||
let l = self.norm();
|
||||
|
||||
self.x /= l;
|
||||
self.x = self.x / copy l;
|
||||
|
||||
l
|
||||
}
|
||||
|
@ -208,15 +208,15 @@ impl<N: Copy> Flatten<N> for Vec1<N>
|
|||
|
||||
#[inline(always)]
|
||||
fn from_flattened(l: &[N], off: uint) -> Vec1<N>
|
||||
{ Vec1::new(l[off]) }
|
||||
{ Vec1::new(copy l[off]) }
|
||||
|
||||
#[inline(always)]
|
||||
fn flatten(&self) -> ~[N]
|
||||
{ ~[ self.x ] }
|
||||
{ ~[ copy self.x ] }
|
||||
|
||||
#[inline(always)]
|
||||
fn flatten_to(&self, l: &mut [N], off: uint)
|
||||
{ l[off] = self.x }
|
||||
{ l[off] = copy self.x }
|
||||
}
|
||||
|
||||
impl<N: Bounded + Copy> Bounded for Vec1<N>
|
||||
|
|
|
@ -42,8 +42,8 @@ impl<N:Copy + One + Zero> One for Mat2<N>
|
|||
fn one() -> Mat2<N>
|
||||
{
|
||||
let (_0, _1) = (Zero::zero(), One::one());
|
||||
return Mat2::new(_1, _0,
|
||||
_0, _1)
|
||||
return Mat2::new(copy _1, copy _0,
|
||||
copy _0, copy _1)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -53,8 +53,8 @@ impl<N:Copy + Zero> Zero for Mat2<N>
|
|||
fn zero() -> Mat2<N>
|
||||
{
|
||||
let _0 = Zero::zero();
|
||||
return Mat2::new(_0, _0,
|
||||
_0, _0)
|
||||
return Mat2::new(copy _0, copy _0,
|
||||
copy _0, copy _0)
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
|
@ -109,7 +109,7 @@ Inv for Mat2<N>
|
|||
#[inline(always)]
|
||||
fn inverse(&self) -> Mat2<N>
|
||||
{
|
||||
let mut res : Mat2<N> = *self;
|
||||
let mut res : Mat2<N> = copy *self;
|
||||
|
||||
res.invert();
|
||||
|
||||
|
@ -133,8 +133,8 @@ impl<N:Copy> Transpose for Mat2<N>
|
|||
#[inline(always)]
|
||||
fn transposed(&self) -> Mat2<N>
|
||||
{
|
||||
Mat2::new(self.m11, self.m21,
|
||||
self.m12, self.m22)
|
||||
Mat2::new(copy self.m11, copy self.m21,
|
||||
copy self.m12, copy self.m22)
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
|
@ -184,18 +184,18 @@ impl<N: Copy> Flatten<N> for Mat2<N>
|
|||
|
||||
#[inline(always)]
|
||||
fn from_flattened(l: &[N], off: uint) -> Mat2<N>
|
||||
{ Mat2::new(l[off], l[off + 1], l[off + 2], l[off + 3]) }
|
||||
{ Mat2::new(copy l[off], copy l[off + 1], copy l[off + 2], copy l[off + 3]) }
|
||||
|
||||
#[inline(always)]
|
||||
fn flatten(&self) -> ~[N]
|
||||
{ ~[ self.m11, self.m12, self.m21, self.m22 ] }
|
||||
{ ~[ copy self.m11, copy self.m12, copy self.m21, copy self.m22 ] }
|
||||
|
||||
#[inline(always)]
|
||||
fn flatten_to(&self, l: &mut [N], off: uint)
|
||||
{
|
||||
l[off] = self.m11;
|
||||
l[off + 1] = self.m12;
|
||||
l[off + 2] = self.m21;
|
||||
l[off + 3] = self.m22;
|
||||
l[off] = copy self.m11;
|
||||
l[off + 1] = copy self.m12;
|
||||
l[off + 2] = copy self.m21;
|
||||
l[off + 3] = copy self.m22;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,8 +57,8 @@ ScalarMul<N> for Vec2<N>
|
|||
#[inline(always)]
|
||||
fn scalar_mul_inplace(&mut self, s: &N)
|
||||
{
|
||||
self.x *= *s;
|
||||
self.y *= *s;
|
||||
self.x = self.x * copy *s;
|
||||
self.y = self.y * copy *s;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -73,8 +73,8 @@ ScalarDiv<N> for Vec2<N>
|
|||
#[inline(always)]
|
||||
fn scalar_div_inplace(&mut self, s: &N)
|
||||
{
|
||||
self.x /= *s;
|
||||
self.y /= *s;
|
||||
self.x = self.x / copy *s;
|
||||
self.y = self.y / copy *s;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -88,8 +88,8 @@ ScalarAdd<N> for Vec2<N>
|
|||
#[inline(always)]
|
||||
fn scalar_add_inplace(&mut self, s: &N)
|
||||
{
|
||||
self.x += *s;
|
||||
self.y += *s;
|
||||
self.x = self.x + copy *s;
|
||||
self.y = self.y + copy *s;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -103,8 +103,8 @@ ScalarSub<N> for Vec2<N>
|
|||
#[inline(always)]
|
||||
fn scalar_sub_inplace(&mut self, s: &N)
|
||||
{
|
||||
self.x -= *s;
|
||||
self.y -= *s;
|
||||
self.x = self.x - copy *s;
|
||||
self.y = self.y - copy *s;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -112,7 +112,7 @@ impl<N: Copy + Add<N, N>> Translation<Vec2<N>> for Vec2<N>
|
|||
{
|
||||
#[inline(always)]
|
||||
fn translation(&self) -> Vec2<N>
|
||||
{ *self }
|
||||
{ copy *self }
|
||||
|
||||
#[inline(always)]
|
||||
fn translated(&self, t: &Vec2<N>) -> Vec2<N>
|
||||
|
@ -120,7 +120,7 @@ impl<N: Copy + Add<N, N>> Translation<Vec2<N>> for Vec2<N>
|
|||
|
||||
#[inline(always)]
|
||||
fn translate(&mut self, t: &Vec2<N>)
|
||||
{ *self += *t; }
|
||||
{ *self = *self + copy *t; }
|
||||
}
|
||||
|
||||
impl<N:Copy + Mul<N, N> + Add<N, N>> Dot<N> for Vec2<N>
|
||||
|
@ -161,10 +161,10 @@ Norm<N> for Vec2<N>
|
|||
{
|
||||
let l = self.norm();
|
||||
|
||||
self.x /= l;
|
||||
self.y /= l;
|
||||
self.x = self.x / copy l;
|
||||
self.y = self.y / copy l;
|
||||
|
||||
l
|
||||
copy l
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -188,7 +188,7 @@ impl<N:Copy + Zero> Zero for Vec2<N>
|
|||
fn zero() -> Vec2<N>
|
||||
{
|
||||
let _0 = Zero::zero();
|
||||
Vec2::new(_0, _0)
|
||||
Vec2::new(copy _0, copy _0)
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
|
@ -208,7 +208,7 @@ impl<N: Copy + One + Zero + Neg<N>> Basis for Vec2<N>
|
|||
|
||||
#[inline(always)]
|
||||
fn orthogonal_subspace_basis(&self) -> ~[Vec2<N>]
|
||||
{ ~[ Vec2::new(-self.y, self.x) ] }
|
||||
{ ~[ Vec2::new(-self.y, copy self.x) ] }
|
||||
}
|
||||
|
||||
impl<N:ApproxEq<N>> ApproxEq<N> for Vec2<N>
|
||||
|
@ -244,17 +244,17 @@ impl<N: Copy> Flatten<N> for Vec2<N>
|
|||
|
||||
#[inline(always)]
|
||||
fn from_flattened(l: &[N], off: uint) -> Vec2<N>
|
||||
{ Vec2::new(l[off], l[off + 1]) }
|
||||
{ Vec2::new(copy l[off], copy l[off + 1]) }
|
||||
|
||||
#[inline(always)]
|
||||
fn flatten(&self) -> ~[N]
|
||||
{ ~[ self.x, self.y ] }
|
||||
{ ~[ copy self.x, copy self.y ] }
|
||||
|
||||
#[inline(always)]
|
||||
fn flatten_to(&self, l: &mut [N], off: uint)
|
||||
{
|
||||
l[off] = self.x;
|
||||
l[off + 1] = self.y;
|
||||
l[off] = copy self.x;
|
||||
l[off + 1] = copy self.y;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -46,9 +46,9 @@ impl<N:Copy + One + Zero> One for Mat3<N>
|
|||
fn one() -> Mat3<N>
|
||||
{
|
||||
let (_0, _1) = (Zero::zero(), One::one());
|
||||
return Mat3::new(_1, _0, _0,
|
||||
_0, _1, _0,
|
||||
_0, _0, _1)
|
||||
return Mat3::new(copy _1, copy _0, copy _0,
|
||||
copy _0, copy _1, copy _0,
|
||||
copy _0, copy _0, copy _1)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -58,9 +58,9 @@ impl<N:Copy + Zero> Zero for Mat3<N>
|
|||
fn zero() -> Mat3<N>
|
||||
{
|
||||
let _0 = Zero::zero();
|
||||
return Mat3::new(_0, _0, _0,
|
||||
_0, _0, _0,
|
||||
_0, _0, _0)
|
||||
return Mat3::new(copy _0, copy _0, copy _0,
|
||||
copy _0, copy _0, copy _0,
|
||||
copy _0, copy _0, copy _0)
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
|
@ -125,7 +125,7 @@ Inv for Mat3<N>
|
|||
#[inline(always)]
|
||||
fn inverse(&self) -> Mat3<N>
|
||||
{
|
||||
let mut res = *self;
|
||||
let mut res = copy *self;
|
||||
|
||||
res.invert();
|
||||
|
||||
|
@ -166,9 +166,9 @@ impl<N:Copy> Transpose for Mat3<N>
|
|||
#[inline(always)]
|
||||
fn transposed(&self) -> Mat3<N>
|
||||
{
|
||||
Mat3::new(self.m11, self.m21, self.m31,
|
||||
self.m12, self.m22, self.m32,
|
||||
self.m13, self.m23, self.m33)
|
||||
Mat3::new(copy self.m11, copy self.m21, copy self.m31,
|
||||
copy self.m12, copy self.m22, copy self.m32,
|
||||
copy self.m13, copy self.m23, copy self.m33)
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
|
@ -238,31 +238,31 @@ impl<N: Copy> Flatten<N> for Mat3<N>
|
|||
|
||||
#[inline(always)]
|
||||
fn from_flattened(l: &[N], off: uint) -> Mat3<N>
|
||||
{ Mat3::new(l[off + 0], l[off + 1], l[off + 2],
|
||||
l[off + 3], l[off + 4], l[off + 5],
|
||||
l[off + 6], l[off + 7], l[off + 8]) }
|
||||
{ Mat3::new(copy l[off + 0], copy l[off + 1], copy l[off + 2],
|
||||
copy l[off + 3], copy l[off + 4], copy l[off + 5],
|
||||
copy l[off + 6], copy l[off + 7], copy l[off + 8]) }
|
||||
|
||||
#[inline(always)]
|
||||
fn flatten(&self) -> ~[N]
|
||||
{
|
||||
~[
|
||||
self.m11, self.m12, self.m13,
|
||||
self.m21, self.m22, self.m23,
|
||||
self.m31, self.m32, self.m33
|
||||
copy self.m11, copy self.m12, copy self.m13,
|
||||
copy self.m21, copy self.m22, copy self.m23,
|
||||
copy self.m31, copy self.m32, copy self.m33
|
||||
]
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn flatten_to(&self, l: &mut [N], off: uint)
|
||||
{
|
||||
l[off + 0] = self.m11;
|
||||
l[off + 1] = self.m12;
|
||||
l[off + 2] = self.m13;
|
||||
l[off + 3] = self.m21;
|
||||
l[off + 4] = self.m22;
|
||||
l[off + 5] = self.m23;
|
||||
l[off + 6] = self.m31;
|
||||
l[off + 7] = self.m32;
|
||||
l[off + 8] = self.m33;
|
||||
l[off + 0] = copy self.m11;
|
||||
l[off + 1] = copy self.m12;
|
||||
l[off + 2] = copy self.m13;
|
||||
l[off + 3] = copy self.m21;
|
||||
l[off + 4] = copy self.m22;
|
||||
l[off + 5] = copy self.m23;
|
||||
l[off + 6] = copy self.m31;
|
||||
l[off + 7] = copy self.m32;
|
||||
l[off + 8] = copy self.m33;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,9 +57,9 @@ ScalarMul<N> for Vec3<N>
|
|||
#[inline(always)]
|
||||
fn scalar_mul_inplace(&mut self, s: &N)
|
||||
{
|
||||
self.x *= *s;
|
||||
self.y *= *s;
|
||||
self.z *= *s;
|
||||
self.x = self.x * copy *s;
|
||||
self.y = self.y * copy *s;
|
||||
self.z = self.z * copy *s;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -74,9 +74,9 @@ ScalarDiv<N> for Vec3<N>
|
|||
#[inline(always)]
|
||||
fn scalar_div_inplace(&mut self, s: &N)
|
||||
{
|
||||
self.x /= *s;
|
||||
self.y /= *s;
|
||||
self.z /= *s;
|
||||
self.x = self.x / copy *s;
|
||||
self.y = self.y / copy *s;
|
||||
self.z = self.z / copy *s;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -90,9 +90,9 @@ ScalarAdd<N> for Vec3<N>
|
|||
#[inline(always)]
|
||||
fn scalar_add_inplace(&mut self, s: &N)
|
||||
{
|
||||
self.x += *s;
|
||||
self.y += *s;
|
||||
self.z += *s;
|
||||
self.x = self.x + copy *s;
|
||||
self.y = self.y + copy *s;
|
||||
self.z = self.z + copy *s;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -106,9 +106,9 @@ ScalarSub<N> for Vec3<N>
|
|||
#[inline(always)]
|
||||
fn scalar_sub_inplace(&mut self, s: &N)
|
||||
{
|
||||
self.x -= *s;
|
||||
self.y -= *s;
|
||||
self.z -= *s;
|
||||
self.x = self.x - copy *s;
|
||||
self.y = self.y - copy *s;
|
||||
self.z = self.z - copy *s;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -116,7 +116,7 @@ impl<N: Copy + Add<N, N>> Translation<Vec3<N>> for Vec3<N>
|
|||
{
|
||||
#[inline(always)]
|
||||
fn translation(&self) -> Vec3<N>
|
||||
{ *self }
|
||||
{ copy *self }
|
||||
|
||||
#[inline(always)]
|
||||
fn translated(&self, t: &Vec3<N>) -> Vec3<N>
|
||||
|
@ -124,7 +124,7 @@ impl<N: Copy + Add<N, N>> Translation<Vec3<N>> for Vec3<N>
|
|||
|
||||
#[inline(always)]
|
||||
fn translate(&mut self, t: &Vec3<N>)
|
||||
{ *self += *t; }
|
||||
{ *self = *self + copy *t; }
|
||||
}
|
||||
|
||||
|
||||
|
@ -174,9 +174,9 @@ Norm<N> for Vec3<N>
|
|||
{
|
||||
let l = self.norm();
|
||||
|
||||
self.x /= l;
|
||||
self.y /= l;
|
||||
self.z /= l;
|
||||
self.x = self.x / copy l;
|
||||
self.y = self.y / copy l;
|
||||
self.z = self.z / copy l;
|
||||
|
||||
l
|
||||
}
|
||||
|
@ -201,7 +201,7 @@ impl<N:Copy + Zero> Zero for Vec3<N>
|
|||
fn zero() -> Vec3<N>
|
||||
{
|
||||
let _0 = Zero::zero();
|
||||
Vec3::new(_0, _0, _0)
|
||||
Vec3::new(copy _0, copy _0, copy _0)
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
|
@ -226,12 +226,12 @@ Basis for Vec3<N>
|
|||
fn orthogonal_subspace_basis(&self) -> ~[Vec3<N>]
|
||||
{
|
||||
let a =
|
||||
if (abs(self.x) > abs(self.y))
|
||||
{ Vec3::new(self.z, Zero::zero(), -self.x).normalized() }
|
||||
if (abs(copy self.x) > abs(copy self.y))
|
||||
{ Vec3::new(copy self.z, Zero::zero(), -copy self.x).normalized() }
|
||||
else
|
||||
{ Vec3::new(Zero::zero(), -self.z, self.y).normalized() };
|
||||
{ Vec3::new(Zero::zero(), -self.z, copy self.y).normalized() };
|
||||
|
||||
~[ a, a.cross(self) ]
|
||||
~[ a.cross(self), a ]
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -273,18 +273,18 @@ impl<N: Copy> Flatten<N> for Vec3<N>
|
|||
|
||||
#[inline(always)]
|
||||
fn from_flattened(l: &[N], off: uint) -> Vec3<N>
|
||||
{ Vec3::new(l[off], l[off + 1], l[off + 2]) }
|
||||
{ Vec3::new(copy l[off], copy l[off + 1], copy l[off + 2]) }
|
||||
|
||||
#[inline(always)]
|
||||
fn flatten(&self) -> ~[N]
|
||||
{ ~[ self.x, self.y, self.z ] }
|
||||
{ ~[ copy self.x, copy self.y, copy self.z ] }
|
||||
|
||||
#[inline(always)]
|
||||
fn flatten_to(&self, l: &mut [N], off: uint)
|
||||
{
|
||||
l[off] = self.x;
|
||||
l[off + 1] = self.y;
|
||||
l[off + 2] = self.z;
|
||||
l[off] = copy self.x;
|
||||
l[off + 1] = copy self.y;
|
||||
l[off + 2] = copy self.z;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ impl<N: Copy> DMat<N>
|
|||
{
|
||||
assert!(i < self.dim);
|
||||
assert!(j < self.dim);
|
||||
self.mij[self.offset(i, j)] = *t
|
||||
self.mij[self.offset(i, j)] = copy *t
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
|
@ -55,7 +55,7 @@ impl<N: Copy> DMat<N>
|
|||
{
|
||||
assert!(i < self.dim);
|
||||
assert!(j < self.dim);
|
||||
self.mij[self.offset(i, j)]
|
||||
copy self.mij[self.offset(i, j)]
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ Mul<DMat<N>, DMat<N>> for DMat<N>
|
|||
let mut acc = Zero::zero::<N>();
|
||||
|
||||
for iterate(0u, dim) |k|
|
||||
{ acc += self.at(i, k) * other.at(k, j); }
|
||||
{ acc = acc + self.at(i, k) * other.at(k, j); }
|
||||
|
||||
res.set(i, j, &acc);
|
||||
}
|
||||
|
@ -166,7 +166,7 @@ Inv for DMat<N>
|
|||
if (self.at(n0, k) != _0T)
|
||||
{ break; }
|
||||
|
||||
n0 += 1;
|
||||
n0 = n0 + 1;
|
||||
}
|
||||
|
||||
assert!(n0 != dim); // non inversible matrix
|
||||
|
|
|
@ -62,10 +62,10 @@ impl<N: Copy + DivisionRing + Algebraic + Clone + ApproxEq<N>> DVec<N>
|
|||
|
||||
let mut elt = basis_element.clone();
|
||||
|
||||
elt -= self.scalar_mul(&basis_element.dot(self));
|
||||
elt = elt - self.scalar_mul(&basis_element.dot(self));
|
||||
|
||||
for res.each |v|
|
||||
{ elt -= v.scalar_mul(&elt.dot(v)) };
|
||||
{ elt = elt - v.scalar_mul(&elt.dot(v)) };
|
||||
|
||||
if (!elt.sqnorm().approx_eq(&Zero::zero()))
|
||||
{ res.push(elt.normalized()); }
|
||||
|
@ -115,7 +115,7 @@ Dot<N> for DVec<N>
|
|||
let mut res = Zero::zero::<N>();
|
||||
|
||||
for iterate(0u, self.at.len()) |i|
|
||||
{ res += self.at[i] * other.at[i]; }
|
||||
{ res = res + self.at[i] * other.at[i]; }
|
||||
|
||||
res
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ impl<N: Copy + Ring> SubDot<N> for DVec<N>
|
|||
let mut res = Zero::zero::<N>();
|
||||
|
||||
for iterate(0u, self.at.len()) |i|
|
||||
{ res += (self.at[i] - a.at[i]) * b.at[i]; }
|
||||
{ res = res + (self.at[i] - a.at[i]) * b.at[i]; }
|
||||
|
||||
res
|
||||
}
|
||||
|
@ -146,7 +146,7 @@ ScalarMul<N> for DVec<N>
|
|||
fn scalar_mul_inplace(&mut self, s: &N)
|
||||
{
|
||||
for iterate(0u, self.at.len()) |i|
|
||||
{ self.at[i] *= *s; }
|
||||
{ self.at[i] = self.at[i] * copy *s; }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -162,7 +162,7 @@ ScalarDiv<N> for DVec<N>
|
|||
fn scalar_div_inplace(&mut self, s: &N)
|
||||
{
|
||||
for iterate(0u, self.at.len()) |i|
|
||||
{ self.at[i] /= *s; }
|
||||
{ self.at[i] = self.at[i] / copy *s; }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -177,7 +177,7 @@ ScalarAdd<N> for DVec<N>
|
|||
fn scalar_add_inplace(&mut self, s: &N)
|
||||
{
|
||||
for iterate(0u, self.at.len()) |i|
|
||||
{ self.at[i] += *s; }
|
||||
{ self.at[i] = self.at[i] + copy *s; }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -192,7 +192,7 @@ ScalarSub<N> for DVec<N>
|
|||
fn scalar_sub_inplace(&mut self, s: &N)
|
||||
{
|
||||
for iterate(0u, self.at.len()) |i|
|
||||
{ self.at[i] -= *s; }
|
||||
{ self.at[i] = self.at[i] - copy *s; }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -238,7 +238,7 @@ Norm<N> for DVec<N>
|
|||
let l = self.norm();
|
||||
|
||||
for iterate(0u, self.at.len()) |i|
|
||||
{ self.at[i] /= l; }
|
||||
{ self.at[i] = self.at[i] / copy l; }
|
||||
|
||||
l
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ Mul<NMat<D, N>, NMat<D, N>> for NMat<D, N>
|
|||
let mut acc: N = Zero::zero();
|
||||
|
||||
for iterate(0u, dim) |k|
|
||||
{ acc += self[(i, k)] * other[(k, j)]; }
|
||||
{ acc = acc + self[(i, k)] * other[(k, j)]; }
|
||||
|
||||
res.set(i, j, &acc);
|
||||
}
|
||||
|
@ -197,7 +197,7 @@ impl<D: Dim, N: Zero + Copy> Flatten<N> for NMat<D, N>
|
|||
let mut res = Zero::zero::<NMat<D, N>>();
|
||||
|
||||
for iterate(0u, dim * dim) |i|
|
||||
{ res.mij.mij[i] = l[off + i] }
|
||||
{ res.mij.mij[i] = copy l[off + i] }
|
||||
|
||||
res
|
||||
}
|
||||
|
@ -209,7 +209,7 @@ impl<D: Dim, N: Zero + Copy> Flatten<N> for NMat<D, N>
|
|||
let mut res = ~[];
|
||||
|
||||
for iterate(0u, dim * dim) |i|
|
||||
{ res.push(self.mij.mij[i]) }
|
||||
{ res.push(copy self.mij.mij[i]) }
|
||||
|
||||
res
|
||||
}
|
||||
|
@ -220,6 +220,6 @@ impl<D: Dim, N: Zero + Copy> Flatten<N> for NMat<D, N>
|
|||
let dim = Dim::dim::<D>();
|
||||
|
||||
for iterate(0u, dim * dim) |i|
|
||||
{ l[off + i] = self.mij.mij[i] }
|
||||
{ l[off + i] = copy self.mij.mij[i] }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -239,7 +239,7 @@ impl<D: Dim, N: Zero + Copy> Flatten<N> for NVec<D, N>
|
|||
let mut res = Zero::zero::<NVec<D, N>>();
|
||||
|
||||
for iterate(0u, dim) |i|
|
||||
{ res.at.at[i] = l[off + i] }
|
||||
{ res.at.at[i] = copy l[off + i] }
|
||||
|
||||
res
|
||||
}
|
||||
|
@ -251,7 +251,7 @@ impl<D: Dim, N: Zero + Copy> Flatten<N> for NVec<D, N>
|
|||
let mut res = ~[];
|
||||
|
||||
for iterate(0u, dim) |i|
|
||||
{ res.push(self.at.at[i]) }
|
||||
{ res.push(copy self.at.at[i]) }
|
||||
|
||||
res
|
||||
}
|
||||
|
@ -262,7 +262,7 @@ impl<D: Dim, N: Zero + Copy> Flatten<N> for NVec<D, N>
|
|||
let dim = Dim::dim::<D>();
|
||||
|
||||
for iterate(0u, dim) |i|
|
||||
{ l[off + i] = self.at.at[i] }
|
||||
{ l[off + i] = copy self.at.at[i] }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -28,6 +28,8 @@ use traits::dot::Dot;
|
|||
use traits::norm::Norm;
|
||||
#[test]
|
||||
use traits::flatten::Flatten;
|
||||
#[test]
|
||||
use traits::scalar_op::{ScalarMul, ScalarDiv, ScalarAdd, ScalarSub};
|
||||
|
||||
macro_rules! test_commut_dot_impl(
|
||||
($t: ty) => (
|
||||
|
@ -41,6 +43,30 @@ macro_rules! test_commut_dot_impl(
|
|||
);
|
||||
)
|
||||
|
||||
macro_rules! test_scalar_op_impl(
|
||||
($t: ty, $n: ty) => (
|
||||
for 10000.times
|
||||
{
|
||||
let v1 : $t = random();
|
||||
let n : $n = random();
|
||||
|
||||
assert!(v1.scalar_mul(&n).scalar_div(&n).approx_eq(&v1));
|
||||
assert!(v1.scalar_div(&n).scalar_mul(&n).approx_eq(&v1));
|
||||
assert!(v1.scalar_sub(&n).scalar_add(&n).approx_eq(&v1));
|
||||
assert!(v1.scalar_add(&n).scalar_sub(&n).approx_eq(&v1));
|
||||
|
||||
let mut v1 : $t = random();
|
||||
let v0 : $t = copy v1;
|
||||
let n : $n = random();
|
||||
|
||||
v1.scalar_mul_inplace(&n);
|
||||
v1.scalar_div_inplace(&n);
|
||||
|
||||
assert!(v1.approx_eq(&v0));
|
||||
}
|
||||
);
|
||||
)
|
||||
|
||||
macro_rules! test_basis_impl(
|
||||
($t: ty) => (
|
||||
for 10000.times
|
||||
|
@ -62,9 +88,9 @@ macro_rules! test_subspace_basis_impl(
|
|||
($t: ty) => (
|
||||
for 10000.times
|
||||
{
|
||||
let v : Vec3<f64> = random();
|
||||
let v1 = v.normalized();
|
||||
let subbasis = v1.orthogonal_subspace_basis();
|
||||
let v : $t = random();
|
||||
let v1 = v.normalized();
|
||||
let subbasis = v1.orthogonal_subspace_basis();
|
||||
|
||||
// check vectors are orthogonal to v1
|
||||
assert!(subbasis.all(|e| v1.dot(e).approx_eq(&Zero::zero())));
|
||||
|
@ -171,3 +197,19 @@ fn test_flatten_vec3()
|
|||
#[test]
|
||||
fn test_flatten_nvec()
|
||||
{ test_flatten_impl!(NVec<d7, f64>, f64); }
|
||||
|
||||
#[test]
|
||||
fn test_scalar_op_vec1()
|
||||
{ test_scalar_op_impl!(Vec1<f64>, f64); }
|
||||
|
||||
#[test]
|
||||
fn test_scalar_op_vec2()
|
||||
{ test_scalar_op_impl!(Vec2<f64>, f64); }
|
||||
|
||||
#[test]
|
||||
fn test_scalar_op_vec3()
|
||||
{ test_scalar_op_impl!(Vec3<f64>, f64); }
|
||||
|
||||
#[test]
|
||||
fn test_scalar_op_nvec()
|
||||
{ test_scalar_op_impl!(NVec<d7, f64>, f64); }
|
||||
|
|
Loading…
Reference in New Issue