POV-Ray : Newsgroups : povray.general : I give up... : Re: I give up... Server Time
5 Aug 2024 00:18:06 EDT (-0400)
  Re: I give up...  
From: PoD
Date: 15 Jan 2003 05:58:37
Message: <pan.2003.01.15.10.58.35.607177@internode.on.net>
On Wed, 15 Jan 2003 03:15:39 +0000, Phil Clute wrote:

> Why isn't this working?
> The correct behaviour should be an animation where the ship spins 360
> degrees(10 degrees per frame). Once it has completed 1 rotation it moves
> away from the camera and spins again.
> The ship spins just fine but I can't get it to move away from the camera.
> 
> 
> 
> #declare NumColumns = 24;
> #declare Columns = 0;
> #declare NumRows = 36;
> #declare Rows = 0;
> 
> #while(Columns < NumColumns)
>          #while(Rows < NumRows)
>             #declare T = Columns *40;
>             object {ship rotate clock*z*360
>                          translate < 0, T, T> }
>             #declare Rows = Rows + 1;
>          #end
>      #declare Columns = Columns + 1;
> #end

Rows has to be reinitialised to 0 inside the Columns loop.
The second time through the Columns loop Rows still has the value NumRows,
so the Rows loop will not be executed.

#declare NumColumns = 24;
#declare NumRows = 36;
 
#declare Columns = 0;
#while(Columns < NumColumns)
         #declare Rows = 0;
         #while(Rows < NumRows)
            #declare T = Columns *40;
            object {ship rotate clock*z*360
                         translate < 0, T, T> }
            #declare Rows = Rows + 1;
         #end
     #declare Columns = Columns + 1;
#end

I believe that keeping the initialiser close to the #while loop makes it
clearer.  I usually do it as

#declare N = 0; #while( N < Limit)
    ....
    #declare N=N+1; #end

so that it looks more like a for() loop

Cheers,
PoD.


Post a reply to this message

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