← All projects

Python-B-spline-examples

by @kawache

113

Examples in Python about plotting and interpolating a B-spline curve and their comparison using Numpy, Scipy and Matplotlib.

About this project

Python-B-spline-examples Examples in Python about evaluating and interpolating a B-spline curve and their comparaison using Numpy, Scipy and Matplotlib. Requirements Python 2.7.x or 3.x.x, Numpy Scipy Matplotlib Getting hands dirty Assuming you already know a little about B-spline curves, otherwise google it or check this out. Let consider a 9 points list named plist : We will do two things : A. Drawing a cubic B-Spline curve where plist is the control polygon. B. Find(interpolate) and draw the B-spline curve that go trough plist points and or in other words a curve fitting using a cubic B-spline curve. As we will work with Numpy , let's create a numpy array named ctr from plist ,and then split it into x and y arrays. A. Drawing the B-spline Curve We will draw a cubic B-spline which degree k=3 as it's the most used one. We need now to define the knots vector, with k ending equal knots: Now we have defined all requirement to draw it. we can construct a sequence of length 3 containing the knots, coefficients, and degree of the spline to pass it as the tck argument to scipy.interpolate.splev , the function that will evaluate our curve:

From the project README on GitHub

Stars
113
Forks
25
License
MIT
Last push
13 Jan 2024

Add this badge to your README

Show that your project is listed on Made in Algeria.

Made in Algeria
[![Made in Algeria](https://www.madeinalgeria.dev/badge/python-b-spline-examples.svg)](https://www.madeinalgeria.dev/projects/python-b-spline-examples)

Related projects