Merge pull request #31 from phaazon/fix/bezier-interpolation
Fix/bezier interpolation
This commit is contained in:
commit
336c1c7e80
@ -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
|
# 2.0.0
|
||||||
|
|
||||||
> Mon Sep 24th 2019
|
> Mon Sep 23rd 2019
|
||||||
|
|
||||||
## Major changes
|
## Major changes
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "splines"
|
name = "splines"
|
||||||
version = "2.0.0"
|
version = "2.0.1"
|
||||||
license = "BSD-3-Clause"
|
license = "BSD-3-Clause"
|
||||||
authors = ["Dimitri Sabadie <dimitri.sabadie@gmail.com>"]
|
authors = ["Dimitri Sabadie <dimitri.sabadie@gmail.com>"]
|
||||||
description = "Spline interpolation made easy"
|
description = "Spline interpolation made easy"
|
||||||
|
@ -240,7 +240,10 @@ where V: Linear<T>,
|
|||||||
let one_t_3 = one_t_2 * one_t;
|
let one_t_3 = one_t_2 * one_t;
|
||||||
let three = T::one() + T::one() + T::one();
|
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 {
|
macro_rules! impl_interpolate_simple {
|
||||||
|
@ -136,11 +136,6 @@ impl<T, V> Spline<T, V> {
|
|||||||
|
|
||||||
if let Interpolation::Bezier(v) = cp1.interpolation {
|
if let Interpolation::Bezier(v) = cp1.interpolation {
|
||||||
Some(Interpolate::cubic_bezier(cp0.value, u, v, cp1.value, nt))
|
Some(Interpolate::cubic_bezier(cp0.value, u, v, cp1.value, nt))
|
||||||
//let one_nt = T::one() - nt;
|
|
||||||
//let one_nt_2 = one_nt * one_nt;
|
|
||||||
//let one_nt_3 = one_nt_2 * one_nt;
|
|
||||||
//let three_one_nt_2 = one_nt_2 + one_nt_2 + one_nt_2; // one_nt_2 * 3
|
|
||||||
//let r = cp0.value * one_nt_3;
|
|
||||||
} else {
|
} else {
|
||||||
Some(Interpolate::quadratic_bezier(cp0.value, u, cp1.value, nt))
|
Some(Interpolate::quadratic_bezier(cp0.value, u, cp1.value, nt))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user