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.”
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.”
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]
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]}}]