25 #ifndef INCLUDED_EigenExtras_h_GUID_7AE6CABA_333B_408A_C898_A2CBBE5BCE5D
26 #define INCLUDED_EigenExtras_h_GUID_7AE6CABA_333B_408A_C898_A2CBBE5BCE5D
35 #include <type_traits>
40 using ColMatrix44d = Eigen::Matrix4d;
41 using ColVector3d = Eigen::Vector3d;
42 using ColVector4d = Eigen::Vector4d;
43 using RowMatrix44d = Eigen::Matrix<double, 4, 4, Eigen::RowMajor>;
44 using Eigen::RowVector3d;
45 using Eigen::RowVector4d;
47 template <
typename Scalar>
48 using Isometry3 = Eigen::Transform<Scalar, 3, Eigen::Isometry>;
49 template <
typename Scalar>
50 using Translation3 = Eigen::Translation<Scalar, 3>;
53 template <
int Size,
typename PrototypeVector>
54 using SameLayoutVector =
56 PrototypeVector::IsRowMajor ? Size : 1,
57 PrototypeVector::IsRowMajor ? 1 : Size>;
62 template <
typename Derived>
63 inline detail::SameLayoutVector<4, Derived>
65 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Derived, 3);
66 return (detail::SameLayoutVector<4, Derived>() << vec, 1).finished();
71 template <
typename Derived>
72 inline detail::SameLayoutVector<4, Derived>
74 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Derived, 3);
75 return (detail::SameLayoutVector<4, Derived>() << vec, 0).finished();
80 template <
typename Derived>
81 inline detail::SameLayoutVector<3, Derived>
83 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Derived, 4);
84 return homogenous[3] == 0
85 ? homogenous.template head<3>().eval()
86 : (homogenous.template head<3>() / homogenous[3]).eval();
91 template <
typename Derived1,
typename Derived2>
92 inline Isometry3<typename Derived1::Scalar>
94 Eigen::RotationBase<Derived2, 3>
const &rotation) {
95 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Derived1, 3);
99 "Translation and rotation do not have the same scalar type.");
101 return Translation3<Scalar>(translation) * Isometry3<Scalar>(rotation);
104 inline Eigen::Quaterniond
105 flipQuatSignToMatch(Eigen::Quaterniond
const &refQ,
106 Eigen::Quaterniond
const &q) {
107 if (refQ.dot(q) < 0) {
108 return Eigen::Quaterniond(-q.coeffs());
117 #endif // INCLUDED_EigenExtras_h_GUID_7AE6CABA_333B_408A_C898_A2CBBE5BCE5D
The main namespace for all C++ elements of the framework, internal and external.
Header wrapping include of and for warning quieting.
detail::SameLayoutVector< 3, Derived > extractPoint(Eigen::MatrixBase< Derived > const &homogenous)
Pulls the 3D point or vector from a 4D vec, performing division by w if it is nonzero.
Isometry3< typename Derived1::Scalar > makeIsometry(Eigen::MatrixBase< Derived1 > const &translation, Eigen::RotationBase< Derived2, 3 > const &rotation)
A simpler, functional-style alternative to .fromPositionOrientationScale when no scaling is performed...
detail::SameLayoutVector< 4, Derived > makeHomogeneousPoint(Eigen::MatrixBase< Derived > const &vec)
Makes a 3D vector into a 4D homogeneous point, with the same options (scalar, row vs col vector) as t...
detail::SameLayoutVector< 4, Derived > makeHomogeneousVector(Eigen::MatrixBase< Derived > const &vec)
Makes a 3D vector into a 4D homogeneous vector, with the same options (scalar, row vs col vector) as ...
double Scalar
Common scalar type.
Eigen::Matrix< Scalar, m, n > Matrix
A matrix with rows = m, cols = n.