POV-Ray : Newsgroups : povray.newusers : Controlling Speed along a spline Server Time
2 Nov 2024 05:21:01 EDT (-0400)
  Controlling Speed along a spline (Message 1 to 5 of 5)  
From: Bathurstfreak
Subject: Controlling Speed along a spline
Date: 4 Oct 2004 23:40:01
Message: <web.416216ce678da1004ba5e2fd0@news.povray.org>
I'm a first time POVRay user, working on my first animation, but I need to
control the speed of a vehicle along a spline. What determines how far the
car travels between each frame? Is it based on the distance between each
point on the spline? Can I get linear deceleration around a corner for
example? I realise these are based on chosen framerate and other such
things.


Post a reply to this message

From: Jim Charter
Subject: Re: Controlling Speed along a spline
Date: 5 Oct 2004 18:44:50
Message: <416323e2$1@news.povray.org>
Bathurstfreak wrote:

> I'm a first time POVRay user, working on my first animation, but I need to
> control the speed of a vehicle along a spline. What determines how far the
> car travels between each frame? Is it based on the distance between each
> point on the spline? Can I get linear deceleration around a corner for
> example? I realise these are based on chosen framerate and other such
> things.
> 
> 
Well I am not the best one to be answering this since I don't do 
animation but here is what I know:

there is a sample file showing animation along a spline called 
followspline.pov in the src directory

splines are usually accessed My_Spline ( Value )
where Value is 0 < Value < 1
so that 0 represents one end of the spline and 1 the other
you more the camera along from frame to frame by using the clock value
there

When you access the spline in this way you might expect that
My_Spline ( 0/5 )
My_Spline ( 1/5 )
My_Spline ( 2/5 )
...
My_Spline ( 5/5 )

would return points on the spline at equal distances between each other
but it does not necessarily do that

The only way I have found to ensure that it does is by defining the 
spline in a careful way

the syntax for defining the spline is
#local My_Spline =
spline {
Value0, Pt0
Value1, Pt1
Value2, Pt2
...
ValueN, PtN
}
where again Value* is 0 < Value* < 1
the trick is to make Value0 Value1 Value2 ...
reflect the same proportion to the whole that
the length to corresponding points makes to the whole
length of the spline being defined

I do it like this:
Given the points used to define the spline in an array called Points
#declare Points = array [10] {
P0,P1,P2,...P9 };

#macro DefineSpline ()
         #local TLen=0;
         #local i=1;#while(i<dimension_size(Points,1))
                 #local TLen = TLen + vlength ( Points[i] - 
Points[i-1] 					);
         #local i=i+1;#end


         spline { natural_spline
                #local Len=0;
                Len/TLen, Points[0]
                #local i=1;#while(i<dimension_size(Points,1))
                        #local Len = Len + vlength ( 
Points[i] - 								Points[i-1] );
                        Len/TLen, Points[i]
                #local i=i+1;#end
         }

#end


//then
#local CameraSpline = DefineSpline ()

;now if I do
#local i=0;#while(i<10)
	sphere { CameraSpline( i/10 ) ... }
#local i=i+1;#end

should give spheres equally spaced along the spline

(this works at least when the points used to define the spline are 
numerous and reasonably smoothly "connected")

once you have achieved a constant change of distance you should be
able to control your change of speed by controlling the change of i
which would, for the camera, be a factor of clock

I was sure I saw somewhere a macro for producing a spline that parsed 
with equal distances but I cannot find it now

-Jim
(waiting for the cavalry to arrive)


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: Controlling Speed along a spline
Date: 6 Oct 2004 16:42:25
Message: <416458b1$1@news.povray.org>
Jim Charter wrote:
...
> I was sure I saw somewhere a macro for producing a spline that parsed 
> with equal distances but I cannot find it now
> 
> -Jim
> (waiting for the cavalry to arrive)

:)

Are you thinking of this:

http://news.povray.org/ttoenucoq6fcgkun57la24s9ia4ij5o573%404ax.com
(By ABX)

- or this:

http://www.geocities.com/SiliconValley/Lakes/1434/spline/index.html
(By Chris Colefax)

?

-- 
Tor Olav
http://subcube.net
http://subcube.com


Post a reply to this message

From: Jim Charter
Subject: Re: Controlling Speed along a spline
Date: 6 Oct 2004 17:47:33
Message: <416467f5$1@news.povray.org>
Tor Olav Kristensen wrote:
> Jim Charter wrote:
> ...
> 
>> I was sure I saw somewhere a macro for producing a spline that parsed 
>> with equal distances but I cannot find it now
>>
>> -Jim
>> (waiting for the cavalry to arrive)
> 
> 
> :)
> 
> Are you thinking of this:
> 
> http://news.povray.org/ttoenucoq6fcgkun57la24s9ia4ij5o573%404ax.com
> (By ABX)
> 
Okay, so instead of processing an array of points you reprocess a spline .

Yes that may indeed be what I was remembering.


Post a reply to this message

From: Tim Nikias
Subject: Re: Controlling Speed along a spline
Date: 6 Oct 2004 18:02:25
Message: <41646b71$1@news.povray.org>
> Are you thinking of this:
> http://news.povray.org/ttoenucoq6fcgkun57la24s9ia4ij5o573%404ax.com
> (By ABX)
> - or this:
> http://www.geocities.com/SiliconValley/Lakes/1434/spline/index.html
> (By Chris Colefax)
> ?

Now I'm sad. :-( I've scripted Bezier-splines from a Math-Book of mine which
I find very intuitive to use: you define control-nodes, which are ON the
spline, and Direction-Vectors for these Control-Nodes, to define the
direction WHERE the spline is moving after the node. I use 4D-Vectors to
make the directions use different lengths for when coming to and leaving
from a control-node.
Along with the Macros comes one which will take one of those BSplines,
calculate a given amount of nodes onto it, and then generates a sequence of
points from the initial bunch which are roughly the same distance of each
other (which takes movement along the spline into account, not distance
between two new points). The accuracy is in proportion to the amount of
nodes you let the macro generate before trying to find a given amount of
equal-distanced nodes.
These nodes can then just be used with a Macro that interpolates between
them. After I've scripted these macros, I've never used anything else. Not
just because *I* made them, but because I find them easy to visualize and
manipulate.

Well, enough of shameless plugging and throwing in bunches of 2 cents... ;-)

Regards,
Tim

-- 
"Tim Nikias v2.0"
Homepage: <http://www.nolights.de>


Post a reply to this message

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