pinocchio  2.7.1
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 #include <boost/type_traits/is_floating_point.hpp>
12 
13 namespace pinocchio
14 {
15 
16  template <typename T>
17  struct is_floating_point : boost::is_floating_point<T>
18  {
19  };
20 
26  template<typename Scalar>
27  const Scalar PI()
28  { return boost::math::constants::pi<Scalar>(); }
29 
31  template<typename Scalar> struct TaylorSeriesExpansion;
32 
33  namespace math
34  {
35 
36 #define PINOCCHIO_OVERLOAD_MATH_UNARY_OPERATOR(name) \
37  template<typename Scalar> \
38  Scalar name(const Scalar & value) \
39  { using std::name; return name(value); }
40 
41 #define PINOCCHIO_OVERLOAD_MATH_BINARY_OPERATOR(name) \
42  namespace internal \
43  { \
44  template<typename T1, typename T2> \
45  struct return_type_##name \
46  { \
47  typedef T1 type; \
48  }; \
49  template<typename T1, typename T2> \
50  struct call_##name \
51  { \
52  static inline typename return_type_##name<T1,T2>::type \
53  run(const T1 & a, const T2 & b) \
54  { using std::name; return name(a,b); } \
55  }; \
56  } \
57  template<typename T1, typename T2> \
58  inline typename internal::return_type_##name<T1,T2>::type name(const T1 & a, const T2 & b) \
59  { return internal::call_##name<T1,T2>::run(a,b); }
60 
61  PINOCCHIO_OVERLOAD_MATH_UNARY_OPERATOR(fabs)
62  PINOCCHIO_OVERLOAD_MATH_UNARY_OPERATOR(sqrt)
63  PINOCCHIO_OVERLOAD_MATH_UNARY_OPERATOR(atan)
64  PINOCCHIO_OVERLOAD_MATH_UNARY_OPERATOR(acos)
65  PINOCCHIO_OVERLOAD_MATH_UNARY_OPERATOR(asin)
66  PINOCCHIO_OVERLOAD_MATH_UNARY_OPERATOR(cos)
67  PINOCCHIO_OVERLOAD_MATH_UNARY_OPERATOR(sin)
68 
69  PINOCCHIO_OVERLOAD_MATH_BINARY_OPERATOR(pow)
70  PINOCCHIO_OVERLOAD_MATH_BINARY_OPERATOR(min)
71  PINOCCHIO_OVERLOAD_MATH_BINARY_OPERATOR(max)
72  PINOCCHIO_OVERLOAD_MATH_BINARY_OPERATOR(atan2)
73  }
74 }
75 
76 #endif //#ifndef __pinocchio_math_fwd_hpp__
pinocchio::PI
const Scalar PI()
Returns the value of PI according to the template parameters Scalar.
Definition: fwd.hpp:27
pinocchio::is_floating_point
Definition: fwd.hpp:17
pinocchio::TaylorSeriesExpansion
&#160;
Definition: fwd.hpp:31
pinocchio
Main pinocchio namespace.
Definition: treeview.dox:11