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