|
![](/i/fill.gif) |
If you know the exact form of the function (the spline) you
can calculate the length of the spline, this involve a simple integrale.
Actually this is what you do approximately by using straight line
between point.
>
> Tony[B] <ben### [at] panama c-com net> wrote:
> > How can I get an exact/closely approximated measure of the distance
> traveled
> > along a spline and the total length of it? I am using a cubic_spline in
> > MegaPOV.
>
> Due to the maths involved, there is no known way to calculate the exact
> length of a cubic spline. The best method is usually to sum the linear
> distances between a number of steps along the spline - obviously, the more
> steps, the more accurate the result (at the cost of speed). In MegaPOV you
> should be able to do this quite simply using a while loop (the following
> presumes your spline clock ranges from 0 to 1):
>
> #declare MySpline = spline {cubic_spline ..... }
> #declare Length = 0;
>
> #declare C = 0; #while (C <= 100)
> #declare P1 = MySpline(C/100);
> #if (C > 0) #declare Length = Length + vlength(P1 - P0); #end
> #declare P0 = P1;
> #declare C = C + 1; #end
>
> Also, a very rough approximation can be calculated if know the bezier hull
> points of the spline. My own Spline Macro file uses a combination of both
> methods, so you can return the total length of a spline, return a point at a
> specified distance along a spline, or even specify a list of points and a
> length, and have the macro tension the spline through the points to fit the
> desired length.
Post a reply to this message
|
![](/i/fill.gif) |