From db27a080f15444fec66bc3257a1d91e64cbc5e54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Crozet=20S=C3=A9bastien?= Date: Tue, 27 Apr 2021 13:17:12 +0200 Subject: [PATCH] Cleanup conversions between points and static vectors. --- src/geometry/point_construction.rs | 14 -------------- src/geometry/point_conversion.rs | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/geometry/point_construction.rs b/src/geometry/point_construction.rs index f50a3fc1..7e34137c 100644 --- a/src/geometry/point_construction.rs +++ b/src/geometry/point_construction.rs @@ -225,17 +225,3 @@ componentwise_constructors_impl!( "# use nalgebra::Point6;\nlet p = Point6::new(1.0, 2.0, 3.0, 4.0, 5.0, 6.0);\nassert!(p.x == 1.0 && p.y == 2.0 && p.z == 3.0 && p.w == 4.0 && p.a == 5.0 && p.b == 6.0);"; Point6, Vector6, x:0, y:1, z:2, w:3, a:4, b:5; ); - -macro_rules! from_array_impl( - ($($Point: ident, $len: expr);*) => {$( - impl From<[T; $len]> for $Point { - fn from(coords: [T; $len]) -> Self { - Self { - coords: coords.into() - } - } - } - )*} -); - -from_array_impl!(Point1, 1; Point2, 2; Point3, 3; Point4, 4; Point5, 5; Point6, 6); diff --git a/src/geometry/point_conversion.rs b/src/geometry/point_conversion.rs index 08438ec0..91cd62ce 100644 --- a/src/geometry/point_conversion.rs +++ b/src/geometry/point_conversion.rs @@ -81,6 +81,22 @@ where } } +impl From<[T; D]> for Point { + #[inline] + fn from(coords: [T; D]) -> Self { + Point { + coords: coords.into(), + } + } +} + +impl Into<[T; D]> for Point { + #[inline] + fn into(self) -> [T; D] { + self.coords.into() + } +} + impl From>> for Point { #[inline] fn from(coords: OVector>) -> Self {