Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
mod360.cpp
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
/*
5 * Authors: see git history
6 *
7 * Copyright (C) 2018 Authors
8 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
9 */
10#include <glib.h>
11#include <cmath>
12
13#include <2geom/angle.h>
14#include "mod360.h"
15
19double mod360(double const x)
20{
21 double m = fmod(x, 360.0);
22 if (std::isnan(m)) {
23 m = 0.0;
24 } else if (m < 0) {
25 m += 360.0;
26 }
27 if (m < 0.0 || m >= 360.0) {
28 m = 0.0;
29 }
30 return m;
31}
32
36double mod360symm(double const x)
37{
38 double m = mod360(x);
39
40 return m < 180.0 ? m : m - 360.0;
41}
42
43double radians_to_degree_mod360(double rad) {
45}
46
47double degree_to_radians_mod2pi(double degrees) {
48 return Geom::Angle::from_degrees(degrees).radians();
49}
50
51/*
52 Local Variables:
53 mode:c++
54 c-file-style:"stroustrup"
55 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
56 indent-tabs-mode:nil
57 fill-column:99
58 End:
59*/
60// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
Various trigoniometric helper functions.
static Angle from_degrees(Coord d)
Create an angle from its measure in degrees.
Definition angle.h:136
static Angle from_radians(Coord d)
Create an angle from its measure in radians.
Definition angle.h:131
Coord degrees() const
Get the angle as degrees in math convention.
Definition angle.h:118
Coord radians() const
Get the angle as radians.
Definition angle.h:107
double mod360symm(double const x)
Returns x wrapped around to between -180 and less than 180, or 0 if x isn't finite.
Definition mod360.cpp:36
double degree_to_radians_mod2pi(double degrees)
Definition mod360.cpp:47
double radians_to_degree_mod360(double rad)
Definition mod360.cpp:43
double mod360(double const x)
Returns x wrapped around to between 0 and less than 360, or 0 if x isn't finite.
Definition mod360.cpp:19
TODO: insert short description here.