18 #ifndef __se3_skew_hpp__ 19 #define __se3_skew_hpp__ 21 #include "pinocchio/macros.hpp" 33 template <
typename Vector3,
typename Matrix3>
34 inline void skew(
const Eigen::MatrixBase<Vector3> & v,
35 const Eigen::MatrixBase<Matrix3> & M)
37 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Vector3,3);
38 EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(Matrix3,3,3);
40 Matrix3 & M_ =
const_cast<Eigen::MatrixBase<Matrix3> &
>(M).derived();
41 typedef typename Matrix3::RealScalar Scalar;
43 M_(0,0) = Scalar(0); M_(0,1) = -v[2]; M_(0,2) = v[1];
44 M_(1,0) = v[2]; M_(1,1) = Scalar(0); M_(1,2) = -v[0];
45 M_(2,0) = -v[1]; M_(2,1) = v[0]; M_(2,2) = Scalar(0);
57 inline Eigen::Matrix<typename D::Scalar,3,3,EIGEN_PLAIN_TYPE(D)::Options>
58 skew(
const Eigen::MatrixBase<D> & v)
60 Eigen::Matrix<typename D::Scalar,3,3,EIGEN_PLAIN_TYPE(D)::Options> M;
73 template <
typename Matrix3,
typename Vector3>
74 inline void unSkew(
const Eigen::MatrixBase<Matrix3> & M,
75 const Eigen::MatrixBase<Vector3> & v)
77 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Vector3,3);
78 EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(Matrix3,3,3);
79 assert((M + M.transpose()).isMuchSmallerThan(M));
81 Vector3 & v_ =
const_cast<Eigen::MatrixBase<Vector3> &
>(v).derived();
82 typedef typename Vector3::RealScalar Scalar;
84 v_[0] = Scalar(0.5) * (M(2,1) - M(1,2));
85 v_[1] = Scalar(0.5) * (M(0,2) - M(2,0));
86 v_[2] = Scalar(0.5) * (M(1,0) - M(0,1));
98 template <
typename Matrix3>
99 inline Eigen::Matrix<typename EIGEN_PLAIN_TYPE(Matrix3)::Scalar,3,1,EIGEN_PLAIN_TYPE(Matrix3)::Options>
100 unSkew(
const Eigen::MatrixBase<Matrix3> & M)
102 Eigen::Matrix<typename EIGEN_PLAIN_TYPE(Matrix3)::Scalar,3,1,EIGEN_PLAIN_TYPE(Matrix3)::Options> v;
115 template <
typename Scalar,
typename Vector3,
typename Matrix3>
117 const Eigen::MatrixBase<Vector3> & v,
118 const Eigen::MatrixBase<Matrix3> & M)
120 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Vector3,3);
121 EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(Matrix3,3,3);
123 Matrix3 & M_ =
const_cast<Eigen::MatrixBase<Matrix3> &
>(M).derived();
124 typedef typename Matrix3::RealScalar RealScalar;
126 M_(0,0) = RealScalar(0); M_(0,1) = -v[2] * alpha; M_(0,2) = v[1] * alpha;
127 M_(1,0) = -M_(0,1); M_(1,1) = RealScalar(0); M_(1,2) = -v[0] * alpha;
128 M_(2,0) = -M_(0,2); M_(2,1) = -M_(1,2); M_(2,2) = RealScalar(0);
140 template <
typename Scalar,
typename Vector3>
141 inline Eigen::Matrix<typename Vector3::Scalar,3,3,EIGEN_PLAIN_TYPE(Vector3)::Options>
143 const Eigen::MatrixBase<Vector3> & v)
145 Eigen::Matrix<typename Vector3::Scalar,3,3,EIGEN_PLAIN_TYPE(Vector3)::Options> M;
157 template <
typename V1,
typename V2,
typename Matrix3>
159 const Eigen::MatrixBase<V2> & v,
160 const Eigen::MatrixBase<Matrix3> & C)
162 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(V1,3);
163 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(V2,3);
164 EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(Matrix3,3,3);
166 Matrix3 & C_ =
const_cast<Eigen::MatrixBase<Matrix3> &
>(C).derived();
167 typedef typename Matrix3::RealScalar Scalar;
169 C_.noalias() = v*u.transpose();
170 const Scalar udotv(u.dot(v));
171 C_.diagonal().array() -= udotv;
182 template <
typename V1,
typename V2>
183 inline Eigen::Matrix<typename V1::Scalar,3,3,EIGEN_PLAIN_TYPE(V1)::Options>
185 const Eigen::MatrixBase<V2> & v)
188 Eigen::Matrix<typename V1::Scalar,3,3,EIGEN_PLAIN_TYPE(V1)::Options> M;
202 template <
typename Vector3,
typename Matrix3xIn,
typename Matrix3xOut>
203 inline void cross(
const Eigen::MatrixBase<Vector3> & v,
204 const Eigen::MatrixBase<Matrix3xIn> & Min,
205 const Eigen::MatrixBase<Matrix3xOut> & Mout)
207 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Vector3,3);
208 EIGEN_STATIC_ASSERT(Matrix3xIn::RowsAtCompileTime==3,THIS_METHOD_IS_ONLY_FOR_MATRICES_OF_A_SPECIFIC_SIZE);
209 EIGEN_STATIC_ASSERT(Matrix3xOut::RowsAtCompileTime==3,THIS_METHOD_IS_ONLY_FOR_MATRICES_OF_A_SPECIFIC_SIZE);
211 Matrix3xOut & Mout_ =
const_cast<Eigen::MatrixBase<Matrix3xOut> &
>(Mout).derived();
213 Mout_.row(0) = v[1]*Min.row(2) - v[2]*Min.row(1);
214 Mout_.row(1) = v[2]*Min.row(0) - v[0]*Min.row(2);
215 Mout_.row(2) = v[0]*Min.row(1) - v[1]*Min.row(0);
226 template <
typename Vector3,
typename Matrix3x>
228 cross(const Eigen::MatrixBase<Vector3> & v,
229 const Eigen::MatrixBase<Matrix3x> & M)
238 #endif // ifndef __se3_skew_hpp__ EIGEN_PLAIN_TYPE(Matrix3x) cross(const Eigen
Applies the cross product onto the columns of M.
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 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. i.e. the antisymmetric matrix representation of the cross product operator ( )
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...
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 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.