14 #ifndef ECL_GEOMETRY_POSE3D_HPP_ 15 #define ECL_GEOMETRY_POSE3D_HPP_ 21 #include <ecl/linear_algebra.hpp> 23 #include <ecl/config/macros.hpp> 41 template <
class Float,
typename Enable =
void>
58 template<
typename Float>
64 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
70 typedef ecl::linear_algebra::Matrix<Float,3,3> RotationMatrix;
71 typedef ecl::linear_algebra::Matrix<Float,3,1> Translation;
79 Pose3D() : rot(RotationMatrix::
Identity()), trans(Translation::Zero()) {}
92 template<
typename Rot,
typename Trans>
94 Pose3D(
const ecl::linear_algebra::EigenBase<Rot>& rotation,
const ecl::linear_algebra::EigenBase<Trans>& translation) :
105 template <enum Pose2DStorageType Storage_>
108 trans(Translation::Zero())
110 rot.template block<2,2>(0,0) = pose.rotationMatrix();
111 trans.template segment<2>(0) = pose.translation();
121 template<
typename Trans>
122 Pose3D(
const ecl::linear_algebra::AngleAxis<Float>& angle_axis,
const ecl::linear_algebra::MatrixBase<Trans>& translation) :
124 trans(Translation::Zero())
135 template<
typename Trans>
136 Pose3D(
const ecl::linear_algebra::Quaternion<Float>& quaternion,
const ecl::linear_algebra::MatrixBase<Trans>& translation) :
137 rot(quaternion.toRotationMatrix()),
145 Pose3D(
const Pose3D<Float>& pose) :
146 rot(pose.rotation()),
147 trans(pose.translation())
160 template <enum Pose2DStorageType Storage_>
162 rot.template block<2,2>(0,0) = pose.rotationMatrix();
163 (rot.template block<2,1>(0,2)) << 0.0, 0.0;
164 (rot.template block<1,3>(2,0)) << 0.0, 0.0, 1.0;
165 trans.template segment<2>(0) = pose.translation();
175 Pose3D<Float>& operator=(
const Pose3D<Float>& pose) {
176 rot = pose.rotation();
177 trans = pose.translation();
190 void rotation(
const RotationMatrix &rotation) {
202 template <
typename Trans>
203 void translation(
const ecl::linear_algebra::MatrixBase<Trans>& translation) {
204 this->trans = translation;
216 RotationMatrix& rotation() {
return rot; }
217 Translation& translation() {
return trans; }
218 const RotationMatrix& rotation()
const {
return rot; }
219 const Translation& translation()
const {
return trans; }
227 RotationMatrix rotationMatrix()
const {
return rot; }
239 Pose3D<Float>
inverse()
const {
241 inverse.rotation(rot.transpose());
242 inverse.translation(-1*(inverse.rot*trans));
250 template <
typename Float_>
251 Pose3D<Float>
operator*(
const Pose3D<Float_> &pose)
const {
252 return Pose3D<Float>(rotation()*pose.rotation(),translation() + rotation()*pose.translation());
263 template <
typename Float_>
264 Pose3D<Float>&
operator*=(
const Pose3D<Float_> &pose) {
266 *
this = (*this)*pose;
277 template <
typename Float_>
278 Pose3D<Float> relative(
const Pose3D<Float_> &pose)
const {
279 return pose.inverse()*(*this);
287 template <
typename OutputStream,
typename Float_>
288 friend OutputStream& operator<<(OutputStream &ostream , const Pose3D<Float_> &pose);
307 template <
typename OutputStream,
typename Float_>
308 OutputStream& operator<<(OutputStream &ostream , const Pose3D<Float_> &pose) {
312 for (
unsigned int i = 0; i < 3; ++i ) {
314 for (
unsigned int j = 0; j < 3; ++j ) {
315 ostream << format(pose.rot(i,j)) <<
" ";
318 ostream << format(pose.trans(i)) <<
" ]\n";
TFSIMD_FORCE_INLINE Vector3 operator*(const Matrix3x3 &m, const Vector3 &v)
FloatingPoint< float > Float
TFSIMD_FORCE_INLINE Quaternion inverse(const Quaternion &q)
TFSIMD_FORCE_INLINE Vector3 & operator*=(const tfScalar &s)