Bezier-Cubic-Spline-Curve

Author:
hawe

Splines aus Bezier-Kurven

Splines, durch kubische Bezier-Segmente stückweise zusammengesetzt. Jedem Stützpunkt füge ich 2 Kontrollpunkte hinzu. Den Verlauf eines Segments steuert der Parameter Tension (Spannung), er gibt an wie stark abgerundet die Spline-Kurve an den Stützpukten ist. Tension = 0 die Kurve an den Stützstellen ist nicht gerundet, bildet Ecken. Der Spline degradiert zu einem gewöhnlichen Polygonzug. Tension gibt an, wie weit die Kontrollpunkte auf dieser Linie vom Stützpunkt entfernt sind. Je grösser der Tensionswert, umso weiter entfernt sind die Kontrollpunkte vom Stützpunkt und umso mehr schmiegt sich die Kurve an diesem Stützpunkt an. Ein Wert von 0,5 ergibt eine ausgeglichene Kurve. Ein negativer Wert für Tension bewirkt, dass die Kontrollpunkte auf der Linie vertauscht sind. Dadurch macht die Kurve am Stützpunkt eine Schleife. Der Slider k markiert eine Stützstelle und aktiviert deren Kontrollpunkte. Splines, composed piecewise by cubic Bezier segments. The path of the segments is controlled by the Tension parameter, which determines how rounded the spline curve is at the nodes. Tension = 0 the curve at the nodes is not rounded, it forms corners. The spline degrades to an ordinary polygonal curve. Tension indicates how far the control points on this line are from the nodes. The larger the Tension value, the further away the control point are from the nodes and the more the curve hugs this node. A value of 0.5 results in a balanced curve. A negative value for Tension causes the control points on the line to be reversed. This causes the curve to make a loop at the node. Translated with www.DeepL.com/Translator. Basiert auf Walter Bislin's Blog-De Alles über Bezierkurven (pomax): A Primer on Bezier Curves

ComputeSplineCurve.js Bezier-Segments

Bezier-Spline (Bernstein-Polynom - de Casteljau-Function)

Bernsteinpolynom-user-function Quartic curve (a fourth degree Bézier curve) B_x(t):=Sum(B_{poly}(4)* ({A, B, C, D, E} (1,0))) B_y(t):=Sum(B_{poly}(4)* ({A, B, C, D, E} (0,1))) Command-Version TFig=0.5 (Tension) Input-Point-List Fig={(-6, 4), (-9, 3), (-8, 6), (-1, 6), (6, 6), (6, 4), (2, 4), (2, -7), (4, -7), (0, -10), (-0.5, 4), (-4, 4), (-4, -8), (-6, -10)} Point list Closed-Spline XY=Flatten({Fig(Length(Fig)), Fig, Fig(1), Fig(1)}) Control-Points C_a=Sequence(XY(j+1) - (XY(j+2) - XY(j)) TFig sqrt((XY(j) - XY(j+1))²) / (sqrt((XY(j) - XY(j+1))²) + sqrt((XY(j+2) - XY(j+1))²)), j, 2, Length(XY)-2) C_b=Sequence(XY(j+1) + (XY(j+2) - XY(j)) TFig sqrt((XY(j+2) - XY(j+1))²) / (sqrt((XY(j) - XY(j+1))²) + sqrt((XY(j+2) - XY(j+1))²)), j, 1, Length(XY)-2) Bezier-Spline-List BezierSplineCurve=Sequence(Curve((1-t)³ XY(j) + 3t (1-t)² C_b(j-1) + 3t² (1-t) C_a(j-1) + t³ XY(j+1), t, 0, 1), j, 2, Length(XY) - 2) Manipulate control points Static copy of C_a->CA, C_b->CB, Exchange BezierSplineCurve C_a->CA, C_b->CB) (Update-Script Fig: Execute({"CA="+C_a,"CB="+C_b})) Slider k (Update-Script Execute({"Ca="+CA(If(k == 1, Length(C_a), k - 1)),"Cb="+CB(k),"D0="+XY(k+1)})) Ca (Update-Script: SetValue(CA,Mod(k - 2, Length(CA)) + 1,Ca)) Cb (Update-Script: SetValue(CB,k,Cb)) Bug: Es kommt immer wieder vor, daß die Bezier-Spline-List-Variable bei Änderungen/Anpassungen verschwindet - kein Undo, Neustart --- Flächen-Fill, Flächenmaß cubicSpline -> xyAreaSpline -> poly2 (Polygon)