pinocchio  2.4.4
A fast and flexible implementation of Rigid Body Dynamics algorithms and their analytical derivatives
fwd.hpp
1 //
2 // Copyright (c) 2016-2019 CNRS INRIA
3 //
4 
5 #ifndef __pinocchio_math_fwd_hpp__
6 #define __pinocchio_math_fwd_hpp__
7 
8 #include "pinocchio/fwd.hpp"
9 #include <math.h>
10 #include <boost/math/constants/constants.hpp>
11 
12 namespace pinocchio
13 {
19  template<typename Scalar>
20  const Scalar PI()
21  { return boost::math::constants::pi<Scalar>(); }
22 
24  template<typename Scalar> struct TaylorSeriesExpansion;
25 
26  namespace math
27  {
28 
29 #define PINOCCHIO_OVERLOAD_MATH_UNARY_OPERATOR(name) \
30  template<typename Scalar> \
31  Scalar name(const Scalar & value) \
32  { using std::name; return name(value); }
33 
34 #define PINOCCHIO_OVERLOAD_MATH_BINARY_OPERATOR(name) \
35  namespace internal \
36  { \
37  template<typename T1, typename T2> \
38  struct return_type_##name \
39  { \
40  typedef T1 type; \
41  }; \
42  template<typename T1, typename T2> \
43  struct call_##name \
44  { \
45  static inline typename return_type_##name<T1,T2>::type \
46  run(const T1 & a, const T2 & b) \
47  { using std::name; return name(a,b); } \
48  }; \
49  } \
50  template<typename T1, typename T2> \
51  inline typename internal::return_type_##name<T1,T2>::type name(const T1 & a, const T2 & b) \
52  { return internal::call_##name<T1,T2>::run(a,b); }
53 
54  PINOCCHIO_OVERLOAD_MATH_UNARY_OPERATOR(fabs)
55  PINOCCHIO_OVERLOAD_MATH_UNARY_OPERATOR(sqrt)
56  PINOCCHIO_OVERLOAD_MATH_UNARY_OPERATOR(atan)
57  PINOCCHIO_OVERLOAD_MATH_UNARY_OPERATOR(acos)
58  PINOCCHIO_OVERLOAD_MATH_UNARY_OPERATOR(asin)
59  PINOCCHIO_OVERLOAD_MATH_UNARY_OPERATOR(cos)
60  PINOCCHIO_OVERLOAD_MATH_UNARY_OPERATOR(sin)
61 
62  PINOCCHIO_OVERLOAD_MATH_BINARY_OPERATOR(pow)
63  PINOCCHIO_OVERLOAD_MATH_BINARY_OPERATOR(min)
64  PINOCCHIO_OVERLOAD_MATH_BINARY_OPERATOR(max)
65  PINOCCHIO_OVERLOAD_MATH_BINARY_OPERATOR(atan2)
66  }
67 }
68 
69 #endif //#ifndef __pinocchio_math_fwd_hpp__
const Scalar PI()
Returns the value of PI according to the template parameters Scalar.
Definition: fwd.hpp:20
Main pinocchio namespace.
Definition: treeview.dox:24