Path: chuka.playstation.co.uk!tjs From: tjs@cs.monash.edu.au (Toby Sargeant) Newsgroups: scee.yaroze.programming.3d_graphics Subject: Re: Bezier question Date: 12 Apr 1999 11:29:36 GMT Organization: PlayStation Net Yaroze (SCEE) Lines: 69 Message-ID: References: <3711AF0B.16E1@mdx.ac.uk> NNTP-Posting-Host: longford.cs.monash.edu.au X-Newsreader: slrn (0.9.4.3 UNIX) On Mon, 12 Apr 1999 09:30:03 +0100, Harvey Cotton wrote: >Hi. > >I was wondering if anyone knows how to calculate the length of a >Bezier curve? It's essential for the project I'm working on. > >Thanks in advance, >Harvey > Sorry about the ugliness of the response... In the generic case, the solution requires numeric methods: In the 2 dimensional case (the extension to 3 dimensions is reasonably trivial): x(t) = a_x.t^3 + b_x.t^2 + c_x.t + d_x y(t) = a_y.t^3 + b_y.t^2 + c_y.t + d_y where: d_x = x_0 c_x = 3 (x1 - x0) b_x = 3 (x2 - x1) - c_x a_x = x3 - x0 - c_x - b_x d_y = y_0 c_y = 3 (y1 - y0) b_y = 3 (y2 - y1) - c_y a_y = y3 - y0 - c_y - b_y where (x_0,y_0),(x_1,y_1),(x_2,y_2),(x_3,y_3) are the control points. then, the line integral from 0 to 1 of (1) = sqrt(x'(t)^2+y'(t)^2) wrt t is the length of of the curve. (1) can be rewritten as sqrt(at^4 + bt^3 + ct^2 + dt + e) where (assuming I expanded things correctly): a=9a_x^2 + 9a_y^2 b=12a_x.b_x + 12a_y.b_y c=6a_x.c_x + 4b_x^2 + 6a_y.c_y + 4b_x^2 d=4b_x.c_x + 4b_y.c_y e=c_x^2 + c_y^2 which only has a neat solution if: a=u^2 b=0 c=2.u.v d=0 e=v^2 (i.e. the polynomial can be factored to the form (u.t^2+v)^2 ) The only way I know how to handle something that isn't in that form is through numerical integration. Alternatively, there are other classes of curve that have nice properties with respect to velocity (i.e., velocity is constant throughout the curve). In this case, the length is simply computed as velocity * time. Toby.