From: PmI on
Hi,

does anyone know how to derive the values for the control points of a 3rd
order bezier curve that approximates a 2nd order bezier curve? I need to work
in cubic bezier curves, but have some quadratic bezier data that needs to be
best approximated, but I don't really know how to do this. The curve
functions are relatively simple,

fx(t) = x1�(t-1)� + cx�(t-1)�t + x2�(t)�
fy(t) = y1�(t-1)� + cy�(t-1)�t + y2�(t)�

for quadratic, and

fx(t) = x1�(t-1)� + 3�cx1�t�(t-1)� + 3�cx2�(t-1)�t� x2�t�
fx(t) = y1�(t-1)� + 3�cy1�t�(t-1)� + 3�cy2�(t-1)�t� y2�t�

for cubic.

For the curve approximation these functions will have the same values for
x1/y1 and x2/y2, but different values for the control points... how do I
express cx1/cy1/cx2/cy2 in terms of cx/cy (and possibly x1/y1/x2/y2)?

- PmI
From: Rob Johnson on
In article <3cednTMBYJZheG7WnZ2dnUVZ8hWdnZ2d(a)giganews.com>,
"PmI" <pmi(a)int13h.com> wrote:
>does anyone know how to derive the values for the control points of a 3rd
>order bezier curve that approximates a 2nd order bezier curve? I need to work
>in cubic bezier curves, but have some quadratic bezier data that needs to be
>best approximated, but I don't really know how to do this. The curve
>functions are relatively simple,
>
>fx(t) = x1�(t-1)^2 + cx�(t-1)�t + x2�(t)^2
>fy(t) = y1�(t-1)^2 + cy�(t-1)�t + y2�(t)^2
>
>for quadratic, and
>
>fx(t) = x1�(t-1)^3 + 3�cx1�t�(t-1)^2 + 3�cx2�(t-1)�t^2 x2�t^3
>fx(t) = y1�(t-1)^3 + 3�cy1�t�(t-1)^2 + 3�cy2�(t-1)�t^2 y2�t^3
>
>for cubic.
>
>For the curve approximation these functions will have the same values for
>x1/y1 and x2/y2, but different values for the control points... how do I
>express cx1/cy1/cx2/cy2 in terms of cx/cy (and possibly x1/y1/x2/y2)?

Note that

(1-t)^2 x1 + 2 (1-t) t cx + t^2 c2

= ((1-t)^3 + (1-t)^2 t) x1

+ 2 ((1-t)^2 t + (1-t) t^2) cx

+ ((1-t) t^2 + t^3) x2

= (1-t)^3 x1

+ 3 (1-t)^2 t (1/3 x1 + 2/3 cx)

+ 3 (1-t) t^2 (2/3 cx + 1/3 x2)

+ t^3 x2

= (1-t)^3 x1 + 3 (1-t)^2 t cx1 + 3 (1-t) t^2 cx2 + t^3 x2

If we set cx1 = (x1 + 2cx)/3 and cx2 = (x2 + 2cx)/3.

Similar for y.

Rob Johnson <rob(a)trash.whim.org>
take out the trash before replying
to view any ASCII art, display article in a monospaced font