Compare commits

..

1 Commits

Author SHA1 Message Date
Dimitri Sabadie
da43539b70
Run rustfmt. 2023-09-23 13:01:41 +02:00
6 changed files with 26 additions and 60 deletions

View File

@ -1,8 +1,6 @@
# Changelog # Changelog
* [4.3.1](#431) * [4.1.2](#412)
* [4.3](#43)
* [4.2](#42)
* [4.1.1](#411) * [4.1.1](#411)
* [4.1](#41) * [4.1](#41)
* [4.0.3](#403) * [4.0.3](#403)
@ -43,20 +41,7 @@
* [0.1.1](#011) * [0.1.1](#011)
* [0.1](#01) * [0.1](#01)
# 4.3.1 # 4.2.0
> Nov 22, 2023
- Add `Default` implementation for `Spline`. [c6ba847](https://github.com/phaazon/splines/commit/c6ba847)
# 4.3
> Sep 23, 2023
- Add support for `glam-0.23` and `glam-0.24`. [cdc48a4](https://github.com/phaazon/splines/commit/cdc48a4)
- Add `Spline::clear` to clear a spline keys without deallocating its internal storage. [eca09f1](https://github.com/phaazon/splines/commit/eca09f1)
# 4.2
> Feb 1, 2023 > Feb 1, 2023

View File

@ -1,6 +1,6 @@
[package] [package]
name = "splines" name = "splines"
version = "4.3.1" version = "4.2.0"
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"
@ -19,13 +19,13 @@ impl-cgmath = ["cgmath"]
impl-glam = ["glam"] impl-glam = ["glam"]
impl-nalgebra = ["nalgebra"] impl-nalgebra = ["nalgebra"]
serialization = ["serde"] serialization = ["serde"]
std = ["nalgebra/std"] std = []
[dependencies] [dependencies]
cgmath = { version = ">=0.17, <0.19", optional = true } cgmath = { version = ">=0.17, <0.19", optional = true }
glam = { version = ">=0.10, <0.25", optional = true } glam = { version = ">=0.10, <0.25", optional = true }
nalgebra = { version = ">=0.21, <0.33", default-features = false, optional = true } nalgebra = { version = ">=0.21, <0.33", optional = true }
serde = { version = "1", features = ["derive"], optional = true } serde = { version = "1", features = ["derive"], optional = true }
[dev-dependencies] [dev-dependencies]
float-cmp = ">=0.6, < 0.10" float-cmp = ">=0.6, < 0.10"

View File

@ -1,6 +1,6 @@
edition = "2018" edition = "2018"
fn_params_layout = "Tall" fn_args_layout = "Tall"
force_explicit_abi = true force_explicit_abi = true
hard_tabs = false hard_tabs = false
max_width = 100 max_width = 100

View File

@ -112,15 +112,10 @@ macro_rules! impl_Interpolate {
} }
} }
#[cfg(feature = "std")]
fn cosine(t: $t, a: Self, b: Self) -> Self { fn cosine(t: $t, a: Self, b: Self) -> Self {
let cos_nt = (1. - (t * $pi).cos()) * 0.5; let cos_nt = (1. - (t * $pi).cos()) * 0.5;
<Self as $crate::interpolate::Interpolate<$t>>::lerp(cos_nt, a, b) <Self as $crate::interpolate::Interpolate<$t>>::lerp(cos_nt, a, b)
} }
#[cfg(not(feature = "std"))]
fn cosine(t: $t, a: Self, b: Self) -> Self {
unimplemented!();
}
fn lerp(t: $t, a: Self, b: Self) -> Self { fn lerp(t: $t, a: Self, b: Self) -> Self {
a * (1. - t) + b * t a * (1. - t) + b * t
@ -181,15 +176,10 @@ macro_rules! impl_InterpolateT {
} }
} }
#[cfg(feature = "std")]
fn cosine(t: $t, a: Self, b: Self) -> Self { fn cosine(t: $t, a: Self, b: Self) -> Self {
let cos_nt = (1. - (t * $pi).cos()) * 0.5; let cos_nt = (1. - (t * $pi).cos()) * 0.5;
<Self as $crate::interpolate::Interpolate<$t>>::lerp(cos_nt, a, b) <Self as $crate::interpolate::Interpolate<$t>>::lerp(cos_nt, a, b)
} }
#[cfg(not(feature = "std"))]
fn cosine(t: $t, a: Self, b: Self) -> Self {
unimplemented!()
}
fn lerp(t: $t, a: Self, b: Self) -> Self { fn lerp(t: $t, a: Self, b: Self) -> Self {
let t = Self::from(t); let t = Self::from(t);
@ -242,6 +232,6 @@ macro_rules! impl_InterpolateT {
}; };
} }
impl_Interpolate!(f32, f32, f32::consts::PI); impl_Interpolate!(f32, f32, std::f32::consts::PI);
impl_Interpolate!(f64, f64, f64::consts::PI); impl_Interpolate!(f64, f64, std::f64::consts::PI);
impl_InterpolateT!(f32, f64, f32::consts::PI); impl_InterpolateT!(f32, f64, std::f32::consts::PI);

View File

@ -1,27 +1,18 @@
#[cfg(not(feature = "std"))]
use core::f32;
#[cfg(not(feature = "std"))]
use core::f64;
#[cfg(feature = "std")]
use std::f32;
#[cfg(feature = "std")]
use std::f64;
use crate::impl_Interpolate; use crate::impl_Interpolate;
use nalgebra::{Quaternion, Vector1, Vector2, Vector3, Vector4, Vector5, Vector6}; use nalgebra::{Quaternion, Vector1, Vector2, Vector3, Vector4, Vector5, Vector6};
impl_Interpolate!(f32, Vector1<f32>, f32::consts::PI); impl_Interpolate!(f32, Vector1<f32>, std::f32::consts::PI);
impl_Interpolate!(f32, Vector2<f32>, f32::consts::PI); impl_Interpolate!(f32, Vector2<f32>, std::f32::consts::PI);
impl_Interpolate!(f32, Vector3<f32>, f32::consts::PI); impl_Interpolate!(f32, Vector3<f32>, std::f32::consts::PI);
impl_Interpolate!(f32, Vector4<f32>, f32::consts::PI); impl_Interpolate!(f32, Vector4<f32>, std::f32::consts::PI);
impl_Interpolate!(f32, Vector5<f32>, f32::consts::PI); impl_Interpolate!(f32, Vector5<f32>, std::f32::consts::PI);
impl_Interpolate!(f32, Vector6<f32>, f32::consts::PI); impl_Interpolate!(f32, Vector6<f32>, std::f32::consts::PI);
impl_Interpolate!(f32, Quaternion<f32>, f32::consts::PI); impl_Interpolate!(f32, Quaternion<f32>, std::f32::consts::PI);
impl_Interpolate!(f64, Vector1<f64>, f64::consts::PI); impl_Interpolate!(f64, Vector1<f64>, std::f64::consts::PI);
impl_Interpolate!(f64, Vector2<f64>, f64::consts::PI); impl_Interpolate!(f64, Vector2<f64>, std::f64::consts::PI);
impl_Interpolate!(f64, Vector3<f64>, f64::consts::PI); impl_Interpolate!(f64, Vector3<f64>, std::f64::consts::PI);
impl_Interpolate!(f64, Vector4<f64>, f64::consts::PI); impl_Interpolate!(f64, Vector4<f64>, std::f64::consts::PI);
impl_Interpolate!(f64, Vector5<f64>, f64::consts::PI); impl_Interpolate!(f64, Vector5<f64>, std::f64::consts::PI);
impl_Interpolate!(f64, Vector6<f64>, f64::consts::PI); impl_Interpolate!(f64, Vector6<f64>, std::f64::consts::PI);
impl_Interpolate!(f64, Quaternion<f64>, f64::consts::PI); impl_Interpolate!(f64, Quaternion<f64>, std::f64::consts::PI);

View File

@ -1,6 +1,6 @@
//! Spline curves and operations. //! Spline curves and operations.
// #[cfg(feature = "std")] #[cfg(feature = "std")]
use crate::interpolate::{Interpolate, Interpolator}; use crate::interpolate::{Interpolate, Interpolator};
use crate::interpolation::Interpolation; use crate::interpolation::Interpolation;
use crate::key::Key; use crate::key::Key;
@ -27,7 +27,7 @@ use std::cmp::Ordering;
/// for the required interpolation mode, you get `None`. /// for the required interpolation mode, you get `None`.
/// - [`Spline::clamped_sample`]: behaves like [`Spline::sample`] but will return either the first /// - [`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. /// or last key if out of bound; it will return `None` if not enough key.
#[derive(Debug, Clone, Default)] #[derive(Debug, Clone)]
#[cfg_attr( #[cfg_attr(
any(feature = "serialization", feature = "serde"), any(feature = "serialization", feature = "serde"),
derive(Deserialize, Serialize) derive(Deserialize, Serialize)