5#ifndef __pinocchio_spatial_skew_hpp__ 6#define __pinocchio_spatial_skew_hpp__ 8#include "pinocchio/macros.hpp" 21 template<
typename Vector3,
typename Matrix3>
22 inline void skew(
const Eigen::MatrixBase<Vector3> & v,
const Eigen::MatrixBase<Matrix3> & M)
24 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(
Vector3, 3);
25 EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(
Matrix3, 3, 3);
28 typedef typename Matrix3::RealScalar
Scalar;
50 inline Eigen::Matrix<
typename D::Scalar, 3, 3, PINOCCHIO_EIGEN_PLAIN_TYPE(D)::Options>
51 skew(const Eigen::MatrixBase<D> & v)
53 Eigen::Matrix<
typename D::Scalar, 3, 3, PINOCCHIO_EIGEN_PLAIN_TYPE(D)::Options> M;
66 template<
typename Vector3Like,
typename Matrix3Like>
68 addSkew(
const Eigen::MatrixBase<Vector3Like> & v,
const Eigen::MatrixBase<Matrix3Like> & M)
70 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Vector3Like, 3);
71 PINOCCHIO_ASSERT_MATRIX_SPECIFIC_SIZE(Matrix3Like, M, 3, 3);
73 Matrix3Like & M_ = PINOCCHIO_EIGEN_CONST_CAST(Matrix3Like, M);
92 template<
typename Matrix3,
typename Vector3>
93 inline void unSkew(
const Eigen::MatrixBase<Matrix3> & M,
const Eigen::MatrixBase<Vector3> & v)
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);
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));
115 template<
typename Matrix3>
116 inline Eigen::Matrix<
typename Matrix3::Scalar, 3, 1, PINOCCHIO_EIGEN_PLAIN_TYPE(Matrix3)::Options>
119 Eigen::Matrix<
typename Matrix3::Scalar, 3, 1, PINOCCHIO_EIGEN_PLAIN_TYPE(
Matrix3)::Options> v;
133 template<
typename Scalar,
typename Vector3,
typename Matrix3>
135 const Scalar alpha,
const Eigen::MatrixBase<Vector3> & v,
const Eigen::MatrixBase<Matrix3> & M)
137 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(
Vector3, 3);
138 EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(
Matrix3, 3, 3);
141 typedef typename Matrix3::RealScalar RealScalar;
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);
164 template<
typename Scalar,
typename Vector3>
165 inline Eigen::Matrix<
typename Vector3::Scalar, 3, 3, PINOCCHIO_EIGEN_PLAIN_TYPE(Vector3)::Options>
168 Eigen::Matrix<
typename Vector3::Scalar, 3, 3, PINOCCHIO_EIGEN_PLAIN_TYPE(
Vector3)::Options> M;
181 template<
typename V1,
typename V2,
typename Matrix3>
183 const Eigen::MatrixBase<V1> & u,
184 const Eigen::MatrixBase<V2> & v,
185 const Eigen::MatrixBase<Matrix3> & C)
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);
192 typedef typename Matrix3::RealScalar
Scalar;
194 C_.noalias() = v * u.transpose();
195 const Scalar udotv(u.dot(v));
196 C_.diagonal().array() -= udotv;
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)
213 Eigen::Matrix<
typename V1::Scalar, 3, 3, PINOCCHIO_EIGEN_PLAIN_TYPE(V1)::Options> M;
227 template<
typename Vector3,
typename Matrix3xIn,
typename Matrix3xOut>
229 const Eigen::MatrixBase<Vector3> & v,
230 const Eigen::MatrixBase<Matrix3xIn> & Min,
231 const Eigen::MatrixBase<Matrix3xOut> & Mout)
233 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(
Vector3, 3);
235 Matrix3xIn::RowsAtCompileTime == 3, THIS_METHOD_IS_ONLY_FOR_MATRICES_OF_A_SPECIFIC_SIZE);
237 Matrix3xOut::RowsAtCompileTime == 3, THIS_METHOD_IS_ONLY_FOR_MATRICES_OF_A_SPECIFIC_SIZE);
239 Matrix3xOut & Mout_ = PINOCCHIO_EIGEN_CONST_CAST(Matrix3xOut, Mout);
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);
254 template<
typename Vector3,
typename Matrix3x>
255 inline typename PINOCCHIO_EIGEN_PLAIN_TYPE(Matrix3x)
256 cross(const Eigen::MatrixBase<
Vector3> & v, const Eigen::MatrixBase<Matrix3x> & M)
258 typename PINOCCHIO_EIGEN_PLAIN_TYPE(Matrix3x) res(3, M.cols());
Main pinocchio namespace.
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,...
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...
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.
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...
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....
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...