POV-Ray : Newsgroups : povray.advanced-users : Length of spline... Server Time
30 Jul 2024 10:18:26 EDT (-0400)
  Length of spline... (Message 1 to 10 of 13)  
Goto Latest 10 Messages Next 3 Messages >>>
From: Tony[B]
Subject: Length of spline...
Date: 22 Oct 2000 21:51:50
Message: <39f399b6@news.povray.org>
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.


Post a reply to this message

From: Margus Ramst
Subject: Re: Length of spline...
Date: 22 Oct 2000 23:08:14
Message: <39F39D85.286CC421@peak.edu.ee>
"Tony[B]" 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.

You could try using Chris Colefax's spline macros instead, I believe they are
capable of finding the (approximate) length of a cubic spline.
Finding the exact length is an exceedingly hairy problem, or so I gather.

-- 
Margus Ramst

Personal e-mail: mar### [at] peakeduee
TAG (Team Assistance Group) e-mail: mar### [at] tagpovrayorg


Post a reply to this message

From: Chris Colefax
Subject: Re: Length of spline...
Date: 22 Oct 2000 23:26:29
Message: <39f3afe5@news.povray.org>
Tony[B] <ben### [at] panamac-comnet> 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

From: Tony[B]
Subject: Re: Length of spline...
Date: 23 Oct 2000 21:37:56
Message: <39f4e7f4@news.povray.org>
OK. Thank you both very much. I will try this code later tonight. I want to
figure the length so I can get my car chase animation working within the
realm of reality. I want to make the car go at specific speeds along the
path. If I don't know how long the path is, I won't know which speed is
appropriate. I think... anyway, thanks.


Post a reply to this message

From: Fabian BRAU
Subject: Re: Length of spline...
Date: 25 Oct 2000 03:33:55
Message: <39F68CC8.FA39C490@umh.ac.be>
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] panamac-comnet> 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

From: Chris Colefax
Subject: Re: Length of spline...
Date: 25 Oct 2000 04:56:32
Message: <39f6a040@news.povray.org>
I wrote:
> 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)...

Fabian BRAU <Fab### [at] umhacbe> wrote:
> 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.

Yes, it seems obvious that you could integrate the spline function to find
the exact length.  But like I said, there is simply no known way *to*
integrate the function.  To create my Spline Macro File I searched and
re-searched the web for the right formulas, and also started from first
principals to derive the functions myself, before attempting (without
success) the necessary integration in MathCAD.  I guess it shows that there
are limits to our knowledge of mathematics....


Post a reply to this message

From: Jan Walzer
Subject: Re: Length of spline...
Date: 25 Oct 2000 16:07:23
Message: <39f73d7b$1@news.povray.org>
Isn't it a propertie of a cubic-Spline, to be 3-Times
differentiable and also (at every-Point) integratable ???
An Cubic Spline consists of several cubic-functions (every going
through 4 Points) and having at every Point the same
2nd-derivations ....
So there MUST be a way to integrate them ...
or am I completely wrong ???

I just though to have heard this last semester in the
"aproximation-theorie"-lecture ...

I just fear you can not use the pov-Spline to do this for you,
but you have to calculate the Spline yourself, with all its
matrices and so on ...

You know what I mean ???

Chris Colefax <chr### [at] tagpovrayorg> schrieb in im
Newsbeitrag: 39f6a040@news.povray.org...
> I wrote:
> > 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)...
>
> Fabian BRAU <Fab### [at] umhacbe> wrote:
> > 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.
>
> Yes, it seems obvious that you could integrate the spline
function to find
> the exact length.  But like I said, there is simply no known
way *to*
> integrate the function.  To create my Spline Macro File I
searched and
> re-searched the web for the right formulas, and also started
from first
> principals to derive the functions myself, before attempting
(without
> success) the necessary integration in MathCAD.  I guess it
shows that there
> are limits to our knowledge of mathematics....
>
>


Post a reply to this message

From: Andrew Clinton
Subject: Re: Length of spline...
Date: 25 Oct 2000 19:35:09
Message: <39F797F6.B9B4C593@ibm.net>
Exact length of a cubic f(x) = a*x^3 + b*x^2 + c*x + d:
http://www.eng.uwaterloo.ca/~ajclinto/test.html

assuming you have x=0 and x=1 as the bounds of the segment (and maybe a=1) it
would become SLIGHTly simpler, but I still doubt whether there would be any
practical use for this mess.

Andrew C


"Tony[B]" 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.


Post a reply to this message

From: Michael Andrews
Subject: Re: Length of spline...
Date: 26 Oct 2000 08:13:37
Message: <39F82026.9B461477@reading.ac.uk>
Hi Andrew,

This is the length of a simple parametric spline where a, b, c and d are
scalars, yes?

The problem is that it would usually be used to produce a spline in 3d,
so a, b, c and d would be 3-component vectors. This would probably add a
whole new level of complexity, something like

f_x := a_x * t^3 + b_x * t^2 + c_x * t + d_x ;
f_y := a_y * t^3 + ... ;
f_z := ... ;

int(sqrt(diff(f_x,t)^2 + diff(f_y,t)^2 + diff(f_z,t)^2),t) ;

Try feeding that to Maple and see if it chokes :-)

Bye for now,
	Mike Andrews.

Andrew Clinton wrote:
> 
> Exact length of a cubic f(x) = a*x^3 + b*x^2 + c*x + d:
> http://www.eng.uwaterloo.ca/~ajclinto/test.html
> 
> assuming you have x=0 and x=1 as the bounds of the segment (and maybe a=1) it
> would become SLIGHTly simpler, but I still doubt whether there would be any
> practical use for this mess.
> 
> Andrew C
> 
> "Tony[B]" 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.


Post a reply to this message

From: Andrew Clinton
Subject: Re: Length of spline...
Date: 26 Oct 2000 15:43:25
Message: <39F8B320.D72FBFBB@ibm.net>
Michael,

Ahh, I was thinking of this, but thought that maybe one could take the magnitude of
the vector returned by that (terribly ugly) formula to get the distance traveled.  I
understand how this is done with vectors now (there is a good page at
http://iq.orst.edu/mathsg/vcalc/arc/arc.html)

Thanks for clarifying
Andrew C


Michael Andrews wrote:

> Hi Andrew,
>
> This is the length of a simple parametric spline where a, b, c and d are
> scalars, yes?
>
> The problem is that it would usually be used to produce a spline in 3d,
> so a, b, c and d would be 3-component vectors. This would probably add a
> whole new level of complexity, something like
>
> f_x := a_x * t^3 + b_x * t^2 + c_x * t + d_x ;
> f_y := a_y * t^3 + ... ;
> f_z := ... ;
>
> int(sqrt(diff(f_x,t)^2 + diff(f_y,t)^2 + diff(f_z,t)^2),t) ;
>
> Try feeding that to Maple and see if it chokes :-)
>
> Bye for now,
>         Mike Andrews.
>
> Andrew Clinton wrote:
> >
> > Exact length of a cubic f(x) = a*x^3 + b*x^2 + c*x + d:
> > http://www.eng.uwaterloo.ca/~ajclinto/test.html
> >
> > assuming you have x=0 and x=1 as the bounds of the segment (and maybe a=1) it
> > would become SLIGHTly simpler, but I still doubt whether there would be any
> > practical use for this mess.
> >
> > Andrew C
> >
> > "Tony[B]" 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.


Post a reply to this message

Goto Latest 10 Messages Next 3 Messages >>>

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.