POV-Ray : Newsgroups : povray.animations : Train : Re: Train Server Time
1 Jun 2024 11:34:55 EDT (-0400)
  Re: Train  
From: Chris B
Date: 19 Jul 2008 06:11:44
Message: <4881bde0@news.povray.org>
"Chris B" <nom### [at] nomailcom> wrote in message 
news:4881bcdf@news.povray.org...
>
> "HelveticaFanatic" <nomail@nomail> wrote in message 
> news:web.4881a293729c10115f60ef1e0@news.povray.org...
>> "HelveticaFanatic" <nomail@nomail> wrote:
>>> How can I make an animation of a train that follows curves and 
>>> elevation? Is
>>> there anyway to lay track on it, either?
>>>
>>> Thanks.
>>
>> Is there an easy method for regulating the spacing? In other words...
>> I always use 1 foot scales for my coordinates for ease in designing and
>> visualizing, and I need to accelerate the train and keep it going at a 
>> smooth
>> speed. This would necessitate the float for each vector in the spline to 
>> be how
>> many feet from the end of the track. Is there a way to follow the spline 
>> by
>> length along the spline on the clock value? I'm thinking that I just 
>> label all
>> key points as 1, 2, 3, ..., then use a small program to determine the 
>> distances
>> between the key points (make small subdivisions and Pythagorean theorem, 
>> add it
>> up), then output it to a file, change the 1, 2, 3 to the feet? Or is 
>> there a
>> macro for this or some feature all ready?
>>
>
> The 'vlength' function calculates the length of a vector, so you can 
> subtract the coordinates of one position from the coordinates of another, 
> then use vlength to find the distance between them (in POV-Ray units). 
> It's generally best to avoid writing to files if you can because there's 
> usually a performance penalty to pay.
>
> The following example is a complete test scene file. Although it doesn't 
> contain a camera or objects it writes debug messages into the message 
> stream. Note that the second test on the #while loop is just to avoid 
> infinite loops in case you set DistanceTravelled to a length that takes 
> you off the end of the spline. In your animation you would define 
> DistanceTravelled based on the clock and your acceleration profile. The 
> very short #while loop ends when SplineIndex holds the value you seek. You 
> can increase the accuracy as necessary by reducing the value of Increment.
>
> #declare YourSpline = spline {
>    cubic_spline
>    -.25, <0,0,-1>
>    0.00, <2,0,0>
>    1.00, <1,0,2>
>    1.25, <0,0,1>
> }

I meant to say:

#declare YourSpline = spline {
    cubic_spline
    -.25, <0,0,-1>
    0.00, <20,0,0>
    1.00, <1,0,20>
    1.25, <0,0,1>
}

The other example illustrates the scenario where the distance is greater 
than the length of the spline :-)

Chris B.


Post a reply to this message

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