From ea29e088369ffba3f04934ebae81eeb14d9af01f Mon Sep 17 00:00:00 2001 From: Dimitri Sabadie Date: Tue, 24 Sep 2019 21:31:18 +0200 Subject: [PATCH] =?UTF-8?q?Fix=20cubic=20B=C3=A9zier=20interpolation.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 9 ++++++++- Cargo.toml | 2 +- src/interpolate.rs | 5 ++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e986d3..e48e0ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,13 @@ +# 2.0.1 + +> Tue Sep 24th 2019 + +- Fix the cubic Bézier curve interpolation. The “output” tangent is now taken by mirroring the + next key’s tangent around its control point. + # 2.0.0 -> Mon Sep 24th 2019 +> Mon Sep 23rd 2019 ## Major changes diff --git a/Cargo.toml b/Cargo.toml index 413e427..cd82274 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "splines" -version = "2.0.0" +version = "2.0.1" license = "BSD-3-Clause" authors = ["Dimitri Sabadie "] description = "Spline interpolation made easy" diff --git a/src/interpolate.rs b/src/interpolate.rs index 36042e2..2f1b3c2 100644 --- a/src/interpolate.rs +++ b/src/interpolate.rs @@ -240,7 +240,10 @@ where V: Linear, let one_t_3 = one_t_2 * one_t; let three = T::one() + T::one() + T::one(); - a.outer_mul(one_t_3) + u.outer_mul(three * one_t_2 * t) + v.outer_mul(three * one_t * t * t) + b.outer_mul(t * t * t) + // mirror the “output” tangent based on the next key “input” tangent + let v_ = b + b - v; + + a.outer_mul(one_t_3) + u.outer_mul(three * one_t_2 * t) + v_.outer_mul(three * one_t * t * t) + b.outer_mul(t * t * t) } macro_rules! impl_interpolate_simple {