Function Repository Resource:

FullBSplineCurve

Source Notebook

Modify a BSplineCurve object to have explicit settings for certain options

Contributed by: Carl Woll

ResourceFunction["FullBSplineCurve"][spline]

generates an equivalent BSplineCurve object with explicit values given for the options SplineDegree,SplineKnots and SplineWeights.

Details and Options

ResourceFunction["FullBSplineCurve"][spline] displays the same as spline.
BSplineCurve objects with an explicit list of knots and with SplineClosedTrue are not supported.
The output always uses SplineClosedFalse.

Examples

Basic Examples (3) 

A basic BSplineCurve:

In[1]:=
pts = {{1, 0}, {1, 1}, {0, 1}, {-1, 1}};
spline = BSplineCurve[pts]
Out[2]=

An equivalent BSplineCurve where all options are made explicit:

In[3]:=
ResourceFunction["FullBSplineCurve"][spline]
Out[3]=

Show the original spline in red and the new spline in blue with partial opacity. The blended color of the curve indicates that the two splines are equivalent:

In[4]:=
Graphics[{Opacity[.5], Red, spline, Blue, ResourceFunction["FullBSplineCurve"][spline]}]
Out[4]=

Scope (3) 

Comparison of combinations of option settings for SplineClosed and SplineKnots:

In[5]:=
pts = RandomReal[1, {5, 2}];
GraphicsGrid[
 Table[Graphics[{Opacity[.5], Red, BSplineCurve[pts, SplineClosed -> c, SplineKnots -> k], Blue, ResourceFunction["FullBSplineCurve"] @ BSplineCurve[pts, SplineClosed -> c, SplineKnots -> k]}],
  {c, {True, False}}, {k, {"Clamped", Automatic, "Unclamped"}}], Frame -> All]
Out[6]=

Comparison of varying SplineDegree:

In[7]:=
pts = RandomReal[1, {10, 2}];
GraphicsRow[
 Table[Graphics[{Opacity[.5], Red, BSplineCurve[pts, SplineDegree -> d], Blue, ResourceFunction["FullBSplineCurve"] @ BSplineCurve[pts, SplineDegree -> d]}], {d, 5}], Frame -> All]
Out[8]=

Using lists of symbolic points and weights:

In[9]:=
ResourceFunction["FullBSplineCurve"] @ BSplineCurve[Array[p, 5], SplineWeights -> Array[w, 5], SplineClosed -> True]
Out[9]=

Possible Issues (1) 

With SplineClosedTrue and an explicit list for the SplineKnots option, the original BSplineCurve is returned with a message:

In[10]:=
ResourceFunction["FullBSplineCurve"] @ BSplineCurve[RandomReal[1, {5, 2}], SplineClosed -> True, SplineKnots -> {0, 0, 0, 1, 1, 2, 3, 4, 5}]
Out[10]=

Publisher

Carl Woll

Version History

  • 1.0.0 – 19 December 2019

Related Resources

Author Notes

Suggestions on how to handle SplineClosedTrue with an explicit list of knots would be appreciated.

License Information