Rewrite to_homogenous for vectors to use push
This commit is contained in:
parent
3055c289c0
commit
85a943b7ef
|
@ -832,14 +832,7 @@ impl<N: Scalar + Zero, D: DimAdd<U1>, S: Storage<N, D>> Vector<N, D, S> {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn to_homogeneous(&self) -> VectorN<N, DimSum<D, U1>>
|
pub fn to_homogeneous(&self) -> VectorN<N, DimSum<D, U1>>
|
||||||
where DefaultAllocator: Allocator<N, DimSum<D, U1>> {
|
where DefaultAllocator: Allocator<N, DimSum<D, U1>> {
|
||||||
let len = self.len();
|
self.push(N::zero())
|
||||||
let hnrows = DimSum::<D, U1>::from_usize(len + 1);
|
|
||||||
let mut res = unsafe { VectorN::<N, _>::new_uninitialized_generic(hnrows, U1) };
|
|
||||||
res.generic_slice_mut((0, 0), self.data.shape())
|
|
||||||
.copy_from(self);
|
|
||||||
res[(len, 0)] = N::zero();
|
|
||||||
|
|
||||||
res
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Constructs a vector from coordinates in projective space, i.e., removes a `0` at the end of
|
/// Constructs a vector from coordinates in projective space, i.e., removes a `0` at the end of
|
||||||
|
|
Loading…
Reference in New Issue