MCPcopy Index your code
hub / github.com/Twinklebear/bspline

github.com/Twinklebear/bspline @1.1.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release 1.1.0 ↗ · + Follow
65 symbols 110 edges 7 files 31 documented · 48%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

logo

A library for computing B-spline interpolating curves on generic control points. bspline can be used to evaluate B-splines of varying orders on any type that can be linearly interpolated, ranging from floats, positions, RGB colors to transformation matrices and so on.

The bspline logo was generated using this library with a cubic B-spline in 2D for the positioning of the curve and a quadratic B-spline in RGB space to color it (check out the logo example!). Other much simpler examples of 1D and 2D quadratic, cubic and quartic B-splines can also be found in the examples.

Installation

Just grab the crate on crates.io and you're set!

Crates.io Build Status

Documentation

Rust doc can be found here.

1D Example

This example shows how to create the 1D cardinal cubic B-spline example shown on Wikipedia's B-splines page. For examples of evaluating the spline to an image and saving the output see the examples.

let points = vec![0.0, 0.0, 0.0, 6.0, 0.0, 0.0, 0.0]
let knots = vec![-2.0, -2.0, -2.0, -2.0, -1.0, 0.0, 1.0, 2.0, 2.0, 2.0, 2.0];
let degree = 3;
let spline = bspline::BSpline::new(degree, points, knots);

Readings on B-splines

The library assumes you are familiar at some level with how B-splines work, e.g. how control points and knots and effect the curve produced. No interactive editor is provided (at least currently). Some good places to start reading about B-splines to effectively use this library can be found below.

nalgebra support

nalgerba is one of the most popular linear algbera packages for Rust. To make this create compatible with it, you need to enable the nalgebra-support feature and then you can recreate the above example:

use nalgebra as na;

let points = na::DVector::from(vec![0.0, 0.0, 0.0, 6.0, 0.0, 0.0, 0.0])
let knots = na::DVector::from(vec![-2.0, -2.0, -2.0, -2.0, -1.0, 0.0, 1.0, 2.0, 2.0, 2.0, 2.0]);
let degree = 3;
let spline = bspline::BSpline::new(degree, points, knots);

Extension points exported contracts — how you extend this code

Interpolate (Interface)
The interpolate trait is used to linearly interpolate between two types (or in the case of Quaternions, spherically line [1 …
src/lib.rs

Core symbols most depended-on inside this repo

point
called by 8
src/lib.rs
knot_domain
called by 5
src/lib.rs
control_points
called by 4
src/lib.rs
plot_2d
called by 4
examples/plot2d.rs
clamp
called by 3
benches/logo_bench.rs
clamp
called by 3
examples/logo.rs
plot_1d
called by 3
examples/plot1d.rs
to_srgb
called by 1
benches/logo_bench.rs

Shape

Method 29
Function 28
Class 7
Interface 1

Languages

Rust100%

Modules by API surface

examples/logo.rs13 symbols
benches/logo_bench.rs13 symbols
src/lib.rs10 symbols
examples/plot2d.rs10 symbols
tests/test2d.rs8 symbols
tests/basic.rs6 symbols
examples/plot1d.rs5 symbols

For agents

$ claude mcp add bspline \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact