diff --git a/src/point.rs b/src/point.rs index 77137dc2..ac896051 100644 --- a/src/point.rs +++ b/src/point.rs @@ -112,6 +112,12 @@ macro_rules! impl_point { $PointN::new($($field),+) } + impl From<$VectorN> for $PointN { + fn from(v: $VectorN) -> $PointN { + $PointN { $($field: v.$field),+ } + } + } + impl Array for $PointN { type Element = S; @@ -612,6 +618,7 @@ mod tests { let p: &mut Point3<_> = From::from(p); assert_eq!(p, &POINT3); } + assert_eq!(Point3::from(Vector3::new(1, 2, 3)), POINT3); } #[test]