Thread Links Date Links
Thread Prev Thread Next Thread Index Date Prev Date Next Date Index

Re: Alternative atan2 (was Motion 52: final ...)



On 2013-12-03 00:07:49 -0500, Michel Hack wrote:
> Vincent Lefèvre replied to me:
> > > In fact, I think we need to define overlapping ranges, i.e. to define
> > > atan2p() to have the range [0,+2pi).  Would that work?
> >
> > I don't think [0,2pi) is OK.  How would you represent [-eps,+eps]?
> 
> You would use an extension of atan2() and not atan2p().  Remember that
> earlier I had said:
> >> I think what we need are three point functions, atan2(), atan2p() and
> >> atan2m(), with respective ranges (-pi,+pi], [+pi,+3pi) and (-3pi,-pi],
> >> with a rule that selects the appropriate one, based on which argument
> >> contains zero (if any).  I guess [-pi,+pi]_trv would be returned if
> >> both arguments contain 0.
> 
> Basically, one would define atan2_sharp(Y,X) piecemeal, based on either
> atan2() or atan2p(), possibly using the case() operator.  Roughly, one
> could have:
>    if (both X and Y contain 0)   return [-pi,+pi]_trv
>    if (X < 0)                    return atan2p(Y,X)
>    else                          return atan2(Y,X)

I now see what you mean. The atan2p and atan2m functions would just
be helper functions for the specification of atan2_sharp and would
not need to be exposed to the user. Perhaps the ranges (-pi,+pi],
[0,+2pi) and (-2pi,0] might work. I don't think that the interval
version (at Level 1) should contain anything outside [-2pi,+2pi],
i.e. there's always a valid solution in [-2pi,+2pi].

-- 
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)