POV-Ray : Newsgroups : povray.advanced-users : select, pow(0,0) : select, pow(0,0) Server Time
19 Apr 2024 05:15:06 EDT (-0400)
  select, pow(0,0)  
From: Bald Eagle
Date: 25 Aug 2018 12:45:01
Message: <web.5b8186d1724f2371458c7afe0@news.povray.org>
So, I'm trying to write some macros that use pow(X, V).
I'm trying to make it past the "domain error" when pow(0,0) occurs.

So I tried:
#local PowX = select (X * V * (1-X), 0, 0, pow(X, V) );
But that gave me the same error, presumably because select evaluates the full
expression even though the threshold switch won't implement the >0 result.

So I finally did the following:

#declare E = 0.0000001;
#local PowX = select ((X * V * (1-X))-E, 0, 0, pow(X+E, V) );

#local Pow1minX = select ((1-X)*(N-V), 0, 0, pow((1-X),(N-V)) );

At some point X=1, and so 1-1=0, and you'd expect to get the same domain error,
but that doesn't happen.

Is there a better, more elegant way to do this?

Is this a floating point thing again - out at the 15th decimal place?

Isn't there a pow function that tolerates / passes through pow(0,0) as 0, like
the magical atan2 ?

I must say that it get get REALLY frustrating to get bogged down in fixing
things that you wouldn't have thought needed fixing, just so you can get back to
the point of working on the ACTUAL math that you started trying to fix.


Post a reply to this message

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