23 Commits
4.0 ... 4.1

Author SHA1 Message Date
b056a4e9a7 4.1.0. 2022-03-28 11:38:25 +02:00
042253ab9c Merge pull request #83 from phaazon/nalgebra-update
Bump nalgebra dependency.
2022-03-25 09:14:31 +01:00
270f225394 Bump nalgebra dependency. 2022-03-24 17:09:20 +01:00
138828e798 Merge pull request #79 from phaazon/dependabot/cargo/master/glam-gte-0.10-and-lt-0.21
Update glam requirement from >=0.10, <0.18 to >=0.10, <0.21
2022-03-22 20:34:31 +01:00
0ca1c5aa48 Merge pull request #75 from phaazon/dependabot/cargo/master/float-cmp-gte-0.6-and-lt-0.10
Update float-cmp requirement from >=0.6, < 0.9 to >=0.6, < 0.10
2022-03-22 20:33:36 +01:00
f4c8be33b9 Merge pull request #82 from phaazon/edition-2021
Edition 2021
2022-03-22 20:20:01 +01:00
26bd5c88eb Update and simplify the CI. 2022-03-22 16:15:39 +01:00
a4cd49fd20 Switch to edition 2021. 2022-03-22 16:14:28 +01:00
09bc7069b2 Update glam requirement from >=0.10, <0.18 to >=0.10, <0.21
Updates the requirements on [glam](https://github.com/bitshifter/glam-rs) to permit the latest version.
- [Release notes](https://github.com/bitshifter/glam-rs/releases)
- [Changelog](https://github.com/bitshifter/glam-rs/blob/main/CHANGELOG.md)
- [Commits](https://github.com/bitshifter/glam-rs/compare/0.10.0...0.20.0)

---
updated-dependencies:
- dependency-name: glam
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-11-02 04:13:32 +00:00
8dc8606bf0 Update float-cmp requirement from >=0.6, < 0.9 to >=0.6, < 0.10
Updates the requirements on [float-cmp](https://github.com/mikedilger/float-cmp) to permit the latest version.
- [Release notes](https://github.com/mikedilger/float-cmp/releases)
- [Commits](https://github.com/mikedilger/float-cmp/commits)

---
updated-dependencies:
- dependency-name: float-cmp
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-07-22 04:19:29 +00:00
fc2f53200f Fix previous commit (new implementors). 2021-07-11 17:46:59 +02:00
b3836975c3 Add more implementors for Interpolate. 2021-07-11 17:44:05 +02:00
322d271499 Merge pull request #73 from phaazon/next/release
Prepare 4.0.1.
2021-07-11 16:54:24 +02:00
e64298dc88 Prepare 4.0.1. 2021-07-11 16:50:28 +02:00
32e5122339 Merge pull request #72 from phaazon/update-dependencies
Update all dependencies to latest version.
2021-07-11 16:47:34 +02:00
1be94935cf Update all dependencies to latest version. 2021-07-11 16:27:24 +02:00
06f6e4b578 Merge pull request #71 from phaazon/better-feature-gates
Provide better feature gates.
2021-07-11 16:25:45 +02:00
87e27e732d Synchronize README. 2021-07-11 16:22:42 +02:00
fb678f9613 Provide better feature gates.
- `serialization` becomes `serde`.
- `impl-nalgebra` becomes `nalgebra`.
- `impl-cgmath` becomes `cgmath`.
- `impl-glam` becomes `glam`.

Already existing feature gates are kept around so that we don’t
introduce a breaking change.
2021-07-11 16:18:47 +02:00
ee4230340b Merge pull request #64 from phaazon/dependabot/cargo/master/glam-gte-0.10-and-lt-0.15
Update glam requirement from >=0.10, <0.13 to >=0.10, <0.15
2021-07-11 16:09:46 +02:00
f585119883 Merge pull request #66 from phaazon/dependabot/add-v2-config-file
Upgrade to GitHub-native Dependabot
2021-05-04 00:32:44 +02:00
25d5c5217e Upgrade to GitHub-native Dependabot 2021-04-29 15:36:58 +00:00
355178f5fa Update glam requirement from >=0.10, <0.13 to >=0.10, <0.15
Updates the requirements on [glam](https://github.com/bitshifter/glam-rs) to permit the latest version.
- [Release notes](https://github.com/bitshifter/glam-rs/releases)
- [Changelog](https://github.com/bitshifter/glam-rs/blob/master/CHANGELOG.md)
- [Commits](https://github.com/bitshifter/glam-rs/compare/0.10.0...0.14.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-04-09 09:54:49 +00:00
11 changed files with 167 additions and 62 deletions

View File

@ -1,12 +0,0 @@
version: 1
update_configs:
- package_manager: "rust:cargo"
directory: "."
update_schedule: "live"
target_branch: "master"
default_reviewers:
- "phaazon"
default_assignees:
- "phaazon"
default_labels:
- "dependency-update"

25
.github/dependabot.yml vendored Normal file
View File

@ -0,0 +1,25 @@
version: 2
updates:
- package-ecosystem: cargo
directory: "/."
schedule:
interval: daily
time: "04:00"
open-pull-requests-limit: 10
target-branch: master
reviewers:
- phaazon
assignees:
- phaazon
labels:
- dependency-update
ignore:
- dependency-name: glam
versions:
- 0.13.0
- dependency-name: nalgebra
versions:
- 0.25.0
- dependency-name: cgmath
versions:
- 0.18.0

View File

@ -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

View File

@ -2,6 +2,10 @@
<!-- vim-markdown-toc GFM -->
* [4.1](#41)
* [4.0.3](#403)
* [4.0.2](#402)
* [4.0.1](#401)
* [4.0](#40)
* [Major changes](#major-changes)
* [Patch changes](#patch-changes)
@ -39,6 +43,40 @@
<!-- vim-markdown-toc -->
# 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
- Add more implementors for `Interpolate`.
# 4.0.2
> Jul 11, 2021
- **Yanked.**
# 4.0.1
> Jul 11, 2021
- Add support up to `glam-0.17`.
- Add support up to `nalgebra-0.27`.
- Replace the name of some feature gates:
- `serialization` becomes `serde`.
- `impl-*` becomes `*`.
- The previous feature gates are kept around to prevent a breaking change but will eventually be removed in the next
major update.
# 4.0
> Mar 05, 2021

View File

@ -1,6 +1,6 @@
[package]
name = "splines"
version = "4.0.0"
version = "4.1.0"
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" }
@ -24,18 +24,17 @@ default = ["std"]
impl-cgmath = ["cgmath"]
impl-glam = ["glam"]
impl-nalgebra = ["nalgebra"]
serialization = ["serde", "serde_derive"]
serialization = ["serde"]
std = []
[dependencies]
cgmath = { version = ">=0.17, <0.19", optional = true }
glam = { version = ">=0.10, <0.13", optional = true }
nalgebra = { version = ">=0.21, <0.25", optional = true }
serde = { version = "1", optional = true }
serde_derive = { version = "1", optional = true }
glam = { version = ">=0.10, <0.21", optional = true }
nalgebra = { version = ">=0.21, <0.31", 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]
@ -46,4 +45,4 @@ name = "hello-world"
[[example]]
name = "serialization"
required-features = ["serialization"]
required-features = ["serde"]

View File

@ -83,19 +83,19 @@ not. Its especially important to see how it copes with the documentation.
So heres a list of currently supported features and how to enable them:
- **Serialization / deserialization.**
- **Serde.**
- This feature implements both the `Serialize` and `Deserialize` traits from `serde` for all
types exported by this crate.
- Enable with the `"serialization"` feature.
- Enable with the `"serde"` feature.
- **[cgmath](https://crates.io/crates/cgmath) implementors.**
- Adds some useful implementations of `Interpolate` for some cgmath types.
- Enable with the `"impl-cgmath"` feature.
- Enable with the `"cgmath"` feature.
- **[glam](https://crates.io/crates/glam) implementors.**
- Adds some useful implementations of `Interpolate` for some glam types.
- Enable with the `"impl-glam"` feature.
- Enable with the `"glam"` feature.
- **[nalgebra](https://crates.io/crates/nalgebra) implementors.**
- Adds some useful implementations of `Interpolate` for some nalgebra types.
- Enable with the `"impl-nalgebra"` feature.
- Enable with the `"nalgebra"` feature.
- **Standard library / no standard library.**
- Its possible to compile against the standard library or go on your own without it.
- Compiling with the standard library is enabled by default.

View File

@ -163,5 +163,73 @@ macro_rules! impl_Interpolate {
};
}
#[macro_export]
macro_rules! impl_InterpolateT {
($t:ty, $v:ty, $pi:expr) => {
impl $crate::interpolate::Interpolate<$t> for $v {
fn step(t: $t, threshold: $t, a: Self, b: Self) -> Self {
if t < threshold {
a
} else {
b
}
}
fn cosine(t: $t, a: Self, b: Self) -> Self {
let cos_nt = (1. - (t * $pi).cos()) * 0.5;
<Self as $crate::interpolate::Interpolate<$t>>::lerp(cos_nt, a, b)
}
fn lerp(t: $t, a: Self, b: Self) -> Self {
let t = Self::from(t);
a * (1. - t) + b * t
}
fn cubic_hermite(t: $t, x: ($t, Self), a: ($t, Self), b: ($t, Self), y: ($t, Self)) -> Self {
// sampler stuff
let t = Self::from(t);
let two_t = t * 2.;
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;
// 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));
a.1 * (two_t3 - three_t2 + 1.)
+ m0 * (t3 - t2 * two_t + t)
+ b.1 * (three_t2 - two_t3)
+ m1 * (t3 - t2)
}
fn quadratic_bezier(t: $t, a: Self, u: Self, b: Self) -> Self {
let t = Self::from(t);
let one_t = 1. - t;
let one_t2 = one_t * one_t;
u + (a - u) * one_t2 + (b - u) * t * t
}
fn cubic_bezier(t: $t, a: Self, u: Self, v: Self, b: Self) -> Self {
let t = Self::from(t);
let one_t = 1. - t;
let one_t2 = one_t * one_t;
let one_t3 = one_t2 * one_t;
let t2 = t * t;
a * one_t3 + (u * one_t2 * t + v * one_t * t2) * 3. + b * t2 * t
}
fn cubic_bezier_mirrored(t: $t, a: Self, u: Self, v: Self, b: Self) -> Self {
<Self as $crate::interpolate::Interpolate<$t>>::cubic_bezier(t, a, u, b + b - v, b)
}
}
};
}
impl_Interpolate!(f32, f32, std::f32::consts::PI);
impl_Interpolate!(f64, f64, std::f64::consts::PI);
impl_InterpolateT!(f32, f64, std::f32::consts::PI);

View File

@ -1,7 +1,7 @@
//! Available interpolation modes.
#[cfg(feature = "serialization")]
use serde_derive::{Deserialize, Serialize};
#[cfg(any(feature = "serialization", feature = "serde"))]
use serde::{Deserialize, Serialize};
/// Available kind of interpolations.
///
@ -9,7 +9,7 @@ use serde_derive::{Deserialize, Serialize};
#[non_exhaustive]
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
#[cfg_attr(
feature = "serialization",
any(feature = "serialization", feature = "serde"),
derive(Deserialize, Serialize),
serde(rename_all = "snake_case")
)]

View File

@ -7,8 +7,8 @@
//! interpolation mode on a key-based way, allowing you to implement and encode complex curves.
use crate::interpolation::Interpolation;
#[cfg(feature = "serialization")]
use serde_derive::{Deserialize, Serialize};
#[cfg(any(feature = "serialization", feature = "serde"))]
use serde::{Deserialize, Serialize};
/// A spline control point.
///
@ -19,7 +19,7 @@ use serde_derive::{Deserialize, Serialize};
/// [`Interpolation`]: crate::interpolation::Interpolation
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
#[cfg_attr(
feature = "serialization",
any(feature = "serialization", feature = "serde"),
derive(Deserialize, Serialize),
serde(rename_all = "snake_case")
)]

View File

@ -84,19 +84,19 @@
//!
//! So heres a list of currently supported features and how to enable them:
//!
//! - **Serialization / deserialization.**
//! - **Serde.**
//! - This feature implements both the `Serialize` and `Deserialize` traits from `serde` for all
//! types exported by this crate.
//! - Enable with the `"serialization"` feature.
//! - Enable with the `"serde"` feature.
//! - **[cgmath](https://crates.io/crates/cgmath) implementors.**
//! - Adds some useful implementations of `Interpolate` for some cgmath types.
//! - Enable with the `"impl-cgmath"` feature.
//! - Enable with the `"cgmath"` feature.
//! - **[glam](https://crates.io/crates/glam) implementors.**
//! - Adds some useful implementations of `Interpolate` for some glam types.
//! - Enable with the `"impl-glam"` feature.
//! - Enable with the `"glam"` feature.
//! - **[nalgebra](https://crates.io/crates/nalgebra) implementors.**
//! - Adds some useful implementations of `Interpolate` for some nalgebra types.
//! - Enable with the `"impl-nalgebra"` feature.
//! - Enable with the `"nalgebra"` feature.
//! - **Standard library / no standard library.**
//! - Its possible to compile against the standard library or go on your own without it.
//! - Compiling with the standard library is enabled by default.
@ -112,15 +112,15 @@
#[cfg(not(feature = "std"))]
extern crate alloc;
#[cfg(feature = "impl-cgmath")]
#[cfg(any(feature = "impl-cgmath", feature = "cgmath"))]
mod cgmath;
#[cfg(feature = "impl-glam")]
#[cfg(any(feature = "impl-glam", feature = "glam"))]
mod glam;
pub mod interpolate;
pub mod interpolation;
pub mod iter;
pub mod key;
#[cfg(feature = "impl-nalgebra")]
#[cfg(any(feature = "impl-nalgebra", feature = "nalgebra"))]
mod nalgebra;
pub mod spline;

View File

@ -10,8 +10,8 @@ use alloc::vec::Vec;
use core::cmp::Ordering;
#[cfg(not(feature = "std"))]
use core::ops::{Div, Mul};
#[cfg(feature = "serialization")]
use serde_derive::{Deserialize, Serialize};
#[cfg(any(feature = "serialization", feature = "serde"))]
use serde::{Deserialize, Serialize};
#[cfg(feature = "std")]
use std::cmp::Ordering;
@ -28,7 +28,10 @@ use std::cmp::Ordering;
/// - [`Spline::clamped_sample`]: behaves like [`Spline::sample`] but will return either the first
/// or last key if out of bound; it will return `None` if not enough key.
#[derive(Debug, Clone)]
#[cfg_attr(feature = "serialization", derive(Deserialize, Serialize))]
#[cfg_attr(
any(feature = "serialization", feature = "serde"),
derive(Deserialize, Serialize)
)]
pub struct Spline<T, V>(pub(crate) Vec<Key<T, V>>);
impl<T, V> Spline<T, V> {