POV-Ray : Newsgroups : povray.general : Array of points for use with bicubic patch : Re: Array of points for use with bicubic patch Server Time
29 Jul 2024 20:14:38 EDT (-0400)
  Re: Array of points for use with bicubic patch  
From: D103
Date: 5 May 2011 09:00:01
Message: <web.4dc29e162d1676e45ae2687f0@news.povray.org>
"D103" <nomail@nomail> wrote:
> #declare X1=-1.5;  //in the scene file these are equal to the v_length of the
> appropriate values.
> #declare Z1=-1.5;
> #declare Cnt=0;
>
> #while(X1<=1.5)
>   #while(Z1<=1.5)
>     #if(Cnt>=15)
>       #debug "Cnt = illegal value.\n"
>     #else
>       #debug "Cnt is within legal range.\n"
>     #end
>     //#declare Pts[Cnt]=<X1, 0, Z1>;
>     sphere { 0, 0.1 pigment { White } translate <X1, 0, Z1> }
>     #declare Z1=Z1+1;
>     #declare Cnt=Cnt+1;
>   #end
>
> For some reason, when I run this in POV-Ray, it only creates one sphere, (or
> else several spheres in the same location), and when the sphere is replace with
> an array, the first point is generated alright, but on the second loop, it
> produces an error message: "attempt to access uninitialized array element".
>   #declare X1=X1+1;
>   #declare Z1=-1.5;
> #end

Not quite sure what went wrong there, but this seems to have fixed it:

#declare S1 = seed(7);
#declare S2 = seed(rand(S1)*10);

#macro RandColour(Col)
  colour Col+(<rand(S1), rand(S1), rand(S1)>-0.5)
  #if (1<(Col.gray))
    #local Col=Col-(<rand(S2), rand(S2), rand(S2)>);
    #else
      #if (0>(Col.gray))
      #local Col=Col+(<rand(S2), rand(S2), rand(S2)>);
    #end
  #end
#end

(thought I might as well post this macro, in case someone wants it)

#declare S3=seed(3);
#declare Cnt=0;
#declare X=-1.5;
#declare Z=-1.5;

#declare Pts = array[16];
#while(X<=1.5)
  #while(Z<=1.5)
    #if(Cnt>15)
      #debug "Cnt = illegal value.\n"
    #else
      #debug "Cnt is within legal range.\n"
    #end
    #declare Y=sin(X*4)/2;
    #declare Pts[Cnt]=<X, Y, Z>;
    #declare Z=Z+1;
    #declare Cnt=Cnt+1;
  #end
  #declare X=X+1;
  #declare Z=-1.5;
#end

bicubic_patch {
  type 1 u_steps 3 v_steps 3
  #declare C=0;
  #while(C<=15)
    Pts[C]
    #declare C=C+1;
  #end
  pigment {
    ripples colour_map {
      #declare Ind = 0;
      #declare Num = 50;
      #declare Rand = rand(S3);
      #while(Ind<=Num)
        #if(Rand<(1/3))
          [Ind/Num RandColour(Yellow) ]
        #end
        #if(Rand>(1/3)&Rand<(2/3))
          [Ind/Num RandColour(Cyan) ]
        #end
        #if(Rand>(2/3)&Rand<(1))
          [Ind/Num RandColour(Magenta) ]
        #end
      #declare Ind = Ind + 1;
      #end
    }
  }
}

Perhaps someone can shed some light on what's going on?

Thanks,
D103


Post a reply to this message

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