Daniel Sapoundjiev on
  Converting BSpline to Cublic Bezier curves

Converting BSpline to Cublic Bezier curves

Is it possible

Yes. It is possible for every Uniform Cubic B-Spline Curve to be converted to Curbic Bezier Curves.

Uniform Cubic B-Spline equation

B(u) = P0(1-u)^3/6 + P1*(3u^3 - 6u^2 + 4)/6 + (-3u^3 + 3u^2 + 3u + 1)/6 + u^3/6

Cubic Bezier Curve equation

B(t) = (1-t)^3*P0 + 3*(1-t)^2*t*P1 + 3*(1-t)*t^P2 + t^3*P3

Conversion code

function TBSpline.getBezierPoint2(aIndex: Integer; out CtrlPt2: TPoint2D): TPoint2D;
var
p1, p2: TPoint2D;
a1, a2, x, y: Double;
begin
p1 := getValueForSegment2(aIndex, 0.6);
p2 := getValueForSegment2(aIndex, 0.4);

a1 := (125 * p1.X - 8 * px[aIndex] - 27 * px[aIndex+1]) / 90;
a2 := (125 * p2.X - 27 * px[aIndex] - 8 * px[aIndex+1]) / 30;

x := a2 - 2 * a1;
CtrlPt2.X := 5 / 3 * a1 - 2 / 3 * x;

a1 := (125 * p1.Y - 8 * py[aIndex] - 27 * py[aIndex+1]) / 90;
a2 := (125 * p2.Y - 27 * py[aIndex] - 8 * py[aIndex+1]) / 30;

y := a2 - 2 * a1;
CtrlPt2.Y := 5/3 * a1 - 2/3 * y;

Result.X := x;
Result.Y := y;
end;

Conversion

to be continued

Back to main menu