PDA

View Full Version : Approximate Bezier Curve Length



Andrew Jameson
04-26-2003, 03:23 AM
Hi,
We're now in the final stages of product completion and need to address a couple of minor tweaks. We use bezier curves to define many of our object trajectories ... but we use linear interpolation based on the origin to destination ... and for 95% of the time the effect is fine. However for short 'as the crow flies' trajectories, there is a significant difference between the actual curve distance.

Is there a way in which we could derive an very rough approximation of the bezier path length ?

Whilst our maths isn't too bad ... we'd appreciate responses that are more practical and maybe not those from the academic world !

We use a bezier definition of StartPoint, ControlPoint1, ControlPoint2 and EndPoint - all defined as Vectors.

Many thanks

Andrew

SThomas
04-26-2003, 09:40 AM
i don't know of any "rough approximations" to the arc length of a bezier curve, but you could just use the standard integration method. go here (http://www.magic-software.com/Documentation.html) , and take a look at the pdfs titled "moving at constant speed" and "numerical integration".

Andrew Jameson
04-27-2003, 01:11 AM
Many thanks for the link ... if nothing else I've now got a lot of reading to do ... there's some really good information here.

With regard to my original problem, I came up with something that works OK for my case ...

function BezierLength : GLfloat;
// Rough approximation for the bezier path length.
var
LinearLength : GLfloat;
begin
with fBezier do begin
LinearLength := VectorLength(VectorSubtract(StartPoint, EndPoint));
Result := (VectorLength(VectorSubtract(StartPoint, ControlPoint1)) +
VectorLength(VectorSubtract(EndPoint, ControlPoint2))) / 1.5;
if (Result < LinearLength) then
Result := LinearLength;
end; {with}
end; {BezierLength}

Andrew


[This message has been edited by Andrew Jameson (edited 04-27-2003).]