1 #ifndef __TRANSFORM_UTILS__
2 #define __TRANSFORM_UTILS__
42 #include <Eigen/Dense>
55 void getPoseFromMatrix(BaseVector<T>& position, BaseVector<T>& angles,
const Transform<T>& mat);
93 const T& sx,
const T& sy,
const T& sz,
94 const unsigned char& xPos,
95 const unsigned char& yPos,
96 const unsigned char& zPos);
129 Transform<T>
transformFrame(
const Transform<T>& frame,
const CoordinateTransform<T>& ct);
151 Transform<T>
poseToMatrix(
const Vector3<T>& position,
const Vector3<T>& rotation);
161 void matrixToPose(
const Transform<T>& mat, Vector3<T>& position, Vector3<T>& rotation);
171 template <
typename T>
188 ret(12) = -100*in(7);
189 ret(13) = 100*in(11);
204 template <
typename T>
212 ret(3) = in(14)/100.0;
216 ret(7) = -in(12)/100.0;
220 ret(11) = in(13)/100.0;
229 template <
typename T>
233 in.coeff(2) /
static_cast<T
>(100.0),
234 - in.coeff(0) /
static_cast<T
>(100.0),
235 in.coeff(1) /
static_cast<T
>(100.0)
272 template <
typename T>
276 in.coeff(2) /
static_cast<T
>(100.0),
277 - in.coeff(0) /
static_cast<T
>(100.0),
278 in.coeff(1) /
static_cast<T
>(100.0)
301 ret.coeffRef(0, 0) = in.coeff(2, 2);
302 ret.coeffRef(1, 0) = -in.coeff(0, 2);
303 ret.coeffRef(2, 0) = in.coeff(1, 2);
304 ret.coeffRef(0, 1) = -in.coeff(2, 0);
305 ret.coeffRef(1, 1) = in.coeff(0, 0);
306 ret.coeffRef(2, 1) = -in.coeff(1, 0);
307 ret.coeffRef(0, 2) = in.coeff(2, 1);
308 ret.coeffRef(1, 2) = -in.coeff(0, 1);
309 ret.coeffRef(2, 2) = in.coeff(1, 1);
314 template <
typename T>
324 ret.coeffRef(0, 3) = in.coeff(2, 3)/
static_cast<T
>(100.0);
325 ret.coeffRef(1, 3) = -in.coeff(0, 3)/
static_cast<T
>(100.0);
326 ret.coeffRef(2, 3) = in.coeff(1, 3)/
static_cast<T
>(100.0);
327 ret.coeffRef(3, 0) = in.coeff(3, 2)/
static_cast<T
>(100.0);
328 ret.coeffRef(3, 1) = -in.coeff(3, 0)/
static_cast<T
>(100.0);
329 ret.coeffRef(3, 2) = in.coeff(3, 1)/
static_cast<T
>(100.0);
330 ret.coeffRef(3, 3) = in.coeff(3, 3);
363 template <
typename T>
373 template <
typename T>
378 ret.coeffRef(0,0) = in.coeff(2,2);
379 ret.coeffRef(0,1) = -in.coeff(2,0);
380 ret.coeffRef(0,2) = -in.coeff(2,1);
381 ret.coeffRef(1,0) = -in.coeff(0,2);
382 ret.coeffRef(1,1) = in.coeff(0,0);
383 ret.coeffRef(1,2) = in.coeff(0,1);
384 ret.coeffRef(2,0) = -in.coeff(1,2);
385 ret.coeffRef(2,1) = in.coeff(1,0);
386 ret.coeffRef(2,2) = in.coeff(1,1);
391 template <
typename T>
399 ret.coeffRef(0,3) = in.coeff(2,3);
400 ret.coeffRef(1,3) = -in.coeff(0,3);
401 ret.coeffRef(2,3) = -in.coeff(1,3);
403 ret.coeffRef(3,0) = in.coeff(3,2);
404 ret.coeffRef(3,1) = -in.coeff(3,0);
405 ret.coeffRef(3,2) = -in.coeff(3,1);
407 ret.coeffRef(3,3) = in.coeff(3,3);
443 template <
typename T>
447 -in.coeff(1) *
static_cast<T
>(100.0),
448 in.coeff(2) *
static_cast<T
>(100.0),
449 in.coeff(0) *
static_cast<T
>(100.0)
472 ret.coeffRef(0, 0) = in.coeff(1, 1);
473 ret.coeffRef(1, 0) = -in.coeff(2, 1);
474 ret.coeffRef(2, 0) = -in.coeff(0, 1);
475 ret.coeffRef(0, 1) = -in.coeff(1, 2);
476 ret.coeffRef(1, 1) = in.coeff(2, 2);
477 ret.coeffRef(2, 1) = in.coeff(0, 2);
478 ret.coeffRef(0, 2) = -in.coeff(1, 0);
479 ret.coeffRef(1, 2) = in.coeff(2, 0);
480 ret.coeffRef(2, 2) = in.coeff(0, 0);
485 template <
typename T>
495 ret.coeffRef(0, 3) = -
static_cast<T
>(100.0) * in.coeff(1, 3);
496 ret.coeffRef(1, 3) =
static_cast<T
>(100.0) * in.coeff(2, 3);
497 ret.coeffRef(2, 3) =
static_cast<T
>(100.0) * in.coeff(0, 3);
498 ret.coeffRef(3, 0) = -
static_cast<T
>(100.0) * in.coeff(3, 1);
499 ret.coeffRef(3, 1) =
static_cast<T
>(100.0) * in.coeff(3, 2);
500 ret.coeffRef(3, 2) =
static_cast<T
>(100.0) * in.coeff(3, 0);
502 ret.coeffRef(3, 3) = in.coeff(3, 3);
537 template <
typename T>
547 template <
typename T>
552 ret.coeffRef(0,0) = in.coeff(1,1);
553 ret.coeffRef(0,1) = in.coeff(1,2);
554 ret.coeffRef(0,2) = -in.coeff(1,0);
555 ret.coeffRef(1,0) = in.coeff(2,1);
556 ret.coeffRef(1,1) = in.coeff(2,2);
557 ret.coeffRef(1,2) = -in.coeff(2,0);
558 ret.coeffRef(2,0) = -in.coeff(0,1);
559 ret.coeffRef(2,1) = -in.coeff(0,2);
560 ret.coeffRef(2,2) = in.coeff(0,0);
565 template <
typename T>
573 ret.coeffRef(0,3) = -in.coeff(1,3);
574 ret.coeffRef(1,3) = -in.coeff(2,3);
575 ret.coeffRef(2,3) = in.coeff(0,3);
577 ret.coeffRef(3,0) = -in.coeff(3,1);
578 ret.coeffRef(3,1) = -in.coeff(3,2);
579 ret.coeffRef(3,2) = in.coeff(3,0);
581 ret.coeffRef(3,3) = in.coeff(3,3);
595 pose[4] = asin(m[8]);
599 pose[4] = (float)
M_PI - asin(m[8]);
603 float C = cos(pose[4]);
608 pose[3] = atan2(_trY, _trX);
611 pose[5] = atan2(_trY, _trX);
618 pose[5] = atan2(_trY, _trX);
638 pose[4] = asin(m[8]);
642 pose[4] = (float)
M_PI - asin(m[8]);
646 float C = cos(pose[4]);
651 pose[3] = atan2(_trY, _trX);
654 pose[5] = atan2(_trY, _trX);
661 pose[5] = atan2(_trY, _trX);
676 #include "TransformUtils.tcc"