POV-Ray : Newsgroups : povray.advanced-users : select, pow(0,0) : Re: select, pow(0,0) Server Time
24 Apr 2024 18:17:55 EDT (-0400)
  Re: select, pow(0,0)  
From: clipka
Date: 25 Aug 2018 13:39:53
Message: <5b819469@news.povray.org>
Am 25.08.2018 um 18:41 schrieb Bald Eagle:
> 
> 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.

Are you sure that N-V=0, too?

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

In a macro? Why, yes, of course! Why not use `#if` instead of `select`?

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

And what result should that function return?

In some applications, you may want the result to be 1, to conform with
x^0=1; in other applications, a result of 0 would make more sense, to
conform with 0^x=0.

And in yet other applications, the most sensible thing to do is catch
this case further upstream and report that something's just totally wrong.


Post a reply to this message

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