On Tue, 26 Oct 1999, James Henstridge wrote:

> I suppose so.  The other option would be to use the other formula for
> drawing a bezier curve.  It looks something like:
> 
>           3
>          ___
>   x(t) = \   ( 3 ) * x  * t^i * (1-t)^(3-i)
>          /   ( i )    i
>          ---
>          i=0
> 
>           3 
>          ___
>   y(t) = \   ( 3 ) * y  * t^i * (1-t)^(3-i)
>          /   ( i )    i
>          --- 
>          i=0
> 
> (t runs from 0 to 1)
> 
> Where the first coefficient is the binomial coefficient (ie. 1 for i = 0
> or 3, 3 for i = 1 or 2).  This way you could decide on a fixed number of
> points (say 10 or 20), and calculate them.  By precomputing the powers of
> the various values of t, to calculate each point you would only need 24
> multiplications and 6 additions.  Also, the process is constant time
> rather than a recursive algorithm.  This is potentially not as high a
> quality, but may be sufficient for on screen display.
> 
> Another place to look is the algorithms used in libart from gnome-libs (in
> the art_vpath_bpath.c file).  It looks like it uses a similar approach to
> dia's renderer, except that it looks at `smoothness' to decide when to
> break out of the recursion rather than spacing of the points.

 Dia doesn't look at the point spacing. Consider this bezier-curve:

   P1        P2
    *      *
 u /|x      \
  / |        \
 *------------*
P0 y     v     P3


P0-P3 are the bezier points. 
u = P1-P0
v = P3-P0

y = u projected on v
x = u-y;

Then the value of |x| decides if the curve is "smooth" enough to draw as a
line. Then the same is checked on the other |x| (P3-P2 projected on
P0-P3).

/ Alex 

Reply via email to