POV-Ray : Newsgroups : povray.general : Q: missing cylinder Server Time
6 Nov 2024 02:23:54 EST (-0500)
  Q: missing cylinder (Message 1 to 3 of 3)  
From: ingo
Subject: Q: missing cylinder
Date: 27 Feb 1999 11:54:46
Message: <36d82356.0@news.povray.org>
What goes wrong here?
In the following scene, if you change Steps to 9, 11, 21, 25 ...... there is
one cylinder missing. What thinking error did I make?

ingo.


#version 3.1;
#global_settings {assumed_gamma 1.0}
light_source {<500,500,-500> rgb 1}
camera {location 2*y look_at 0}

#declare StartPoint= <-1,0,0>;
#declare Length= <2,0,0>;

#declare Steps=10;

#declare iStep=1/Steps;
#declare i=0;
#declare i2=i+iStep;
#while (i2 <= 1)
  #declare P1= StartPoint+(Length*i);
  #declare P2= StartPoint+(Length*i2);
  cylinder {P1, P2, 0.05 pigment {rgb 1}}
  #declare i= i2;
  #declare i2= i+iStep;
#end

sphere { <-1,0,0>,0.05 pigment{rgb 10}}
sphere { < 1,0,0>,0.05 pigment{rgb 10}}

--
Met dank aan de muze met het glazen oog.


Post a reply to this message

From: Nathan Kopp
Subject: Re: Q: missing cylinder
Date: 28 Feb 1999 00:55:36
Message: <36D8DA49.A828175E@Kopp.com>
You're running into a round-off problem in the line "#while (i2 <= 1)".
Usually it's best to use integer values 'for' loop (or in a while loop
trying to act as a foor loop).  Changing your loop to the following fixes
the problem:
#declare iStep=1/Steps;
#declare i=0;
#declare n=0;  // using n as the counter
#declare i2=i+iStep;
#while(n<Steps)  // checking an integer, not a floating point
  #declare P1= StartPoint+(Length*i);
  #declare P2= StartPoint+(Length*i2);
  cylinder {P1, P2, 0.05 pigment {rgb 1}}
  #declare i= i2;
  #declare i2= i+iStep;
  #declare n=n+1;  // increment the loop counter
#end

-Nathan

ingo wrote:
> 
> What goes wrong here?
> In the following scene, if you change Steps to 9, 11, 21, 25 ...... there is
> one cylinder missing. What thinking error did I make?
> 
> ingo.
> 
> #version 3.1;
> #global_settings {assumed_gamma 1.0}
> light_source {<500,500,-500> rgb 1}
> camera {location 2*y look_at 0}
> 
> #declare StartPoint= <-1,0,0>;
> #declare Length= <2,0,0>;
> 
> #declare Steps=10;
> 
> #declare iStep=1/Steps;
> #declare i=0;
> #declare i2=i+iStep;
> #while (i2 <= 1)
>   #declare P1= StartPoint+(Length*i);
>   #declare P2= StartPoint+(Length*i2);
>   cylinder {P1, P2, 0.05 pigment {rgb 1}}
>   #declare i= i2;
>   #declare i2= i+iStep;
> #end
> 
> sphere { <-1,0,0>,0.05 pigment{rgb 10}}
> sphere { < 1,0,0>,0.05 pigment{rgb 10}}
> 
> --
> Met dank aan de muze met het glazen oog.


Post a reply to this message

From: ingo
Subject: Re: Q: missing cylinder
Date: 28 Feb 1999 03:31:37
Message: <36d8fee9.0@news.povray.org>
Thanks Nathan

ingo

--
Met dank aan de muze met het glazen oog.
Nathan Kopp heeft geschreven in bericht <36D8DA49.A828175E@Kopp.com>...
>You're running into a round-off problem in the line "#while (i2 <= 1)".
>Usually it's best to use integer values 'for' loop (or in a while loop
>trying to act as a foor loop).  Changing your loop to the following fixes
>the problem: ..........................


Post a reply to this message

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