POV-Ray : Newsgroups : povray.general : #while loop problem Server Time
2 Nov 2024 00:22:00 EDT (-0400)
  #while loop problem (Message 1 to 10 of 10)  
From: crewman
Subject: #while loop problem
Date: 29 Mar 2000 00:45:54
Message: <Pine.BSF.4.21.0003282122320.17649-100000@grafts.alley.org>
Hi there, I'm having a little problem with #while loops. Here is the
situation, I have a sphere that I wante to "etch" by using difference with
a torus. I had this bright idea that instead of hand coding 6 toruses, I
could use a while loop to make them for me:


//Includes:
#include "colors.inc"
#include "textures.inc"
#include "shapes.inc"
#include "metals.inc"


//Camera

camera {

right <-1.33,0,0>
up <0,10>
direction <0,0,1>
location <0,0,20>
look_at <0,0,0>
}


//Lights

light_source {<-20,35,34>
color {White}
}

light_source {<10,10,24>
color {White}
}


//White Background :)
background {White}

//And now the while loop


#declare Count1=0;
#while (Count1 < 6)

//This is the torus I want to make 6 (well 5 copies of)
#declare spinner2 =
torus { 1.0, 0.8
scale <1,0.1,1>
translate <0,0,0.5>
texture {T13} // A nice gold texture in metals.inc
}


difference {
//the sphere I want to "etch"
sphere {<0,0,0.5> 1.4
texture {T13}

object {spinner2 rotate <0,0,60*Count1>}

#declare Count1=Count1+1;
#end


Now my problem is, this doesn't seem to produce the effect I want, that is
a sphere, with a sort of star like pattern etched out. This drives me
nuts, becuase if I remove the difference, and the sphere from inside the
while loop, the six toruses are produced in the pattern I want, but I
can't for the life of me get it to subtract it from that sphere. So the
question I have is, is there a way for me to somehow #declare the while
loop created object? so I can THEN subtract that from the sphere? I tried
to #declare inside the while the loop, but seems to declare one instance
of the loop, not all of them (I hope I'm being clear, I'm not a programmer
:). Anyhow any help is appreciated, I hope my code doesn't have any typos
in it, since I typed in by hand hehe.



         Leif Petersen
         yf6### [at] victoriatcca


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: #while loop problem
Date: 29 Mar 2000 01:00:06
Message: <38e19be6$1@news.povray.org>
In article <Pin### [at] graftsalleyorg> , 
crewman <cre### [at] graftsalleyorg>  wrote:

> #declare Count1=0;
> #while (Count1 < 6)
>
> //This is the torus I want to make 6 (well 5 copies of)
> #declare spinner2 =
> torus { 1.0, 0.8
> scale <1,0.1,1>
> translate <0,0,0.5>
> texture {T13} // A nice gold texture in metals.inc
> }
>
>
> difference {
> //the sphere I want to "etch"
> sphere {<0,0,0.5> 1.4
> texture {T13}
>
> object {spinner2 rotate <0,0,60*Count1>}
>
> #declare Count1=Count1+1;
> #end

You need to use only one difference statement. Currently you create six
spheres and out of each of them you cut out one torus. Try this:

difference {
    //the sphere I want to "etch"
    sphere {<0,0,0.5> 1.4}

    #declare Count1=0;
    #while (Count1 < 6)

        //This is the torus I want to make 6 (well 5 copies of)
        torus {
            1.0, 0.8
            scale <1,0.1,1>
            translate <0,0,0.5>
            rotate <0,0,60*Count1>
        }

    #declare Count1=Count1+1;
    #end

    texture {T13} // A nice gold texture in metals.inc
}



     Thorsten


Post a reply to this message

From: Warp
Subject: Re: #while loop problem
Date: 29 Mar 2000 03:50:51
Message: <38e1c3ea@news.povray.org>
This is a surprisingly common mistake. I remember someone trying to make
a merge of several objects in a loop and he made:

#while(whatever)
  merge
  { object { Object }
  }
#end

(which makes lots of merges with one object inside them)
instead of doing it (correctly):

merge
{ #while(whatever)
    object { Object }
  #end
}

(which creates just one merge with lots of objects inside it)

  This case seems similar.

#while(whatever)
  difference
  { object { Object1 }
    object { Object2 }
  }
#end

(which makes lots of differences with two objects)
instead of:

difference
{ object { Object1 }
  #while(whatever)
    object { Object2 }
  #end
}

(which makes one difference with lots of objects).

  I don't know of any way to avoid this kind of misconceptions other than
learning the basics of programming.

-- 
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):5;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

From: Ken
Subject: Re: #while loop problem
Date: 29 Mar 2000 04:09:06
Message: <38E1C2FB.BE152AB3@pacbell.net>
Warp wrote:
> 
>   This is a surprisingly common mistake. I remember someone trying to make
> a merge of several objects in a loop and he made:

I think that was me :)

>   I don't know of any way to avoid this kind of misconceptions other than
> learning the basics of programming.

Don't have the time to learn how to program but once it was explained to
me I have not repeated the mistake. The while loop function may look like
a programmers operation to you but for me it was just another POV-Ray
proceedure to learn.


-- 
Ken Tyler -  1300+ Povray, Graphics, 3D Rendering, and Raytracing Links:
http://home.pacbell.net/tylereng/index.html http://www.povray.org/links/


Post a reply to this message

From: Warp
Subject: Re: #while loop problem
Date: 29 Mar 2000 04:23:05
Message: <38e1cb79@news.povray.org>
The little programmer inside me never sleeps... Resistance is futile :)

-- 
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):5;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

From: crewman
Subject: Re: #while loop problem
Date: 29 Mar 2000 15:49:37
Message: <Pine.LNX.4.10.10003291249270.13761-100000@belial.reno.nv.us>
On Wed, 29 Mar 2000, Thorsten Froehlich wrote:

Thank-you very much, you have no idea how many wierd things (and wow, some
of the results were....interesting :) I tried. Now it works like a charm!


Thanks again! 


> In article <Pin### [at] graftsalleyorg> , 
> crewman <cre### [at] graftsalleyorg>  wrote:
> 
> 
> You need to use only one difference statement. Currently you create six
> spheres and out of each of them you cut out one torus. Try this:
> 
> difference {
>     //the sphere I want to "etch"
>     sphere {<0,0,0.5> 1.4}
> 
>     #declare Count1=0;
>     #while (Count1 < 6)
> 
> 
> 
>      Thorsten
> 
>


Post a reply to this message

From: crewman
Subject: Re: #while loop problem
Date: 29 Mar 2000 15:51:30
Message: <Pine.LNX.4.10.10003291254160.13761-100000@belial.reno.nv.us>
On 29 Mar 2000, Warp wrote:

>   This is a surprisingly common mistake. I remember someone trying to make
> a merge of several objects in a loop and he made:

Not surprised

 
> #while(whatever)
>   merge
>   { object { Object }
>   }
> #end
> 
> difference
> { object { Object1 }
>   #while(whatever)
>     object { Object2 }
>   #end
> }
> 
> (which makes one difference with lots of objects).
> 
>   I don't know of any way to avoid this kind of misconceptions other than
> learning the basics of programming.

I do, by asking the folks here :)



 
> -- 
> main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
> ):5;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/
> 
>


Post a reply to this message

From: Warp
Subject: Re: #while loop problem
Date: 30 Mar 2000 03:40:15
Message: <38e312ef@news.povray.org>
cre### [at] belialrenonvus wrote:
:>   I don't know of any way to avoid this kind of misconceptions other than
:> learning the basics of programming.

: I do, by asking the folks here :)

  If you had to ask here, it means that you weren't able to avoid the
mistake... ;)

-- 
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):5;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

From: crewman
Subject: Re: #while loop problem
Date: 30 Mar 2000 12:51:26
Message: <Pine.LNX.4.10.10003300955001.14146-100000@belial.reno.nv.us>
On 30 Mar 2000, Warp wrote:

> cre### [at] belialrenonvus wrote:
> :>   I don't know of any way to avoid this kind of misconceptions other than
> :> learning the basics of programming.
> 
> : I do, by asking the folks here :)
> 
>   If you had to ask here, it means that you weren't able to avoid the
> mistake... ;)

Hehehe, hey nobody is perfect, least of all me ;) 

 
> -- 
> main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
> ):5;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/
> 
>


Post a reply to this message

From: PoD
Subject: Re: #while loop problem
Date: 30 Mar 2000 20:10:59
Message: <38E406B0.B8273CE9@merlin.net.au>
Ken wrote:
> 
> Warp wrote:
> >
> >   This is a surprisingly common mistake. I remember someone trying to make
> > a merge of several objects in a loop and he made:
> 
> I think that was me :)
> 
> >   I don't know of any way to avoid this kind of misconceptions other than
> > learning the basics of programming.
> 
> Don't have the time to learn how to program but once it was explained to
> me I have not repeated the mistake. The while loop function may look like
> a programmers operation to you but for me it was just another POV-Ray
> proceedure to learn.
> 

Like it or not you're learing to program ;^)

PoD.


Post a reply to this message

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