forked from M-Labs/nalgebra
Make MatrixN::{transform_vector, transform_point} inherent methods.
Addresses https://github.com/rustsim/nalgebra/issues/372
This commit is contained in:
parent
d35c29b589
commit
fc782f3644
@ -314,11 +314,12 @@ impl<N: Scalar + Ring, D: DimName, S: StorageMut<N, D, D>> SquareMatrix<N, D, S>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<N: Real, D: DimNameSub<U1>> Transformation<Point<N, DimNameDiff<D, U1>>> for MatrixN<N, D>
|
impl<N: Real, D: DimNameSub<U1>, S: Storage<N, D, D>> SquareMatrix<N, D, S>
|
||||||
where DefaultAllocator: Allocator<N, D, D>
|
where DefaultAllocator: Allocator<N, D, D>
|
||||||
+ Allocator<N, DimNameDiff<D, U1>>
|
+ Allocator<N, DimNameDiff<D, U1>>
|
||||||
+ Allocator<N, DimNameDiff<D, U1>, DimNameDiff<D, U1>>
|
+ Allocator<N, DimNameDiff<D, U1>, DimNameDiff<D, U1>>
|
||||||
{
|
{
|
||||||
|
/// Transforms the given vector, assuming the matirx `self` uses homogeneous coordinates.
|
||||||
#[inline]
|
#[inline]
|
||||||
fn transform_vector(
|
fn transform_vector(
|
||||||
&self,
|
&self,
|
||||||
@ -336,6 +337,7 @@ where DefaultAllocator: Allocator<N, D, D>
|
|||||||
transform * v
|
transform * v
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Transforms the given point, assuming the matrix `self` uses homogeneous coordinates.
|
||||||
#[inline]
|
#[inline]
|
||||||
fn transform_point(&self, pt: &Point<N, DimNameDiff<D, U1>>) -> Point<N, DimNameDiff<D, U1>> {
|
fn transform_point(&self, pt: &Point<N, DimNameDiff<D, U1>>) -> Point<N, DimNameDiff<D, U1>> {
|
||||||
let transform = self.fixed_slice::<DimNameDiff<D, U1>, DimNameDiff<D, U1>>(0, 0);
|
let transform = self.fixed_slice::<DimNameDiff<D, U1>, DimNameDiff<D, U1>>(0, 0);
|
||||||
@ -351,3 +353,23 @@ where DefaultAllocator: Allocator<N, D, D>
|
|||||||
transform * pt + translation
|
transform * pt + translation
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<N: Real, D: DimNameSub<U1>> Transformation<Point<N, DimNameDiff<D, U1>>> for MatrixN<N, D>
|
||||||
|
where DefaultAllocator: Allocator<N, D, D>
|
||||||
|
+ Allocator<N, DimNameDiff<D, U1>>
|
||||||
|
+ Allocator<N, DimNameDiff<D, U1>, DimNameDiff<D, U1>>
|
||||||
|
{
|
||||||
|
#[inline]
|
||||||
|
fn transform_vector(
|
||||||
|
&self,
|
||||||
|
v: &VectorN<N, DimNameDiff<D, U1>>,
|
||||||
|
) -> VectorN<N, DimNameDiff<D, U1>>
|
||||||
|
{
|
||||||
|
self.transform_vector(v)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn transform_point(&self, pt: &Point<N, DimNameDiff<D, U1>>) -> Point<N, DimNameDiff<D, U1>> {
|
||||||
|
self.transform_point(pt)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user