cheshirekow  v0.1.0
funcs.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 Josh Bialkowski (jbialk@mit.edu)
3  *
4  * This file is part of mpblocks.
5  *
6  * mpblocks is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * mpblocks is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with mpblocks. If not, see <http://www.gnu.org/licenses/>.
18  */
27 #ifndef MPBLOCKS_DUBINS_CURVES_FUNCS_HPP_
28 #define MPBLOCKS_DUBINS_CURVES_FUNCS_HPP_
29 
31 
32 namespace mpblocks {
33 namespace dubins {
34 
35 template <typename Format_t>
37 Format_t clampRadian(Format_t a) {
38  const Format_t _PI = static_cast<Format_t>(M_PI);
39  const Format_t _2 = static_cast<Format_t>(2);
40 
41  while (a > _PI) a -= _2 * _PI;
42  while (a < -_PI) a += _2 * _PI;
43 
44  return a;
45 }
46 
49 template <typename Format_t>
51 Format_t ccwArc(Format_t a, Format_t b) {
52  const Format_t _PI = static_cast<Format_t>(M_PI);
53  const Format_t _2 = static_cast<Format_t>(2);
54 
55  Format_t r = b - a;
56  while (r < 0) r += _2 * _PI;
57  return r;
58 }
59 
62 template <typename Format_t>
64 Format_t leftArc(Format_t a, Format_t b) {
65  return ccwArc(a, b);
66 }
67 
70 template <typename Format_t>
72 Format_t cwArc(Format_t a, Format_t b) {
73  const Format_t _PI = static_cast<Format_t>(M_PI);
74  const Format_t _2 = static_cast<Format_t>(2);
75 
76  Format_t r = a - b;
77  while (r < 0) r += _2 * _PI;
78  return r;
79 }
80 
83 template <typename Format_t>
85 Format_t rightArc(Format_t a, Format_t b) {
86  return cwArc(a, b);
87 }
88 
89 } // dubins
90 } // mpblocks
91 
92 #endif // MPBLOCKS_DUBINS_CURVES_FUNCS_HPP_
__host__ __device__ Format_t cwArc(Format_t a, Format_t b)
returns the clockwise (right) distance from a to b
Definition: funcs.hpp:72
empty struct used to template "variant" of three arc primitives
Definition: types.h:46
__host__ __device__ Format_t ccwArc(Format_t a, Format_t b)
returns the counter clockwise (left) distance from a to b
Definition: funcs.hpp:51
empty struct used to template "variant" of three arc primitives
Definition: types.h:43
__host__ __device__ Format_t clampRadian(Format_t a)
wraps the input onto [-pi,pi]
Definition: funcs.hpp:37
__host__ __device__ Format_t rightArc(Format_t a, Format_t b)
returns the clockwise (right) distance from a to b
Definition: funcs.hpp:85
#define __device__
Definition: fakecuda.h:34
#define __host__
Definition: fakecuda.h:37
__host__ __device__ Format_t leftArc(Format_t a, Format_t b)
returns the counter clockwise (left) distance from a to b
Definition: funcs.hpp:64