diff --git a/src/geometry/scale.rs b/src/geometry/scale.rs index 5fe36602..deb0116b 100755 --- a/src/geometry/scale.rs +++ b/src/geometry/scale.rs @@ -14,8 +14,8 @@ use abomonation::Abomonation; use crate::base::allocator::Allocator; use crate::base::dimension::{DimNameAdd, DimNameSum, U1}; use crate::base::storage::Owned; -use crate::base::{Const, DefaultAllocator, OMatrix, SVector, Scalar}; -use crate::ClosedDiv; +use crate::base::{Const, DefaultAllocator, OMatrix, OVector, SVector, Scalar}; +use crate::{ClosedAdd, ClosedDiv}; use crate::ClosedMul; use crate::geometry::Point; @@ -208,11 +208,16 @@ impl Scale { #[must_use] pub fn to_homogeneous(&self) -> OMatrix, U1>, DimNameSum, U1>> where - T: Zero + One, + T: Zero + One + ClosedAdd + Clone, Const: DimNameAdd, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, + DefaultAllocator: Allocator, U1>, DimNameSum, U1>> + Allocator, U1>, U1>, { - todo!(); + let mut v = OVector::, U1>>::zero(); + for i in 0..D { + v[(i, 0)] = self.vector[(i, 0)].clone(); + } + v[(D, 0)] = T::one(); + return OMatrix::, U1>, DimNameSum, U1>>::from_diagonal(&v); } /// Inverts `self` in-place. diff --git a/src/geometry/scale_conversion.rs b/src/geometry/scale_conversion.rs index ed8d4c7a..e6f8573b 100644 --- a/src/geometry/scale_conversion.rs +++ b/src/geometry/scale_conversion.rs @@ -10,7 +10,7 @@ use crate::base::{Const, DefaultAllocator, DimName, OMatrix, OVector, SVector, S use crate::geometry::{ SuperTCategoryOf, TAffine, Transform, Scale }; -use crate::Point; +use crate::{ClosedAdd, Point}; /* * This file provides the following conversions: @@ -50,7 +50,9 @@ where T2: RealField + SupersetOf, C: SuperTCategoryOf, Const: DimNameAdd, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>> + DefaultAllocator: + Allocator, U1>, DimNameSum, U1>> + + Allocator, U1>, U1> + Allocator, U1>, DimNameSum, U1>>, { #[inline] @@ -75,7 +77,9 @@ where T1: RealField, T2: RealField + SupersetOf, Const: DimNameAdd, - DefaultAllocator: Allocator, U1>, DimNameSum, U1>> + DefaultAllocator: + Allocator, U1>, DimNameSum, U1>> + + Allocator, U1>, U1> + Allocator, U1>, DimNameSum, U1>>, // + Allocator // + Allocator @@ -108,12 +112,14 @@ where } } -impl From> +impl From> for OMatrix, U1>, DimNameSum, U1>> where Const: DimNameAdd, DefaultAllocator: - Allocator, U1>, DimNameSum, U1>> + Allocator>, + Allocator, U1>, DimNameSum, U1>> + + Allocator, U1>, U1> + + Allocator>, { #[inline] fn from(t: Scale) -> Self {