POV-Ray : Newsgroups : povray.general : povray crashes on multiplication? : Re: povray crashes on multiplication? Server Time
31 Jul 2024 02:20:44 EDT (-0400)
  Re: povray crashes on multiplication?  
From: Alain
Date: 3 Dec 2007 09:46:32
Message: <475416c8$1@news.povray.org>
stevenvh nous apporta ses lumieres en ce 2007/12/02 14:55:
> Hi,
> I'm using a macro which is called only a few (7) times:
> 
> /* code starts here *********************************************************/
> #macro DrawShelfSection( aLeft, aRight, aY, aSlanting )
>     #declare InvCosSl = 1 / cos ( 180 * aSlanting / pi );
>     ...
>     #declare xx = Left;
>     #while (xx < Right)
>         ...
>         #if (xx + Bwidth <= Right)
>             DrawBook( xx, aY, Bheight, Bwidth, aSlanting, RandomColor > )
>         #end
>         #declare xx = xx + Bwidth * InvCosSl;
>     #end
> #end
> /* code ends here ***********************************************************/
> 
> When I start rendering the "tokens parsed" counter starts and runs until POVray
> crashes at about 270 million (!) tokens parsed.
> When I change the last declaration to
> 
>     #declare xx = xx + Bwidth;
> 
> everything runs fine (with only 660000 tokens parsed).
> I first thought the error may have been caused by the 10000x10000 pixel image,
> but it also happens on a 500x500.
> You can find the error msg dialog at http://www.nenya.be/temp/povray_err.png.
> 
> Ideaz anyone?
> TIA
> Steven
> 
> 
> 
The variable "InvCosSl" can go negative. I suggest using the absolute value. 
Also, "cos ( 180 * aSlanting / pi )" can evaluate to a very small, even zero, 
value, resulting in an extremely large value (overflow) or a divide by zero 
error. In fact, you evaluate a cotangent, a functions with asymptotic lines.

-- 
Alain
-------------------------------------------------
   My wife likes to talk on the phone during sex; she called me from Chicago 
last night.
	Rodney Dangerfield


Post a reply to this message

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