From 5512b6a0f748dcce9d53e5e0f435c3db5cb12df2 Mon Sep 17 00:00:00 2001 From: Vlad Shcherbina Date: Thu, 22 Nov 2018 17:43:21 +0300 Subject: [PATCH] [breaking] Move lerp() from InnerSpace to VectorSpace Because it does not require dot product. Along the way, fix the comment. Fixes #471. --- CHANGELOG.md | 3 +++ src/structure.rs | 14 +++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c80305..9dcd253 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] +### Changed + - Move `lerp()` from `InnerSpace` to `VectorSpace` + ## [v0.16.1] - 2018-03-21 ### Added diff --git a/src/structure.rs b/src/structure.rs index 299d6f0..abcd450 100644 --- a/src/structure.rs +++ b/src/structure.rs @@ -181,6 +181,13 @@ where { /// The associated scalar. type Scalar: BaseNum; + + /// Returns the result of linearly interpolating the vector + /// towards `other` by the specified amount. + #[inline] + fn lerp(self, other: Self, amount: Self::Scalar) -> Self { + self + ((other - self) * amount) + } } /// A type with a distance function between values. @@ -261,13 +268,6 @@ where self * (magnitude / self.magnitude()) } - /// Returns the result of linearly interpolating the magnitude of the vector - /// towards the magnitude of `other` by the specified amount. - #[inline] - fn lerp(self, other: Self, amount: Self::Scalar) -> Self { - self + ((other - self) * amount) - } - /// Returns the /// [vector projection](https://en.wikipedia.org/wiki/Vector_projection) /// of the current inner space projected onto the supplied argument.