length of bezier



I'm trying to derive the length of a generic cubic bezier curve, so
that I can write a program which calculates the length of paths
defined in SVG.

According to wikipedia the parametric bezier curve definition is as
follows:

eqx:Bx(t) = px[0]*(1-t)^3 + 3*px[1]*t*(1-t)^2+3*px[2]*t^2*(1-t)+px[3]*t^3;
eqy:By(t) = py[0]*(1-t)^3 + 3*py[1]*t*(1-t)^2+3*py[2]*t^2*(1-t)+py[3]*t^3;

I decided to see if maxima could symbolically integrate this as follows:

dlen:rhs((diff(eqx,t)^2+diff(eqy,t)^2)^(1/2));
integrate(dlen,t,0,1);

The last statement hangs up for longer than I'd expect. I might let it
crank longer but after about 10 mins on a 2 gig 1.8 ghz sempron 64 bit
it was still going....

I suspect that this integral should be doable, but might possible
result in something not particularly numerically stable. That's a
seperate issue. It would be relatively easy to write my program to do
a numerical integral by simply evaluating the bezier at 100 points
between t = 0 and t = 1 and using line segments but I'd like to see
maxima solve this problem for me, and I'm sure that most of you will
agree that it's exactly the kind of thing that we should expect maxima
to be used for in applied math.

Is there anything about the way in which I've given maxima the problem
that might cause it to be slower than necessary or be confused and
unable to perform the task? Perhaps the subscripted coefficients? 

Since it's a sqrt of a polynomial, I expect that it should have a
solution in closed form. perhaps I'm being optimistic?


-- 
Daniel Lakeland
dlakelan at street-artists.org
http://www.street-artists.org/~dlakelan