4 ms·
This is very fun and well done, great interactive illustrations, and I love the deep dive into curvature. I have to wonder - if you want smooth joins, why not
by dahart 1mo ago
This is very fun and well done, great interactive illustrations, and I love the deep dive into curvature.
I have to wonder - if you want smooth joins, why not use uniform B-splines instead of Bézier curves? With B-splines you don’t have to set constraints or compute curvature, it’s built in. What are the reasons to prefer Bézier?
There’s an old 1985 tech report by Tony DeRose (formerly of Pixar Research) that categorized the different ways to smoothly join curves - "Geometric Continuity: A Parametrization Independent Measure of Continuity for Computer Aided Geometric Design.”
That paper has a simple constraint formula for matching curvature between cubic Béziers, one that has a couple degrees of freedom. It’s the “G2 (curvature continuity)” formula mentioned on Wikipedia here: https://en.wikipedia.org/wiki/Composite_B%C3%A9zier_curve#Smoothly_joining_cubic_B%C3%A9ziers https://en.wikipedia.org/wiki/Composite_B%C3%A9zier_curve#Sm.... It’d be interesting to know whether that somehow works out to be mathematically equivalent to this post’s technique or not.
- unconed 1mo agoAs the post says, beziers are everywhere so we are stuck with them. It's worth trying to improve them for that reason alone. Additionally B-splines (like Catmull-Rom) have the issue that moving one point affects a larger area of the spline than an equivalent bezier. The local control of beziers makes them more desirable for precise illustration. As for the formula you cited, it tells you where to put the control point for continuity in function of two scalars, but those scalars don't directly map to intuitive controls. It also doesn't help when moving a curve point while preserving curvature on both sides because it only tells you one side in function of the other. I.e. continuity of curvature is a weaker constraint than having the desired curvature. I initially experimented with something similar but found that numerical drift would steadily accumulate during interactive editing. The post shows this with the last example before curvature handles: rotating the tangents there preserves curvature continuity but the curve tends to blow up for certain angles, because the tangent is a poor proxy for indicating desired curvature.
- dahart 1mo agoOh Béziers are great and not going anywhere, and I’m not suggesting they should. It’s all about your specific goals. I think B-splines are misunderstood and underutilized, and your comment might be exemplifying that a little. ;) For one, Catmull-Rom is not a B-spline. For two, it’s easy to achieve local control of a B-spline wherever it’s needed (there are two separate ways to do this). For three, and most importantly - note that the goal of the article is to get a smooth join, and the technique in the article is to drop localized control (!) by imposing constraints on both sides of a join point. Using a Bézier for this is more complicated than using a B-spline, for no additional benefit that I can see. Also worth mentioning that uniform B-splines and Béziers are mathematically shape equivalent - it’s trivial to convert between them, so they provide identical levels of control, they’re just slightly different interfaces for the same shape. Minor edit here to note, it just occurred to me that the curvature constraint affects the curve over a span of 7 control points, whereas editing a B-spline control point affects the curve over a span of 4 control points. B-splines are strictly more localized than Curvature Béziers… One reason B-splines aren’t well known & used is because seemingly most/all online content launches into the math and discussion of knots. The uniform B-spline doesn’t need knots, and I wish more tutorials would start there rather than intimidating people with the math. BTW yes you’re right about the ‘scalars’ (the beta parameters) in the G2 curvature matching equation. I haven’t tried this and I don’t know what they do. I was wondering if these might have a relationship to the ‘heuristic’ the Acko article derives? That was kind of my question.
- unconed 1mo agoI wrote the article :). To clarify, I meant B-splines _lack local control_ like Catmull-Rom splines, not that the latter is an instance of the former. Though indeed, all cubic splines are just cubic polynomials. I disagree with your characterization that the proposed solution lacks local control, because edits only affect the segments in question, just like with a classic bezier. From the point of view of curvature handles, the handles you don't touch don't change. (The splitting of a curvature bezier is imo the best illustration of this.) Re: the meaning of the scalars, I imagine they are derived similarly as the perpendicular-distance diagram in the post. If you plug bezier formulas into curvature formulas, a lot of terms cancel out.