ibex-team / ibex-lib

IBEX is a C++ library for constraint processing over real numbers.
http://ibex-team.github.io/ibex-lib/
GNU Lesser General Public License v3.0
69 stars 51 forks source link

CtcAngle #140

Open gchabert opened 9 years ago

gchabert commented 9 years ago

We need a contractor for the angle constraint: Angle(x,y,t) <=> exists r>0, x=r_cos(t) et y=r_sin(t),

The simplest way to do this is with the reformulation: Angle(x,y,t) <=> modulo(2pi, t, atan2(x,y)), since we already have the atan2 and modulo operators.

However, forward-backward is not optimal because of the discontinuity of the atan2 function. Ex: [x]=[-2,-1], [y]=[-1,1] and [t]=[3,4]. So we have to manage the constraint "as a whole" (since we don't want to introduce unions in the generic forward-backward) and keep the union of intervals produced by the backward of the modulo:

fwd_atan2 --> [-pi,pi] bwd_modulo --> ([3-2_pi,4-2_pi] union [3,4]) inter [-pi,pi] --> [-pi,-4-2_pi] union [3,pi] then bwd_atan2 with successively [-pi,-4-2_pi] et [3,pi].

msis commented 9 years ago

I propose to have directly a CtcPolar as mentionned by Pr. Luc Jaulin, and letting the user set or not the r.

I think the implementation that I made of Interval::bwd_atan2 was optimal but had a bug as mentioned in #123. But I saw how you did the new one and I think I know how to solve it know. But @Jordan08 should provide an example so we can test it.

Look forward for my next push for this feature.