POV-Ray : Newsgroups : povray.advanced-users : Closing brace bug ? Server Time
27 Dec 2024 05:46:56 EST (-0500)
  Closing brace bug ? (Message 1 to 9 of 9)  
From: Ken
Subject: Closing brace bug ?
Date: 7 Oct 1999 16:58:36
Message: <37FD096A.31723A5F@pacbell.net>
Rendering the following code as is issues a warning that there should be
at least two objects in a csg operation.  Ok I can live with that even
though it should work as is should it not ?
  Anyway the really weird part begins when we uncomment the extra closing
brace and Pov accepts it then renders the file. When did Pov start ignoring
extra closing braces ?


camera { location<0,0,-3> look_at 0}
light_source {<0,0,-300> rgb 1}

difference {
#declare A = 12;
#while (A<12)

sphere   {<0,0,0>, 1 pigment { rgb 1 }}
sphere   {<0,0,0>,.9 pigment { rgb 1 }}
cylinder { <-1.1,0, 0.0>,<1.0,0,0.0>,.1  rotate y*360/A pigment {rgb 1}}
cylinder { < 0.0,0,-1.1>,<0.0,0,1.1>,.1  rotate x*360/A pigment {rgb 1}}

// } // <------ uncomment this line

#declare A=A+1;
#end 
} // <--- leave this one alone


-- 
Ken Tyler
1100+ Povray, Graphics, 3D Rendering, and Raytracing Links:
http://home.pacbell.net/tylereng/index.html


Post a reply to this message

From: Ron Parker
Subject: Re: Closing brace bug ?
Date: 7 Oct 1999 17:06:04
Message: <slrn7vq2po.v8.parkerr@ron.gwmicro.com>
On Thu, 07 Oct 1999 13:58:18 -0700, Ken wrote:

>#declare A = 12;
>#while (A<12)

Nothing inside the #while - including the "extra" close brace -
will even be parsed, just read and ignored.  This is exactly like
the old C practice commenting out code by using #if 0 (which I do.)

[...]

>// } // <------ uncomment this line
>
>#declare A=A+1;
>#end


Post a reply to this message

From: Ken
Subject: Re: Closing brace bug ?
Date: 7 Oct 1999 17:10:25
Message: <37FD0C31.F2731A89@pacbell.net>
Ron Parker wrote:
> 
> On Thu, 07 Oct 1999 13:58:18 -0700, Ken wrote:
> 
> >#declare A = 12;
> >#while (A<12)
> 
> Nothing inside the #while - including the "extra" close brace -
> will even be parsed, just read and ignored.  This is exactly like
> the old C practice commenting out code by using #if 0 (which I do.)
> 
> [...]
> 
> >// } // <------ uncomment this line
> >
> >#declare A=A+1;
> >#end

I knew it had to be something simple and my fault but I just couldn't
see it. Thanks Uncle Ron.

-- 
Ken Tyler
1100+ Povray, Graphics, 3D Rendering, and Raytracing Links:
http://home.pacbell.net/tylereng/index.html


Post a reply to this message

From: Ken
Subject: Re: Closing brace bug ?
Date: 15 Oct 1999 11:20:59
Message: <38074610.89BB9676@pacbell.net>
Ken wrote:

  Something still bothering me about this code. After fixing it so that the
loop starts at zero and the csg operation is performed properly I am getting
a coincident surface problem with the sphere object. No amount of shuffling
of the code or pigments seems to eliminate the problem. Technicaly there
should be no coincident surface as far as I can tell. Example below:


 camera { location<0,0,-3> look_at 0}
 light_source {<0,0,-300> rgb 1}
 
difference {
 #declare A = .001;
  #while (A<12)
 
   sphere   {<0,0,0>, 1 pigment { rgb 1 }}
   sphere   {<0,0,0>,.9 pigment { rgb 1 }}
   cylinder { <-1.1,0, 0.0>,<1.0,0,0.0>,.1  rotate y*360/A pigment {rgb 1}}
   cylinder { < 0.0,0,-1.1>,<0.0,0,1.1>,.1  rotate x*360/A pigment {rgb 1}}

  #declare A=A+1;
 #end
}

-- 
Ken Tyler -  1100+ 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: Ron Parker
Subject: Re: Closing brace bug ?
Date: 15 Oct 1999 11:49:17
Message: <slrn80eitl.v8.parkerr@ron.gwmicro.com>
On Fri, 15 Oct 1999 08:19:44 -0700, Ken wrote:
>
>
>Ken wrote:
>
>  Something still bothering me about this code. After fixing it so that the
>loop starts at zero and the csg operation is performed properly I am getting
>a coincident surface problem with the sphere object. No amount of shuffling
>of the code or pigments seems to eliminate the problem. Technicaly there
>should be no coincident surface as far as I can tell. Example below:

Your code expands to:

camera { location<0,0,-3> look_at 0}
light_source {<0,0,-300> rgb 1}
 
difference {
   sphere   {<0,0,0>, 1 pigment { rgb 1 }}
   sphere   {<0,0,0>,.9 pigment { rgb 1 }}
   cylinder { <-1.1,0, 0.0>,<1.0,0,0.0>,.1  rotate y*360/.001 pigment {rgb 1}}
   cylinder { < 0.0,0,-1.1>,<0.0,0,1.1>,.1  rotate x*360/.001 pigment {rgb 1}}
   sphere   {<0,0,0>, 1 pigment { rgb 1 }}
   sphere   {<0,0,0>,.9 pigment { rgb 1 }}
   cylinder { <-1.1,0, 0.0>,<1.0,0,0.0>,.1  rotate y*360/1.001 pigment {rgb 1}}
   cylinder { < 0.0,0,-1.1>,<0.0,0,1.1>,.1  rotate x*360/1.001 pigment {rgb 1}}
    :
    :
   sphere   {<0,0,0>, 1 pigment { rgb 1 }}
   sphere   {<0,0,0>,.9 pigment { rgb 1 }}
   cylinder { <-1.1,0, 0.0>,<1.0,0,0.0>,.1  rotate y*360/11.001 pigment {rgb 1}}
   cylinder { < 0.0,0,-1.1>,<0.0,0,1.1>,.1  rotate x*360/11.001 pigment {rgb 1}}
}

First, I'm guessing you didn't really mean to multiply by 360/A; you probably 
meant something else, as rotating by 360,000 degrees is meaningless and strange.
Perhaps you meant to multiply by 360*A/12 ?  If so, note that the cylinder 
created for A=6 will be coincident with the one created for A=0 as well.  In 
addition, the two cylinders for A=3 and the two for A=9 will be coincident.

That said, notice that you're differencing the same sphere many, many times and 
in fact you're differencing the first sphere from itself.  Of course you have a
coincident surface problem.

Here's your code with my changes.  I added the high ambient so I could see the
back side of the sphere through the hole; you probably don't want it.

camera { location<0,0,-3> look_at 0}
light_source {<0,0,-300> rgb 1}
default {finish {ambient .5}}
 
difference {
  sphere   {<0,0,0>, 1 pigment { rgb 1 }}
  sphere   {<0,0,0>,.9 pigment { rgb 1 }}

  #declare A = .001;
  #while (A<6)
 
   cylinder { <-1.1,0, 0.0>,<1.0,0,0.0>,.1  rotate y*A*30 pigment {rgb 1}}
   #if (A != 3 )
     cylinder { < 0.0,0,-1.1>,<0.0,0,1.1>,.1  rotate x*A*30 pigment {rgb 1}}
   #end

 #declare A=A+1;
 #end
}


Post a reply to this message

From: Ken
Subject: Re: Closing brace bug ?
Date: 15 Oct 1999 11:57:54
Message: <38074EB5.14290561@pacbell.net>
Ron Parker wrote:

> Your code expands to:

> 
> First, I'm guessing you didn't really mean to multiply by 360/A; you probably
> meant something else, as rotating by 360,000 degrees is meaningless and strange.
> Perhaps you meant to multiply by 360*A/12 ?  If so, note that the cylinder
> created for A=6 will be coincident with the one created for A=0 as well.  In
> addition, the two cylinders for A=3 and the two for A=9 will be coincident.
> 
> That said, notice that you're differencing the same sphere many, many times and
> in fact you're differencing the first sphere from itself.  Of course you have a
> coincident surface problem.

 Actually the code was intentionaly left as it was to illustrate the
problem. What I am confused about though is why the coincident surface
problem is manifesting itself on the surface areas of the sphere that
are in no way in contact with any of the csg operation. I can understand
it where there are cylinders overlapping ect. but not in the other areas
of the sphere itself.
 I will ponder these things further and perhaps some day I will grok them
in their entirety.

-- 
Ken Tyler -  1100+ 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: Ron Parker
Subject: Re: Closing brace bug ?
Date: 15 Oct 1999 11:58:03
Message: <slrn80eje3.v8.parkerr@ron.gwmicro.com>
On 15 Oct 1999 11:49:17 -0400, Ron Parker wrote:
>In addition, the two cylinders for A=3 and the two for A=9 will be coincident.

Whoops, that's not right.  The first cylinder for A=3 is coincident with the
second cylinder for A=0.  There are still coincident surfaces in my code, and
a missing cylinder besides.  Try this instead:

camera { location<0,2,-3> look_at 0}
light_source {<0,0,-300> rgb 1}
 
difference {
  sphere   {<0,0,0>, 1 pigment { rgb 1 }}
  sphere   {<0,0,0>,.9 pigment { rgb 1 }}

  #declare A = .001;
  #while (A<6)
 
   #if (A != 3 )
     cylinder { <-1.1,0, 0.0>,<1.1,0,0.0>,.1  rotate y*A*30 pigment {rgb 1}}
   #end
   cylinder { < 0.0,0,-1.1>,<0.0,0,1.1>,.1  rotate x*A*30 pigment {rgb 1}}

 #declare A=A+1;
 #end
}


Post a reply to this message

From: Ron Parker
Subject: Re: Closing brace bug ?
Date: 15 Oct 1999 12:02:41
Message: <slrn80ejmo.v8.parkerr@ron.gwmicro.com>
On Fri, 15 Oct 1999 08:56:37 -0700, Ken wrote:
> Actually the code was intentionaly left as it was to illustrate the
>problem. What I am confused about though is why the coincident surface
>problem is manifesting itself on the surface areas of the sphere that
>are in no way in contact with any of the csg operation. 

Because the whole thing is part of the csg operation.  Taking out the 
irrelevant parts, you're left with this, which is obviously wrong:

difference {
  sphere   {<0,0,0>, 1 pigment { rgb 1 }}
  sphere   {<0,0,0>, 1 pigment { rgb 1 }}
  sphere   {<0,0,0>, 1 pigment { rgb 1 }}
  :
  :
}


Post a reply to this message

From: Ken
Subject: Re: Closing brace bug ?
Date: 15 Oct 1999 12:14:35
Message: <380752A0.BBD4C09@pacbell.net>
Ron Parker wrote:
> 
> On Fri, 15 Oct 1999 08:56:37 -0700, Ken wrote:
> > Actually the code was intentionaly left as it was to illustrate the
> >problem. What I am confused about though is why the coincident surface
> >problem is manifesting itself on the surface areas of the sphere that
> >are in no way in contact with any of the csg operation.
> 
> Because the whole thing is part of the csg operation.  Taking out the
> irrelevant parts, you're left with this, which is obviously wrong:
> 
> difference {
>   sphere   {<0,0,0>, 1 pigment { rgb 1 }}
>   sphere   {<0,0,0>, 1 pigment { rgb 1 }}
>   sphere   {<0,0,0>, 1 pigment { rgb 1 }}
>   :
>   :
> }

I understand now. Because part of the operation is within the loop with
a count of 12 I am getting 12 copies of the sphere rather than the 1
I had assumed.

 These programming loops are confusing as hell sometimes "#%@!!!

-- 
Ken Tyler -  1100+ 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

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