|
|
"Tor Olav Kristensen" <tor### [at] TOBEREMOVEDgmailcom> wrote:
> "Chris R" <car### [at] comcastnet> wrote:
> >...
> > I got it to work by making the following change:
> >
> > #declare natan2 = function(a,b) { select(a, 2*pi+atan2(a,b), atan2(a,b)) }
> > #declare Theta = function {((natan2 (y, z))/pi)*tau + x*tau}
> >
> > The problem is that atan2 has that discontinuity where it jumps from pi/2 to
> > -pi/2, ...
>
> Hi Chris
>
> I think that should be "from +pi to -pi".
>
> I would also suggest that you define your new atan2() function like this;
>
> #declare natan2 =
> function(a, b) {
> atan2(a, b) + select(a, 2*pi, 0)
> }
> ;
>
> It makes what happens a little bit clearer at the expense of an extra addition.
I just noticed that both these variants have a little problem:
They have a discontinuity at a = -0
natan2(+1e-100, -1) = +3.141592653589793
natan2( +0, -1) = +3.141592653589793
natan2( -0, -1) = -3.141592653589793
natan2(-1e-100, -1) = +3.141592653589793
This variant does not have this problem:
#declare natan2 =
function(a, b) {
mod(atan2(a, b) + 2*pi, 2*pi)
}
;
--
Tor Olav
http://subcube.com
https://github.com/t-o-k
Post a reply to this message
|
|