From 65b94ccb915e705f8afba254a36d08ad848e3822 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Crozet=20S=C3=A9bastien?= Date: Tue, 27 Apr 2021 13:17:51 +0200 Subject: [PATCH] Add more conversions for translations Add [T; D] <-> Translation Add Point -> Translation --- src/geometry/translation_conversion.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/geometry/translation_conversion.rs b/src/geometry/translation_conversion.rs index 8c8f860f..ff8e797f 100644 --- a/src/geometry/translation_conversion.rs +++ b/src/geometry/translation_conversion.rs @@ -11,6 +11,7 @@ use crate::geometry::{ AbstractRotation, Isometry, Similarity, SuperTCategoryOf, TAffine, Transform, Translation, Translation3, UnitDualQuaternion, UnitQuaternion, }; +use crate::Point; /* * This file provides the following conversions: @@ -199,6 +200,31 @@ impl From>> for Translation } } +impl From<[T; D]> for Translation { + #[inline] + fn from(coords: [T; D]) -> Self { + Translation { + vector: coords.into(), + } + } +} + +impl From> for Translation { + #[inline] + fn from(pt: Point) -> Self { + Translation { + vector: pt.coords.into(), + } + } +} + +impl Into<[T; D]> for Translation { + #[inline] + fn into(self) -> [T; D] { + self.vector.into() + } +} + impl From<[Translation; 2]> for Translation where