README-work

Math::Splines

Raku package for splines (piecewise polynomials), like, Bezier splines or B-splines.

Installation

From Zef ecosystem:

zef install Math::Splines

From GitHub:

zef install https://github.com/antononcube/Raku-Math-Splines.git

Usage examples

The subsections below show example usage for the currently implemented functions.

B-spline basis

use Math::Splines;
use Text::Plot;

Using positional arguments:

b-spline-basis(3, 0, 0.5)

Using named arguments:

my $degree = 3; 
my @knots = b-spline-knots(:$degree, n => 6);
b-spline-basis(:$degree, :@knots, :1index, argument => 0.5)

Plot the basis of degree 3:

my $m = @knots.elems - $degree - 2;
my @points = (0..$m).map( -> $k { (0, 0.01 ... 1).map({ [$_, b-spline-basis(:$degree, :@knots, index => $k, argument => $_)] }) })ยป.Array;
text-list-plot(@points, width => 80, height => 20, title => 'B-spline basis')

Functions instead of values

If the argument :arg(:argument(:$x)) of b-spline-basis is Whatever, then a function is returned:

my &bf = b-spline-basis(:3degree, :0index, arg => Whatever);

&bf(0.25)

Alternatively, the subs b-spline-basis-value and b-spline-basis-function can be used to get values and functions respectively.

Bernstein basis

my @points = (^4).map( -> $k { (0, 0.01 ... 1).map({ [$_, bernstein-basis(3, $k, $_)] }) })ยป.Array;
text-list-plot(@points, width => 80, height => 20, title => 'Bernstein basis')

TODO

  • TODO Implementation

    • TODO Bezier curve

  • TODO Documentation

References

[AAp1] Anton Antonov, Math::Fitting Raku package, (2024), GitHub/antononcube.

[AAp2] Anton Antonov, Math::Polynomial::Chebyshev Raku package, (2024), GitHub/antononcube.

Math::Splines v0.0.1

Raku package for splines (piecewise polynomials), like, Bezier splines or B-splines.

Authors

  • Anton Antonov

License

Artistic-2.0

Dependencies

Test Dependencies

Provides

  • Math::Splines

The Camelia image is copyright 2009 by Larry Wall. "Raku" is trademark of the Yet Another Society. All rights reserved.