1 /*****************************************************************************
2 * This file is part of gfxprim library. *
4 * Gfxprim is free software; you can redistribute it and/or *
5 * modify it under the terms of the GNU Lesser General Public *
6 * License as published by the Free Software Foundation; either *
7 * version 2.1 of the License, or (at your option) any later version. *
9 * Gfxprim is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
12 * Lesser General Public License for more details. *
14 * You should have received a copy of the GNU Lesser General Public *
15 * License along with gfxprim; if not, write to the Free Software *
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
17 * Boston, MA 02110-1301 USA *
19 * Copyright (C) 2011 Tomas Gavenciak <gavento@ucw.cz> *
20 * Copyright (C) 2012 Cyril Hrubis <metan@ucw.cz> *
21 * Copyright (C) 2012 Jiri Dluhos <jiri.bluebear.dluhos@gmail.com> *
23 *****************************************************************************/
25 #include "GP_AngleUtils.h"
29 double GP_NormalizeAngle(double phi
)
31 // clamp angle to <-2*pi, 2*pi>
32 double phi2
= fmod(phi
, 2*M_PI
);
34 // clamp angle to <0, 2*pi>
41 int GP_AngleInRange(double angle
, double start
, double end
)
44 return (angle
>= start
&& angle
<= end
);
46 return (angle
>= start
&& angle
<= 2*M_PI
)
47 || (angle
>= 0 && angle
<= end
);