1 #include <glib.h>
2 #include <math.h>
4 /** Returns \a x wrapped around to between 0 and less than 360,
5 or 0 if \a x isn't finite.
6 **/
7 double mod360(double const x)
8 {
9 double const m = fmod(x, 360.0);
10 double const ret = ( isnan(m)
11 ? 0.0
12 : ( m < 0
13 ? m + 360
14 : m ) );
15 g_return_val_if_fail(0.0 <= ret && ret < 360.0,
16 0.0);
17 return ret;
18 }
20 /*
21 Local Variables:
22 mode:c++
23 c-file-style:"stroustrup"
24 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
25 indent-tabs-mode:nil
26 fill-column:99
27 End:
28 */
29 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :