Mathematica Asked by Lyle Ramshaw on December 18, 2020
Mathematica seems to render rational Bézier curves (drawn with BSplineCurve
) using polylines whose segments can be annoyingly long, while polynomial Bézier curves (drawn with BezierCurve
) behave better. Consider, for example,
Graphics[{Blue,
BezierCurve[{{-0.05, 0}, {0, 0.02}, {0.05, 0}},
SplineDegree -> 2],
Red,
BSplineCurve[{{-0.05, 0.05}, {0, 0.07}, {0.05, 0.05}},
SplineDegree -> 2, SplineWeights -> {1, 1, 1}]},
PlotRange -> {{-1, 1}, {-0.1, 0.2}}, AspectRatio->Automatic]
Those two quadratic Bezier curves should differ only by a small vertical translation. When I execute that code (in version 11.3), however, the default image looks like this:
with the upper, red curve rendered as a straight line. If I stretch the image a bit, the red curve becomes a two-segment polyline:
Stretching the image further causes the red curve to acquire three segments, and so forth.
How can I control the accuracy with which BSplineCurve
‘s are converted into polylines? The straight segments in my current images, while they are fairly short, still generate corners that are sharp enough to be obvious bugs.
(with thanks to Mr. Wizard.)
There is an undocumented option you can use to control the rendering of B-splines:
Graphics[{Blue, BezierCurve[{{-0.05, 0}, {0, 0.02}, {0.05, 0}}, SplineDegree -> 2],
Red, BSplineCurve[{{-0.05, 0.05}, {0, 0.07}, {0.05, 0.05}},
SplineDegree -> 2, SplineWeights -> {1, 1, 1}]},
BaseStyle -> {BSplineCurveBoxOptions -> {Method -> {"SplinePoints" -> 30}}},
PlotRange -> {{-1, 1}, {-0.1, 0.2}}]
Increase or decrease the "SplinePoints"
setting as seen fit.
Correct answer by J. M.'s discontentment on December 18, 2020
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP