From 9e2541f949c6c593e1d41b6e7ad51e77c97fcbee Mon Sep 17 00:00:00 2001 From: sebcrozet Date: Sat, 13 Oct 2018 10:45:42 +0200 Subject: [PATCH] Add a Point::from_slice --- CHANGELOG.md | 7 +++++-- src/geometry/point_construction.rs | 6 ++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 399deea5..7bae7fa8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,8 +14,11 @@ This project adheres to [Semantic Versioning](http://semver.org/). * Add `.slerp` and `.try_slerp` to unit vectors. * Add `.to_projective` and `.as_projective` to `Perspective3` and `Orthographic3` in order to use them as `Projective3` structures. - * Add impl for `From/Into` to allow the conversion of any transformation type to a matrix. - + * Add `From/Into` impls to allow the conversion of any transformation type to a matrix. + * Add `Into` impls to convert a matrix slice into an owned matrix. + * Add `Point*::from_slice` to create a point from a slice. + * Add `.map_with_location` to matrices to apply a map which passes the component indices to the user-defined closure alongide + the component itself. ## [0.16.0] All dependencies have been updated to their latest versions. diff --git a/src/geometry/point_construction.rs b/src/geometry/point_construction.rs index 837b3e44..9d6497b8 100644 --- a/src/geometry/point_construction.rs +++ b/src/geometry/point_construction.rs @@ -31,6 +31,12 @@ where Self::from_coordinates(VectorN::from_element(N::zero())) } + /// Creates a new point from a slice. + #[inline] + pub fn from_slice(components: &[N]) -> Self { + Self::from_coordinates(VectorN::from_row_slice(components)) + } + /// Creates a new point from its homogeneous vector representation. /// /// In practice, this builds a D-dimensional points with the same first D component as `v`