POV-Ray : Newsgroups : povray.general : Looping Server Time
7 Aug 2024 19:26:39 EDT (-0400)
  Looping (Message 1 to 4 of 4)  
From: ingo
Subject: Looping
Date: 22 May 2001 11:12:23
Message: <Xns90A9AF08CFE4Eseed7@povray.org>
How should I rewrite the following to avoid UU & VV to become bigger 
than Umax and Vmax?

#declare Uiter=100;
#declare Viter=100;
#declare Umin=0.0000001;
#declare Umax=0.9999999;
#declare Vmin=0.0000001;
#declare Vmax=1.9999999;
#declare iU=(Umax-Umin)/Uiter;
#declare iV=(Vmax-Vmin)/Viter;

#declare VV=Vmin;
#while (VV<Vmax)
   #declare UU=Umin;
   #while (UU<Umax)
        
      #declare UU=UU+iU;         
      #declare VV=VV+iV;
      #if (UU>=1 | VV>=2)
         #debug concat("UU+ =",str(UU,0,-1),"\n")
         #debug concat("VV+ =",str(VV,0,-1),"\n")
      #end
      
      #declare UU=UU-iU;
      #declare VV=VV-iV;

      #declare UU=UU+iU;      
   #end 
   #declare VV=VV+iV;
#end


Ingo

-- 
Photography: http://members.home.nl/ingoogni/
Pov-Ray    : http://members.home.nl/seed7/


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: Looping
Date: 22 May 2001 16:29:13
Message: <3B0ACBEB.A96B5479@hotmail.com>
Like this ?

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 =

#declare Uiter = 100;
#declare Viter = 100;
#declare Umin = 0.0000001;
#declare Umax = 0.9999999;
#declare Vmin = 0.0000001;
#declare Vmax = 1.9999999;
#declare iU = (Umax - Umin)/Uiter;
#declare iV = (Vmax - Vmin)/Viter;

#declare VV = Vmin;
#while (VV < Vmax)
    #declare UU = Umin;
    #while (UU < Umax)
//      #declare UU = UU + iU;
//      #declare VV = VV + iV;
       #if (UU >= 1 | VV >= 2)
          #debug concat("UU+ =", str(UU, 0, -1), "\n")
          #debug concat("VV+ =", str(VV, 0, -1), "\n")
       #end
//      #declare UU = UU - iU;
//      #declare VV = VV - iV;
       #declare UU = UU + iU;
    #end
    #declare VV = VV + iV;
#end

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 =

But I'm not sure if I understand the problem corretly.

-- 
Best regards,

Tor Olav

mailto:tor### [at] hotmailcom
http://hjem.sol.no/t-o-k/tokpicts.html
http://www.crosswinds.net/~tok


ingo wrote:
> 
> How should I rewrite the following to avoid UU & VV to become bigger
> than Umax and Vmax?
> 
> #declare Uiter=100;
> #declare Viter=100;
> #declare Umin=0.0000001;
> #declare Umax=0.9999999;
> #declare Vmin=0.0000001;
> #declare Vmax=1.9999999;
> #declare iU=(Umax-Umin)/Uiter;
> #declare iV=(Vmax-Vmin)/Viter;
> 
> #declare VV=Vmin;
> #while (VV<Vmax)
>    #declare UU=Umin;
>    #while (UU<Umax)
> 
>       #declare UU=UU+iU;
>       #declare VV=VV+iV;
>       #if (UU>=1 | VV>=2)
>          #debug concat("UU+ =",str(UU,0,-1),"\n")
>          #debug concat("VV+ =",str(VV,0,-1),"\n")
>       #end
> 
>       #declare UU=UU-iU;
>       #declare VV=VV-iV;
> 
>       #declare UU=UU+iU;
>    #end
>    #declare VV=VV+iV;
> #end


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: Looping
Date: 22 May 2001 16:44:53
Message: <3B0ACF9A.57CA26D7@hotmail.com>
Hmmm...
It seems that UU and VV is increased 2 "steps"
above their max limits.

One of the "steps" is due to how these loops works.

I'm not sure of the reason for other one.
Maybe it's some "epsilon problem" mentioned
earlier somewhere in these groups ?

-- 
Best regards,
Tor Olav

mailto:tor### [at] hotmailcom
http://hjem.sol.no/t-o-k/tokpicts.html
http://www.crosswinds.net/~tok


Tor Olav Kristensen wrote:
> 
> Like this ?
> 
> // ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 =
> 
> #declare Uiter = 100;
> #declare Viter = 100;
> #declare Umin = 0.0000001;
> #declare Umax = 0.9999999;
> #declare Vmin = 0.0000001;
> #declare Vmax = 1.9999999;
> #declare iU = (Umax - Umin)/Uiter;
> #declare iV = (Vmax - Vmin)/Viter;
> 
> #declare VV = Vmin;
> #while (VV < Vmax)
>     #declare UU = Umin;
>     #while (UU < Umax)
> //      #declare UU = UU + iU;
> //      #declare VV = VV + iV;
>        #if (UU >= 1 | VV >= 2)
>           #debug concat("UU+ =", str(UU, 0, -1), "\n")
>           #debug concat("VV+ =", str(VV, 0, -1), "\n")
>        #end
> //      #declare UU = UU - iU;
> //      #declare VV = VV - iV;
>        #declare UU = UU + iU;
>     #end
>     #declare VV = VV + iV;
> #end
> 
> // ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 =
> 
> But I'm not sure if I understand the problem corretly.
> 
> --
> Best regards,
> 
> Tor Olav
> 
> mailto:tor### [at] hotmailcom
> http://hjem.sol.no/t-o-k/tokpicts.html
> http://www.crosswinds.net/~tok
> 
> ingo wrote:
> >
> > How should I rewrite the following to avoid UU & VV to become bigger
> > than Umax and Vmax?
> >
> > #declare Uiter=100;
> > #declare Viter=100;
> > #declare Umin=0.0000001;
> > #declare Umax=0.9999999;
> > #declare Vmin=0.0000001;
> > #declare Vmax=1.9999999;
> > #declare iU=(Umax-Umin)/Uiter;
> > #declare iV=(Vmax-Vmin)/Viter;
> >
> > #declare VV=Vmin;
> > #while (VV<Vmax)
> >    #declare UU=Umin;
> >    #while (UU<Umax)
> >
> >       #declare UU=UU+iU;
> >       #declare VV=VV+iV;
> >       #if (UU>=1 | VV>=2)
> >          #debug concat("UU+ =",str(UU,0,-1),"\n")
> >          #debug concat("VV+ =",str(VV,0,-1),"\n")
> >       #end
> >
> >       #declare UU=UU-iU;
> >       #declare VV=VV-iV;
> >
> >       #declare UU=UU+iU;
> >    #end
> >    #declare VV=VV+iV;
> > #end


Post a reply to this message

From: ingo
Subject: Re: Looping
Date: 22 May 2001 17:29:36
Message: <Xns90A9EEFCBC500seed7@povray.org>
in news:3B0ACF9A.57CA26D7@hotmail.com Tor Olav Kristensen wrote:

> I'm not sure of the reason for other one.
> Maybe it's some "epsilon problem" mentioned
> earlier somewhere in these groups ?
> 

It's an accuracy problem indeed and in the meanwhile I solved it. The 
subsequent additions and substractions with small numbers seem to be 
less accurate than the multiplications I use now: 

#declare Uiter=100;
#declare Viter=100;
#declare Umin=0.0000001;
#declare Umax=0.9999999;
#declare Vmin=0.0000001;
#declare Vmax=1.9999999;
#declare iU=(Umax-Umin)/Uiter;
#declare iV=(Vmax-Vmin)/Viter;

#declare I=Vmin;
#while (I<Viter)

   #declare J=Umin;
   #while (J<Uiter)
      #declare VV=I*iV;
      #declare UU=J*iU;

      //some code ...
 
      #declare UU=UU+iU;         
      #declare VV=VV+iV;
      #if (UU>Umax | VV>Vmax)
         #debug concat("UU+ =",str(UU,0,-1),"\n")
         #debug concat("VV+ =",str(VV,0,-1),"\n")
      #end
      
      //some more code here ...

      //#declare UU=UU-iU;
      //#declare VV=VV-iV;
      // instead of substraction use multiplication,
      // and 're-declare.
      #declare VV=I*iV;
      #declare UU=J*iU;

      //even more code ...      

      #declare I=I+1;      
   #end 
   #declare J=J+1;
#end


Ingo

-- 
Photography: http://members.home.nl/ingoogni/
Pov-Ray    : http://members.home.nl/seed7/



Ingo

-- 
Photography: http://members.home.nl/ingoogni/
Pov-Ray    : http://members.home.nl/seed7/


Post a reply to this message

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