skew.hpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2015-2021 CNRS INRIA
3 //
4 
5 #ifndef __pinocchio_spatial_skew_hpp__
6 #define __pinocchio_spatial_skew_hpp__
7 
8 #include "pinocchio/macros.hpp"
9 
10 namespace pinocchio
11 {
12 
21  template<typename Vector3, typename Matrix3>
22  inline void skew(const Eigen::MatrixBase<Vector3> & v, const Eigen::MatrixBase<Matrix3> & M)
23  {
24  EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Vector3, 3);
25  EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(Matrix3, 3, 3);
26 
27  Matrix3 & M_ = PINOCCHIO_EIGEN_CONST_CAST(Matrix3, M);
28  typedef typename Matrix3::RealScalar Scalar;
29 
30  M_(0, 0) = Scalar(0);
31  M_(0, 1) = -v[2];
32  M_(0, 2) = v[1];
33  M_(1, 0) = v[2];
34  M_(1, 1) = Scalar(0);
35  M_(1, 2) = -v[0];
36  M_(2, 0) = -v[1];
37  M_(2, 1) = v[0];
38  M_(2, 2) = Scalar(0);
39  }
40 
49  template<typename D>
50  inline Eigen::Matrix<typename D::Scalar, 3, 3, PINOCCHIO_EIGEN_PLAIN_TYPE(D)::Options>
51  skew(const Eigen::MatrixBase<D> & v)
52  {
53  Eigen::Matrix<typename D::Scalar, 3, 3, PINOCCHIO_EIGEN_PLAIN_TYPE(D)::Options> M;
54  skew(v, M);
55  return M;
56  }
57 
66  template<typename Vector3Like, typename Matrix3Like>
67  inline void
68  addSkew(const Eigen::MatrixBase<Vector3Like> & v, const Eigen::MatrixBase<Matrix3Like> & M)
69  {
70  EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Vector3Like, 3);
71  PINOCCHIO_ASSERT_MATRIX_SPECIFIC_SIZE(Matrix3Like, M, 3, 3);
72 
73  Matrix3Like & M_ = PINOCCHIO_EIGEN_CONST_CAST(Matrix3Like, M);
74 
75  M_(0, 1) -= v[2];
76  M_(0, 2) += v[1];
77  M_(1, 0) += v[2];
78  M_(1, 2) -= v[0];
79  M_(2, 0) -= v[1];
80  M_(2, 1) += v[0];
81  ;
82  }
83 
92  template<typename Matrix3, typename Vector3>
93  inline void unSkew(const Eigen::MatrixBase<Matrix3> & M, const Eigen::MatrixBase<Vector3> & v)
94  {
95  typedef typename Vector3::RealScalar Scalar;
96  EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Vector3, 3);
97  EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(Matrix3, 3, 3);
98 
100 
101  v_[0] = Scalar(0.5) * (M(2, 1) - M(1, 2));
102  v_[1] = Scalar(0.5) * (M(0, 2) - M(2, 0));
103  v_[2] = Scalar(0.5) * (M(1, 0) - M(0, 1));
104  }
105 
115  template<typename Matrix3>
116  inline Eigen::Matrix<typename Matrix3::Scalar, 3, 1, PINOCCHIO_EIGEN_PLAIN_TYPE(Matrix3)::Options>
117  unSkew(const Eigen::MatrixBase<Matrix3> & M)
118  {
119  Eigen::Matrix<typename Matrix3::Scalar, 3, 1, PINOCCHIO_EIGEN_PLAIN_TYPE(Matrix3)::Options> v;
120  unSkew(M, v);
121  return v;
122  }
123 
133  template<typename Scalar, typename Vector3, typename Matrix3>
134  void alphaSkew(
135  const Scalar alpha, const Eigen::MatrixBase<Vector3> & v, const Eigen::MatrixBase<Matrix3> & M)
136  {
137  EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Vector3, 3);
138  EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(Matrix3, 3, 3);
139 
140  Matrix3 & M_ = PINOCCHIO_EIGEN_CONST_CAST(Matrix3, M);
141  typedef typename Matrix3::RealScalar RealScalar;
142 
143  M_(0, 0) = RealScalar(0);
144  M_(0, 1) = -v[2] * alpha;
145  M_(0, 2) = v[1] * alpha;
146  M_(1, 0) = -M_(0, 1);
147  M_(1, 1) = RealScalar(0);
148  M_(1, 2) = -v[0] * alpha;
149  M_(2, 0) = -M_(0, 2);
150  M_(2, 1) = -M_(1, 2);
151  M_(2, 2) = RealScalar(0);
152  }
153 
164  template<typename Scalar, typename Vector3>
165  inline Eigen::Matrix<typename Vector3::Scalar, 3, 3, PINOCCHIO_EIGEN_PLAIN_TYPE(Vector3)::Options>
166  alphaSkew(const Scalar alpha, const Eigen::MatrixBase<Vector3> & v)
167  {
168  Eigen::Matrix<typename Vector3::Scalar, 3, 3, PINOCCHIO_EIGEN_PLAIN_TYPE(Vector3)::Options> M;
169  alphaSkew(alpha, v, M);
170  return M;
171  }
172 
181  template<typename V1, typename V2, typename Matrix3>
182  inline void skewSquare(
183  const Eigen::MatrixBase<V1> & u,
184  const Eigen::MatrixBase<V2> & v,
185  const Eigen::MatrixBase<Matrix3> & C)
186  {
187  EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(V1, 3);
188  EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(V2, 3);
189  EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(Matrix3, 3, 3);
190 
191  Matrix3 & C_ = PINOCCHIO_EIGEN_CONST_CAST(Matrix3, C);
192  typedef typename Matrix3::RealScalar Scalar;
193 
194  C_.noalias() = v * u.transpose();
195  const Scalar udotv(u.dot(v));
196  C_.diagonal().array() -= udotv;
197  }
198 
208  template<typename V1, typename V2>
209  inline Eigen::Matrix<typename V1::Scalar, 3, 3, PINOCCHIO_EIGEN_PLAIN_TYPE(V1)::Options>
210  skewSquare(const Eigen::MatrixBase<V1> & u, const Eigen::MatrixBase<V2> & v)
211  {
212 
213  Eigen::Matrix<typename V1::Scalar, 3, 3, PINOCCHIO_EIGEN_PLAIN_TYPE(V1)::Options> M;
214  skewSquare(u, v, M);
215  return M;
216  }
217 
227  template<typename Vector3, typename Matrix3xIn, typename Matrix3xOut>
228  inline void cross(
229  const Eigen::MatrixBase<Vector3> & v,
230  const Eigen::MatrixBase<Matrix3xIn> & Min,
231  const Eigen::MatrixBase<Matrix3xOut> & Mout)
232  {
233  EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Vector3, 3);
234  EIGEN_STATIC_ASSERT(
235  Matrix3xIn::RowsAtCompileTime == 3, THIS_METHOD_IS_ONLY_FOR_MATRICES_OF_A_SPECIFIC_SIZE);
236  EIGEN_STATIC_ASSERT(
237  Matrix3xOut::RowsAtCompileTime == 3, THIS_METHOD_IS_ONLY_FOR_MATRICES_OF_A_SPECIFIC_SIZE);
238 
239  Matrix3xOut & Mout_ = PINOCCHIO_EIGEN_CONST_CAST(Matrix3xOut, Mout);
240 
241  Mout_.row(0) = v[1] * Min.row(2) - v[2] * Min.row(1);
242  Mout_.row(1) = v[2] * Min.row(0) - v[0] * Min.row(2);
243  Mout_.row(2) = v[0] * Min.row(1) - v[1] * Min.row(0);
244  }
245 
254  template<typename Vector3, typename Matrix3x>
256  cross(const Eigen::MatrixBase<Vector3> & v, const Eigen::MatrixBase<Matrix3x> & M)
257  {
258  typename PINOCCHIO_EIGEN_PLAIN_TYPE(Matrix3x) res(3, M.cols());
259  cross(v, M, res);
260  return res;
261  }
262 
263 } // namespace pinocchio
264 
265 #endif // ifndef __pinocchio_spatial_skew_hpp__
V1
Eigen
pinocchio::u
JointCollectionTpl const Eigen::MatrixBase< ConfigVectorIn1 > const Eigen::MatrixBase< ConfigVectorIn2 > const Scalar & u
Definition: joint-configuration.hpp:1139
macros.hpp
pinocchio::Options
Options
Definition: joint-configuration.hpp:1082
PINOCCHIO_EIGEN_CONST_CAST
#define PINOCCHIO_EIGEN_CONST_CAST(TYPE, OBJ)
Macro for an automatic const_cast.
Definition: eigen-macros.hpp:51
pinocchio::python::Scalar
context::Scalar Scalar
Definition: admm-solver.cpp:29
pinocchio::res
ReturnType res
Definition: spatial/classic-acceleration.hpp:57
dcrba.C
C
Definition: dcrba.py:491
reachable-workspace-with-collisions.alpha
float alpha
Definition: reachable-workspace-with-collisions.py:162
pinocchio::skew
void skew(const Eigen::MatrixBase< Vector3 > &v, const Eigen::MatrixBase< Matrix3 > &M)
Computes the skew representation of a given 3d vector, i.e. the antisymmetric matrix representation o...
Definition: skew.hpp:22
D
D
M
M
pinocchio::context::Vector3
Eigen::Matrix< Scalar, 3, 1, Options > Vector3
Definition: context/generic.hpp:53
pinocchio::skewSquare
void skewSquare(const Eigen::MatrixBase< V1 > &u, const Eigen::MatrixBase< V2 > &v, const Eigen::MatrixBase< Matrix3 > &C)
Computes the square cross product linear operator C(u,v) such that for any vector w,...
Definition: skew.hpp:182
pinocchio::v
JointCollectionTpl const Eigen::MatrixBase< ConfigVectorType > const Eigen::MatrixBase< TangentVectorType > & v
Definition: joint-configuration.hpp:1084
pinocchio::cross
void cross(const Eigen::MatrixBase< Vector3 > &v, const Eigen::MatrixBase< Matrix3xIn > &Min, const Eigen::MatrixBase< Matrix3xOut > &Mout)
Applies the cross product onto the columns of M.
Definition: skew.hpp:228
pinocchio::PINOCCHIO_EIGEN_PLAIN_TYPE
PINOCCHIO_EIGEN_PLAIN_TYPE(ConfigVectorType) integrate(const ModelTpl< Scalar
Integrate a configuration vector for the specified model for a tangent vector during one unit time.
PINOCCHIO_ASSERT_MATRIX_SPECIFIC_SIZE
#define PINOCCHIO_ASSERT_MATRIX_SPECIFIC_SIZE(type, M, nrows, ncols)
Ensure that a matrix (or vector) is of correct size (compile-time and run-time assertion)
Definition: include/pinocchio/macros.hpp:75
pinocchio::alphaSkew
void alphaSkew(const Scalar alpha, const Eigen::MatrixBase< Vector3 > &v, const Eigen::MatrixBase< Matrix3 > &M)
Computes the skew representation of a given 3d vector multiplied by a given scalar....
Definition: skew.hpp:134
pinocchio::unSkew
void unSkew(const Eigen::MatrixBase< Matrix3 > &M, const Eigen::MatrixBase< Vector3 > &v)
Inverse of skew operator. From a given skew-symmetric matrix M of dimension 3x3, it extracts the supp...
Definition: skew.hpp:93
pinocchio::context::Matrix3x
Eigen::Matrix< Scalar, 3, Eigen::Dynamic, Options > Matrix3x
Definition: context/generic.hpp:52
pinocchio::addSkew
void addSkew(const Eigen::MatrixBase< Vector3Like > &v, const Eigen::MatrixBase< Matrix3Like > &M)
Add skew matrix represented by a 3d vector to a given matrix, i.e. add the antisymmetric matrix repre...
Definition: skew.hpp:68
pinocchio
Main pinocchio namespace.
Definition: timings.cpp:27


pinocchio
Author(s):
autogenerated on Fri Nov 1 2024 02:41:48