POV-Ray : Newsgroups : povray.animations : Animation block...acceleration on the x axis. : Re: Animation block...acceleration on the x axis. Server Time
27 Apr 2024 01:56:37 EDT (-0400)
  Re: Animation block...acceleration on the x axis.  
From: RC
Date: 23 Feb 2009 18:30:01
Message: <web.49a3309d21b0f15ae1acfc5e0@news.povray.org>
"Chris B" <nom### [at] nomailcom> wrote:
> "RC" <nomail@nomail> wrote in message
> news:web.49a3163629ff894ce1acfc5e0@news.povray.org...
> > Hello,
> >
> > I know this question is going to be a head slapper but I can't seem to get
> > an
> > object to increase in speed. I need this object to increase in speed every
> > x
> > clock cycles, so I'm using an if statement. Problem is I can get it to
> > enter
> > the 'else' section, but it never returns to my original condition after I
> > reset
> > my variable counting to x (num).
> >
> >        #declare num = clock*60;
> >        //60 being the total number of frames
> >        #declare speed = clock;
> >        #if (num <= 3)
> >              object { Ball
> >                scale 0.7
> >                translate <-5.5, 0, 0>
> >                translate <speed, 0, 0>
> >                #declare num = num + 1;
> >               }
> >              #debug "speed the same\n"
> >        #else
> >              #declare speed = speed + 1;
> >              #declare num = clock;
> >              #debug"speed increased\n"
> >        #end
> >
> > This is hurting my brain, and I know the answer is staring me down I just
> > can't
> > see it. Any input? I have a feeling its related to the declare statements.
> >
>
> I think there are a few misconceptions evident from this code snippet.
>
> The Ball object is only placed in the scene if num<=3. Else the ball is not
> added into the scene at all by this code. I suspect you need to place the
> ball object in the scene after the #if, #else, #end clause that calculates
> the distance travelled.
>
> The comparison 'num<=3' is dodgy in a number of respects. Firstly, if you
> truly do have 60 frames then, as the frame number passes from 0 to 59, num
> will pass from 0 to 60, so won't go up in integer values. Secondly it's a
> calculated decimal value so it can't be  reliably used in this sort of
> comparison anyway (on frame 3 it may or may not be 3 to within the precision
> of the calculation). It would seem more appropriate to use the frame_number
> variable for this sort of comparison, which is an integer.
>
> Within the #if statement, the variable 'speed' is used to translate a
> distance controlled by the clock, but this is a very small distance = 1/60
> POV-Ray units in the first 4 frames, so you may not even notice this
> distance unless your camera is really close to the ball. It'll move from
> x=-5.5 to x=-5.434 in those 4 frames.
>
> Even if the ball appeared beyond the 4th frame (frame 3), which it doesn't
> in this code, the increase in 'speed' isn't really that at all. You're just
> adding 1 unit to the variable you've been using for distance, so it would
> jump forward during one frame transition and would then continue at the
> snails pace it was doing before. It would travel a total of 2 units in the
> 60 frames, with 1 unit of that distance being added in a single step between
> frames 3 and 4.
>
> All of the calculations you do after adding the Ball object to the scene
> have no impact at all on the Ball object., so the num=num+1 doesn't do
> anything to the ball in any of the frames.
>
> I see Warp has given you an example using a function to calculate the X
> displacement of an object that you can then use to translate your Ball
> object while I've been writing this, which is probably all you really need,
> but I hope this explanation also helps.
>
> Regards,
> Chris B.


Thank you both loads. I think I understand and Chris B, what you wrote is
exactly whats happening. I'll give it a whirl...


Post a reply to this message

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