|
|
Cousin Ricky <ric### [at] yahoocom> wrote:
> I have a situation where it is possible to pass zero as both arguments
> to atan2(), which is the one case where the function fails. But while
> attempting to find a workaround for this situation, I discovered that
> simply calling atan2(0,0) from within a user-defined function avoids the
> domain error!
>
> I don't know whether this is intended POV-Ray behavior or just a fluke
> of my computer OS.
>...
Hi Ricky
I recommend that you don't make you code rely on a missing domain error.
(That it is missing could be considered a bug.)
Instead, I suggest that you write a function that deals with the
problematic values explicitly. E.g. like this:
#declare Atan2_Fn =
function(y, x) {
select(
y,
atan2(y, x),
select(
x,
atan2(y, x),
0, // Insert the result you want for Atan2_Fn(0, 0)
atan2(y, x)
),
atan2(y, x)
)
}
;
- or like this if you want 0 returned for AltAtan2_Fn(0, 0):
#declare AltAtan2_Fn =
function(y, x) {
atan2(
y,
select(
x,
x,
select(
y,
x,
1,
x
),
x
)
)
}
;
--
Tor Olav
http://subcube.com
https://github.com/t-o-k
Post a reply to this message
|
|