02-25-2022, 05:17 PM
(02-25-2022, 02:44 PM)Ottia Tuota Wrote:(02-25-2022, 12:30 PM)Ofnuts Wrote: Is the "C2-continuity" more constraining than having the two tangents colinear and symmetric (what you get by depressing the shift key when moving tangents)? Because experimentally this alone doesn't define a single solution.
This is not my line of expertise, but I try to answer as I understand it.
Short answer: Having the two tangents collinear and symmetric means C1-continuity. The C2-continuity is more constraining in that it brings in an additional condition on curvature.
Long answer: A stroke of a path defines a parametric curve, that is, a function f(t) from some real interval to the plane. You can think that we take the parametric representations P(t) of the individual Bezier segments (each one between two anchors), and from those P(t)'s we compose the f(t) in a certain manner. (I can expand this more in detail if you like.) Then:Since the P(t)'s are polynomials and have all derivatives continuous the only points where C1- or C2-continuity can fail are the anchors where we change from one Bezier segment to the next.
- C1-continuity means that the first derivative f'(t) is continuous everywhere.
- C2-continuity means that the first and second derivatives f'(t) and f''(t) are continuous everywhere.
So let us look at one anchor A. There two Bezier segments meet, let us call them "left segment" and "right segment". Let the left segment have control points p0,p1,p2,p3 and the right segment q0,q1,q2,q3. Then p3=q0=A.
Let P(t) and Q(t) be the functions of the two segments (the polynomials of degree 3 involving the Bernstein polynomials). We know that the derivatives at A are: P'(1) = 3*(-p2+p3) and Q'(0)=3*(-q0+q1). That is, the derivatives are equal to 3 times the handles (ignoring the directions).
C1-continuity means that P'(1) = Q'(0), or -p2+p3 = -q0+q1, which means precisely that the two handles at A are collinear and symmetric.
C2-continuity requires that in addition P''(1) = Q''(0). I mention only that P''(1) = 6*(p1-2*p2+p3) and Q''(0) = 6*(q0-2*q1+q2) and go no further. But you see that this means an extra condition involving the anchor A=p3=q0 and two more control points on both sides of A.
So, in the problem case in post #5, even C1-continuity does not hold.
Yes, C1-continuity does not define only a single solution (if I understand right you last remark). But the point in Stuart Kent's text (link in post #5) is that if we require C2-continuity and in addition that f''(t)=0 at the start and end of the stroke, then the solution exists and is unique. Kent derives a big matrix equation which gives the solution.
So, to have a proper smooth "closure", we would just require that f"(0.0 on first spline)==f"(1.0 on last spline)?
Didn't dig too much in the code of the current smooth plugin, but I would guess that it splits a stroke into several splines if there are angles that aren't smoothed, smoothes these individually, and then splice them back, throwing away the "external" handle so if there is at least one unprocessed angle in the stroke, everything is fine...