Hi all, anyone know how to compute the length of a 2d and 3d bezier curve? Need help quick fanx.
Bezier Curve Help
Blitz3D Forums/Blitz3D Programming/Bezier Curve Help Well, if you want an exact answer you'll probably need calculus to find the right equation. :|
But if you just do this you should get a good approx:
Note that its untested, as I wrote it in firefox....
But if you just do this you should get a good approx:
Function BezierLength(x1#,y1#,z1# ,x2#,y2#,z2# ,x3#,y3#,z3# ,x4#,y4#,z4#) px#=x1 py#=y1 pz#=z1 For t#=0 to 1 step .01 x#=Bezier#(t,x1,x2,x3,x4) y#=Bezier#(t,y1,y2,y3,y4) z#=Bezier#(t,z1,z2,z3,z4) td#=td#+Sqr((x-px)*(x-px)+(y-py)*(y-py)+(z-pz)*(z-pz)) px=x py=y pz=z Next Return td# End Function Function Bezier#(t#,x1#,x2#,x3#,x4#) Return x1*(1-t)^3 + 3*v2*(1-t)^2*t + 3*vx3*(1-t)*t^2 + x4*t^3 End Function
Note that its untested, as I wrote it in firefox....
I've got some good news. The equation is simply:
Maple refuses to integrate it though, and I don't think I'll be able to integrate it by hand...
Int((9*x1^2+18*x2*x4*t^2+36*x2*x3*t-18*x1*x4*t^2-36*x1*x3*t+126*x1*x3*t^2-216*x1*x2*t^2+36*x3*t^3*x4-54*x3*t^4*x4+54*x2*t^4*x4-162*x2*t^4*x3-72*x2*t^3*x4-198*x2*t^2*x3+324*x2*t^3*x3-18*x1*t^4*x4+54*x1*t^4*x3-54*x1*t^4*x2+36*x1*t^3*x4-144*x1*t^3*x3+180*x1*t^3*x2+18*y2*y4*t^2+36*y2*y3*t-18*y1*y4*t^2-36*y1*y3*t+126*y1*y3*t^2-216*y1*y2*t^2+108*y1*y2*t+36*y3*t^3*y4-54*y3*t^4*y4+54*y2*t^4*y4-162*y2*t^4*y3-72*y2*t^3*y4-198*y2*t^2*y3+324*y2*t^3*y3-18*y1*t^4*y4+54*y1*t^4*y3-54*y1*t^4*y2+36*y1*t^3*y4-144*y1*t^3*y3+180*y1*t^3*y2+9*y4^2*t^4+36*y3^2*t^2+81*y3^2*t^4-108*y3^2*t^3+9*y2^2+81*y2^2*t^4-72*y2^2*t+198*y2^2*t^2-216*y2^2*t^3+9*y1^2*t^4-36*y1^2*t^3-18*y1*y2+54*y1^2*t^2-36*y1^2*t+9*x4^2*t^4+36*x3^2*t^2-108*x3^2*t^3+81*x3^2*t^4+9*x2^2+81*x2^2*t^4+108*x1*x2*t+9*y1^2+dzt^2-18*x1*x2+54*x1^2*t^2-36*x1^2*t-36*x1^2*t^3+198*x2^2*t^2+9*x1^2*t^4-72*x2^2*t-216*x2^2*t^3)^(1/2),t = 0 .. 1)
Maple refuses to integrate it though, and I don't think I'll be able to integrate it by hand...
Jeez guys, thanks for your replies. Sorry I have'nt responded sooner as I've been working the old night shifts. I'll try both your equations. Thanks again. ;-)
The equation is simply:
LOL