pinocchio  3.3.1
A fast and flexible implementation of Rigid Body Dynamics algorithms and their analytical derivatives
fwd.hpp
1 //
2 // Copyright (c) 2016-2024 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  {
29  return boost::math::constants::pi<Scalar>();
30  }
31 
33  template<typename Scalar>
34  struct TaylorSeriesExpansion;
35 
36  namespace math
37  {
38 
39 #define PINOCCHIO_OVERLOAD_MATH_UNARY_OPERATOR(name) \
40  template<typename Scalar> \
41  Scalar name(const Scalar & value) \
42  { \
43  using std::name; \
44  return name(value); \
45  }
46 
47 #define PINOCCHIO_OVERLOAD_MATH_BINARY_OPERATOR(name) \
48  namespace internal \
49  { \
50  template<typename T1, typename T2> \
51  struct return_type_##name \
52  { \
53  typedef T1 type; \
54  }; \
55  template<typename T1, typename T2> \
56  struct call_##name \
57  { \
58  static inline typename return_type_##name<T1, T2>::type run(const T1 & a, const T2 & b) \
59  { \
60  using std::name; \
61  return name(a, b); \
62  } \
63  }; \
64  } \
65  template<typename T1, typename T2> \
66  inline typename internal::return_type_##name<T1, T2>::type name(const T1 & a, const T2 & b) \
67  { \
68  return internal::call_##name<T1, T2>::run(a, b); \
69  }
70 
71  PINOCCHIO_OVERLOAD_MATH_UNARY_OPERATOR(fabs)
72  PINOCCHIO_OVERLOAD_MATH_UNARY_OPERATOR(sqrt)
73  PINOCCHIO_OVERLOAD_MATH_UNARY_OPERATOR(atan)
74  PINOCCHIO_OVERLOAD_MATH_UNARY_OPERATOR(acos)
75  PINOCCHIO_OVERLOAD_MATH_UNARY_OPERATOR(asin)
76  PINOCCHIO_OVERLOAD_MATH_UNARY_OPERATOR(cos)
77  PINOCCHIO_OVERLOAD_MATH_UNARY_OPERATOR(sin)
78  PINOCCHIO_OVERLOAD_MATH_UNARY_OPERATOR(log)
79  PINOCCHIO_OVERLOAD_MATH_UNARY_OPERATOR(exp)
80 
81  PINOCCHIO_OVERLOAD_MATH_BINARY_OPERATOR(pow)
82  PINOCCHIO_OVERLOAD_MATH_BINARY_OPERATOR(min)
83  PINOCCHIO_OVERLOAD_MATH_BINARY_OPERATOR(max)
84  PINOCCHIO_OVERLOAD_MATH_BINARY_OPERATOR(atan2)
85  } // namespace math
86 } // namespace pinocchio
87 
88 #endif // #ifndef __pinocchio_math_fwd_hpp__
Main pinocchio namespace.
Definition: treeview.dox:11
const Scalar PI()
Returns the value of PI according to the template parameters Scalar.
Definition: fwd.hpp:27