Skip to content

Commit e8800a5

Browse files
committed
2 parents 089f5bf + 3c7b305 commit e8800a5

1 file changed

Lines changed: 36 additions & 2 deletions

File tree

README.md

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,36 @@
1-
# simple-spline
2-
Simple cubic spline evaluation in Rust
1+
## Uniform Cubic Spline Interpolation & Inversion
2+
3+
This crate supports the following types of splines:
4+
* [B-spline](https://en.wikipedia.org/wiki/B-spline)
5+
* [Bezier](https://en.wikipedia.org/wiki/Composite_B%C3%A9zier_curve)
6+
* [Catmull-Rom](https://en.wikipedia.org/wiki/Cubic_Hermite_spline#Catmull%E2%80%93Rom_spline)
7+
* [Hermite](https://en.wikipedia.org/wiki/Cubic_Hermite_spline)
8+
* Linear
9+
* Power
10+
11+
If you come from a background of shading languages used in offline
12+
rendering this crate should feel like home.
13+
14+
The code is a Rust port of the resp. implementation found in the
15+
[Open Shading Language](https://github.com/imageworks/OpenShadingLanguage)
16+
C++ source.
17+
18+
# Example
19+
Using a combination of `spline()` and `spline_inverse()` it is
20+
possible to compute a full spline-with-nonuniform-abscissæ:
21+
```rust
22+
use uniform_cubic_splines::{
23+
spline, spline_inverse, basis::{CatmullRom, Linear}
24+
};
25+
26+
// We want to evaluate the spline at knot value 0.3.
27+
let x = 0.3;
28+
29+
let values = [0.0, 0.0, 1.3, 4.2, 6.4, 6.4];
30+
let knots = [0.0, 0.0, 0.1, 0.3, 1.0, 1.0];
31+
32+
let v = spline_inverse::<Linear, _>(x, &knots).unwrap();
33+
let y = spline::<CatmullRom, _, _>(v, &values);
34+
35+
assert!(y - 4.2 < 1e-6);
36+
```

0 commit comments

Comments
 (0)