Compare commits
25 Commits
Author | SHA1 | Date | |
---|---|---|---|
d9770ad60b | |||
3dfea81856 | |||
604dcc6e27 | |||
8c952ae242 | |||
b52643b5d7 | |||
dc6ef0a5cc | |||
043a8608c3 | |||
295043e5af | |||
1c249215c9 | |||
5a7e74d79c | |||
2012105a72 | |||
f25ebb2c64 | |||
e9c1de389f | |||
bdeaefd9f9 | |||
ace0f4ec50 | |||
b056a4e9a7 | |||
042253ab9c | |||
270f225394 | |||
138828e798 | |||
0ca1c5aa48 | |||
f4c8be33b9 | |||
26bd5c88eb | |||
a4cd49fd20 | |||
09bc7069b2 | |||
8dc8606bf0 |
22
.github/workflows/ci.yaml
vendored
22
.github/workflows/ci.yaml
vendored
@ -6,38 +6,22 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Build
|
||||
run: |
|
||||
cargo build --verbose --all-features
|
||||
- name: Test
|
||||
run: |
|
||||
cargo test --verbose --all-features
|
||||
run: cargo test --verbose --all-features
|
||||
|
||||
build-windows:
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Build
|
||||
run: |
|
||||
cargo build --verbose --all-features
|
||||
- name: Test
|
||||
run: |
|
||||
cargo test --verbose --all-features
|
||||
run: cargo test --verbose --all-features
|
||||
|
||||
build-macosx:
|
||||
runs-on: macOS-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Rust requirements
|
||||
run: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile=minimal
|
||||
- name: Build
|
||||
run: |
|
||||
. ~/.cargo/env
|
||||
cargo build --verbose --all-features
|
||||
- name: Test
|
||||
run: |
|
||||
. ~/.cargo/env
|
||||
cargo test --verbose --all-features
|
||||
run: cargo test --verbose --all-features
|
||||
|
||||
quality:
|
||||
runs-on: ubuntu-latest
|
||||
|
23
CHANGELOG.md
23
CHANGELOG.md
@ -2,6 +2,8 @@
|
||||
|
||||
<!-- vim-markdown-toc GFM -->
|
||||
|
||||
* [4.1.1](#411)
|
||||
* [4.1](#41)
|
||||
* [4.0.3](#403)
|
||||
* [4.0.2](#402)
|
||||
* [4.0.1](#401)
|
||||
@ -42,6 +44,27 @@
|
||||
|
||||
<!-- vim-markdown-toc -->
|
||||
|
||||
# 4.1.1
|
||||
|
||||
> Jul 27, 2022
|
||||
|
||||
- Internal enhancement of sampling splines by looking for control points. That brings the lookup from _O(1)_ to
|
||||
_O(log(N))_. That is super embarassing because it should have been the default from the very first commit. Sorry
|
||||
about that.
|
||||
- Fix hermite cubic interpolation.
|
||||
- Add support for `glam-0.21`.
|
||||
- Add support for `nalgebra-0.31`.
|
||||
|
||||
# 4.1
|
||||
|
||||
> Mar 28, 2022
|
||||
|
||||
- Support for edition 2021.
|
||||
- Bump `float-cmp` dependency.
|
||||
- Bump `glam` dependency.
|
||||
- Bump `nalgebra` dependency.
|
||||
- Simplify the CI.
|
||||
|
||||
# 4.0.3
|
||||
|
||||
> Jul 11, 2021
|
||||
|
10
Cargo.toml
10
Cargo.toml
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "splines"
|
||||
version = "4.0.3"
|
||||
version = "4.1.1"
|
||||
license = "BSD-3-Clause"
|
||||
authors = ["Dimitri Sabadie <dimitri.sabadie@gmail.com>"]
|
||||
description = "Spline interpolation made easy"
|
||||
@ -11,7 +11,7 @@ repository = "https://github.com/phaazon/splines"
|
||||
documentation = "https://docs.rs/splines"
|
||||
readme = "README.md"
|
||||
|
||||
edition = "2018"
|
||||
edition = "2021"
|
||||
|
||||
[badges]
|
||||
travis-ci = { repository = "phaazon/splines", branch = "master" }
|
||||
@ -29,12 +29,12 @@ std = []
|
||||
|
||||
[dependencies]
|
||||
cgmath = { version = ">=0.17, <0.19", optional = true }
|
||||
glam = { version = ">=0.10, <0.18", optional = true }
|
||||
nalgebra = { version = ">=0.21, <0.28", optional = true }
|
||||
glam = { version = ">=0.10, <0.22", optional = true }
|
||||
nalgebra = { version = ">=0.21, <0.32", optional = true }
|
||||
serde = { version = "1", features = ["derive"], optional = true }
|
||||
|
||||
[dev-dependencies]
|
||||
float-cmp = ">=0.6, < 0.9"
|
||||
float-cmp = ">=0.6, < 0.10"
|
||||
serde_json = "1"
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
|
@ -127,15 +127,16 @@ macro_rules! impl_Interpolate {
|
||||
let three_t = t * 3.;
|
||||
let t2 = t * t;
|
||||
let t3 = t2 * t;
|
||||
let two_t3 = t3 * two_t;
|
||||
let three_t2 = t2 * three_t;
|
||||
let two_t3 = t2 * two_t;
|
||||
let two_t2 = t * two_t;
|
||||
let three_t2 = t * three_t;
|
||||
|
||||
// tangents
|
||||
let m0 = (b.1 - x.1) / (b.0 - x.0);
|
||||
let m1 = (y.1 - a.1) / (y.0 - a.0);
|
||||
let m0 = (b.1 - x.1) / (b.0 - x.0) * (b.0 - a.0);
|
||||
let m1 = (y.1 - a.1) / (y.0 - a.0) * (b.0 - a.0);
|
||||
|
||||
a.1 * (two_t3 - three_t2 + 1.)
|
||||
+ m0 * (t3 - t2 * two_t + t)
|
||||
+ m0 * (t3 - two_t2 + t)
|
||||
+ b.1 * (three_t2 - two_t3)
|
||||
+ m1 * (t3 - t2)
|
||||
}
|
||||
@ -192,15 +193,16 @@ macro_rules! impl_InterpolateT {
|
||||
let three_t = t * 3.;
|
||||
let t2 = t * t;
|
||||
let t3 = t2 * t;
|
||||
let two_t3 = t3 * two_t;
|
||||
let three_t2 = t2 * three_t;
|
||||
let two_t3 = t2 * two_t;
|
||||
let two_t2 = t * two_t;
|
||||
let three_t2 = t * three_t;
|
||||
|
||||
// tangents
|
||||
let m0 = (b.1 - x.1) / (Self::from(b.0 - x.0));
|
||||
let m1 = (y.1 - a.1) / (Self::from(y.0 - a.0));
|
||||
let m0 = (b.1 - x.1) / (Self::from(b.0 - x.0)) * (Self::from(b.0 - a.0));
|
||||
let m1 = (y.1 - a.1) / (Self::from(y.0 - a.0)) * (Self::from(b.0 - a.0));
|
||||
|
||||
a.1 * (two_t3 - three_t2 + 1.)
|
||||
+ m0 * (t3 - t2 * two_t + t)
|
||||
+ m0 * (t3 - two_t2 + t)
|
||||
+ b.1 * (three_t2 - two_t3)
|
||||
+ m1 * (t3 - t2)
|
||||
}
|
||||
|
@ -318,37 +318,20 @@ pub struct KeyMut<'a, T, V> {
|
||||
}
|
||||
|
||||
// Find the lower control point corresponding to a given time.
|
||||
// It has the property to have a timestamp smaller or equal to t
|
||||
fn search_lower_cp<T, V>(cps: &[Key<T, V>], t: T) -> Option<usize>
|
||||
where
|
||||
T: PartialOrd,
|
||||
{
|
||||
let mut i = 0;
|
||||
let len = cps.len();
|
||||
|
||||
if len < 2 {
|
||||
return None;
|
||||
}
|
||||
|
||||
loop {
|
||||
let cp = &cps[i];
|
||||
let cp1 = &cps[i + 1];
|
||||
|
||||
if t >= cp1.t {
|
||||
if i >= len - 2 {
|
||||
return None;
|
||||
}
|
||||
|
||||
i += 1;
|
||||
} else if t < cp.t {
|
||||
if i == 0 {
|
||||
return None;
|
||||
}
|
||||
|
||||
i -= 1;
|
||||
} else {
|
||||
break; // found
|
||||
}
|
||||
match cps.binary_search_by(|key| key.t.partial_cmp(&t).unwrap()) {
|
||||
Err(i) if i >= len => None,
|
||||
Err(i) if i == 0 => None,
|
||||
Err(i) => Some(i - 1),
|
||||
Ok(i) if i == len - 1 => None,
|
||||
Ok(i) => Some(i),
|
||||
}
|
||||
|
||||
Some(i)
|
||||
}
|
||||
|
Reference in New Issue
Block a user