Smoothing a curve: bezier curves, b-splines and Alejandro's PenTool Script

Hugh Senior h at FlexibleLearning.com
Fri Oct 2 13:15:41 EDT 2009


I am also trying to plot a curved line through coordinate points, so a
Bezier curve is not an appropriate route as it intentionally misses the
coordinate point. Similarly, with potentially big distances between points,
how 'smooth' is 'smooth'? A sharp, angular curve at each point or a more
flattened, rounded curve? And this assumes that no curve is possible at all
for the first and last points because there is no way of knowing the shape
at all.

One math guru I spoke to said it's not doable with coordinate data anyway,
only statistical data. I hope he is incorrect.

/H

David Bovill wrote...
Maybe someone can suggest a hack :) I'm thinking something along the lines
of calculating the bezier curves for each pair of points along the curve:
this is the function I have courtesy Alejandro:

function graph_BezierLine listOfPoints, zdt
>    put item 1 of  listOfPoints into x1
>    put item 2 of  listOfPoints into y1
>    put item 3 of  listOfPoints into xa
>    put item 4 of  listOfPoints into ya
>    put item 5 of  listOfPoints into xb
>    put item 6 of  listOfPoints into yb
>    put item 7 of  listOfPoints into x2
>    put item 8 of  listOfPoints into y2
>    put 0 into v1
>
>    if zdt is empty then put 32 into zdt
>    repeat with i = 1 TO zdt -- zdt is a integer number like 32
>       put i * 1/zdt into v1
>       put 1 - v1 into v2
>       put (x1 * (v2 * v2 * v2) + (3 * xa * v1 * v2 * v2) + (3 * xb * v1 *
> v1 * v2) + (x2 * (v1 ^ 3))) into x
>       put (y1 * (v2 * v2 * v2) + (3 * ya * v1 * v2 * v2) + (3 * yb * v1 *
> v1 * v2) + (y2 * (v1 ^ 3))) into y
>       if (x div 1 & "," & y div 1) <> last line of variablezxc then put (x
> div 1 & "," & y div 1) & CR after variablezxc
>    end repeat
>
>    --  if x1,y1 <> first line of variablezxc then put x1,y1 & return
before
> variablezxc
>    if x2,y2 <> last line of variablezxc then put x2,y2 & CR after
> variablezxc
>    put x1,y1 & CR before variablezxc
>    -- put x2,y2 & CR after variablezxc
>    return variablezxc
> end graph_BezierLine




More information about the use-livecode mailing list