POV-Ray : Newsgroups : povray.general : Regular Polygons & Prisms : Re: Regular Polygons & Prisms Server Time
11 Aug 2024 07:16:13 EDT (-0400)
  Re: Regular Polygons & Prisms  
From: Nieminen Juha
Date: 8 Oct 1999 04:33:36
Message: <37fdac60@news.povray.org>
Andrea Ryan <ary### [at] global2000net> wrote:
: #if (-0.000000000000000244921<=vec.u<=0.000000000000000244921)

  This comparison doesn't work as expected. It will be true when the value
of 'vec.u' is less than the first value.

  Why?
  Let's take a simpler example:

#if(-0.5 <= var <= 0.5)
  #debug "Hello\n"
#end

  This will print "Hello" only when 'var' is less than '-0.5'.
  What happens?
  First povray will evaluate the first operator, ie. "-0.5 <= var". If
'var' is greater or equal to -0.5, it will return true, which is the same
as 1, else false, which is the same as 0.
  Let's suppose that 'var' has the value 0. The comparison "-0.5 <= 0" will
return true, ie 1. Now povray will make the comparison "1 <= 0.5" which
returns false. The string is not printed.
  Let's suppose that 'var' has the value -1. The comparison "-0.5 <= -1" will
return false, ie 0. The comparison "0 <= 0.5" will return true. The string
is printed.

  Thus, the string will be printed only when the value of 'var' is less
than -0.5.

  The correct way to do the comparison is:

#if(-0.5 <= var & var <= 0.5)

-- 
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

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