Tetrapod Project
angle_utils.h
Go to the documentation of this file.
1 /*******************************************************************/
2 /* AUTHOR: Paal Arthur S. Thorseth */
3 /* ORGN: Dept of Eng Cybernetics, NTNU Trondheim */
4 /* FILE: angle_utils.h */
5 /* DATE: Feb 9, 2021 */
6 /* */
7 /* Copyright (C) 2021 Paal Arthur S. Thorseth, */
8 /* Adrian B. Ghansah */
9 /* */
10 /* This program is free software: you can redistribute it */
11 /* and/or modify it under the terms of the GNU General */
12 /* Public License as published by the Free Software Foundation, */
13 /* either version 3 of the License, or (at your option) any */
14 /* later version. */
15 /* */
16 /* This program is distributed in the hope that it will be useful, */
17 /* but WITHOUT ANY WARRANTY; without even the implied warranty */
18 /* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */
19 /* See the GNU General Public License for more details. */
20 /* */
21 /* You should have received a copy of the GNU General Public */
22 /* License along with this program. If not, see */
23 /* <https://www.gnu.org/licenses/>. */
24 /* */
25 /*******************************************************************/
26 
27 #pragma once
28 
29 // C++ Standard Library
30 #include <cmath>
31 
32 // Boost
33 #include <boost/math/constants/constants.hpp>
34 
35 namespace math_utils
36 {
38  static constexpr double TWO_PI = boost::math::constants::two_pi<double>();
39 
41  static constexpr double FOUR_THIRDS_PI = boost::math::constants::four_thirds_pi<double>();
42 
44  static constexpr double PI = boost::math::constants::pi<double>();
45 
47  static constexpr double THREE_QUARTERS_PI = boost::math::constants::three_quarters_pi<double>();
48 
50  static constexpr double TWO_THIRDS_PI = boost::math::constants::two_thirds_pi<double>();
51 
53  static constexpr double HALF_PI = boost::math::constants::half_pi<double>();
54 
56  static constexpr double THIRD_PI = boost::math::constants::third_pi<double>();
57 
59  static constexpr double SIXTH_PI = boost::math::constants::sixth_pi<double>();
60 
62  static constexpr double ONE_DIV_TWO_PI = boost::math::constants::one_div_two_pi<double>();
63 
67  double degToRad(const double &_deg);
68 
72  double radToDeg(const double &_rad);
73 
78  double wrapAngleToPi(const double &_rad);
79 
84  double wrapAngleTo2Pi(const double &_rad);
85 
91  double angleDiff(const double &_ang1, const double &_ang2);
92 
93 } // namespace math_utils
static constexpr double HALF_PI
Define PI/2.
Definition: angle_utils.h:53
static constexpr double SIXTH_PI
Define PI/6.
Definition: angle_utils.h:59
static constexpr double THIRD_PI
Define PI/3.
Definition: angle_utils.h:56
double wrapAngleToPi(const double &_rad)
The wrapAngleToPi function wraps an input angle to the interval [-pi, pi).
Definition: angle_utils.cpp:45
double degToRad(const double &_deg)
The degToRad function converts degrees to radians.
Definition: angle_utils.cpp:33
double angleDiff(const double &_ang1, const double &_ang2)
The angleDiff function returns the difference in angle between two given angles in the interval [0,...
Definition: angle_utils.cpp:72
static constexpr double ONE_DIV_TWO_PI
Define 1/2PI.
Definition: angle_utils.h:62
static constexpr double THREE_QUARTERS_PI
Define 3PI/4.
Definition: angle_utils.h:47
double radToDeg(const double &_rad)
The radToDeg function converts radians to degrees.
Definition: angle_utils.cpp:39
static constexpr double TWO_PI
Define 2PI.
Definition: angle_utils.h:38
static constexpr double PI
Define PI.
Definition: angle_utils.h:44
double wrapAngleTo2Pi(const double &_rad)
The wrapAngleTo2Pi function wraps an input angle to the interval [0, 2pi).
Definition: angle_utils.cpp:59
static constexpr double FOUR_THIRDS_PI
Define 4PI/3.
Definition: angle_utils.h:41
static constexpr double TWO_THIRDS_PI
Define 2PI/3.
Definition: angle_utils.h:50