|
|
"Bald Eagle" <cre### [at] netscapenet> 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, which happens along the edge you are looking at, and is made visible by
> > the switch in sign of the x value (x*tau). The natan2 puts that discontinuity
> > at opposite ends of the value range, rather than in the middle and makes all of
> > the resulting angles positive (0-2*pi), and thus there is no abrupt switch when
> > x goes negative.
> >
> > -- Chris R
>
> Most Excellent, fine Sir!
> Some days I can see what needs to be done - other days it's more . . . opaque.
>
> I'm officially voting that such be made an internal function, or at least
> something available in functions.inc
>
> This could save a lot of people a lot of trouble in the future.
>
> Thank you,
>
> - BW
No problem. I don't know how many times I have been tripped up by how atan2
works.
If you grab my libfn.inc from GitHub, https://github.com/carath63/povlibrary I
have defined f_normalized_atan2(x,y) already. It would be good to have as a
builtin in a future version of pov-ray, but in the meantime, if you are using
any of my code in your scenes, it is already defined there.
-- Chris R
Post a reply to this message
|
|