Message Boards Message Boards

1
|
3775 Views
|
2 Replies
|
3 Total Likes
View groups...
Share
Share this post:

How do I get filled closed B-splines with discrete weights?

Posted 2 years ago

Plots of filled bsplines with discrete weights doesn't work... It returns this error:

"SplineWeights specification {1, 1, 1, 1} should be Automatic, or a list of positive numbers with the same length as control points."

POSTED BY: Claudio Argento
2 Replies
Posted 1 year ago

A similar approach I take involves letting ParametricPlot[] do its adaptive sampling capabilities, instead of having to guess the stepsize needed for sampling the BSplineFunction[]. Then, it's a simple matter of extracting the points generated using Cases[]:

poly = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
weights = {7.8, 9.1, 4.8, 7.8};
fp = Cases[Normal @ ParametricPlot[BSplineFunction[poly, SplineClosed -> True,
                                                   SplineDegree -> 3,
                                                   SplineWeights -> weights][t] //
                                   Evaluate, {t, 0, 1}],
           Line[l_] :> Polygon[l], Infinity];

Graphics[{{ColorData[97, 2], fp},
          {Directive[AbsoluteThickness[3], ColorData[97, 1]], 
           BSplineCurve[poly, SplineClosed -> True, SplineDegree -> 3,
                        SplineWeights -> weights]}}]
POSTED BY: J. M.

A simple approach: 1) Use BSplineFunction, 2) calculate a series of points along the BSpline, 3) call these points a Polygon.

poly = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
weights = {7.8, 9.1, 4.8, 7.8};

bSplineFunction = 
BSplineFunction[poly, SplineClosed -> True, SplineDegree -> 3, 
SplineWeights -> weights];
bsPolygonPts = Table[bSplineFunction[i], {i, 0, 1, .01}];

bSplinePts = Graphics[Point[bsPolygonPts]];

ply = Graphics[{Opacity[.1], Polygon[poly]}];

bSplineCurve = 
Graphics[{Red, 
BSplineCurve[poly, SplineClosed -> True, SplineDegree -> 3, 
SplineWeights -> weights]}];

bSplinePolygon = Graphics[{Red, Polygon[bsPolygonPts]}];

Show[ply, bSplineCurve, bSplinePts]
Show[ply, bSplinePolygon]
POSTED BY: Neil Chiavaroli
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract