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" Eigen::Matrix< T, 3, 3 > Rotation
General 3x3 rotation matrix.
void matrixToPose(const Transform< T > &mat, Vector3< T > &position, Vector3< T > &rotation)
Extracts the Pose from a Matrix.
void extrinsicsToEuler(Extrinsics< T > mat, T *pose)
void getPoseFromMatrix(BaseVector< T > &position, BaseVector< T > &angles, const Transform< T > &mat)
Computes a Euler representation from the given transformation matrix.
void eigenToEuler(Transform< T > &mat, T *pose)
static Vector3< T > lvrToOpenCv(const Vector3< T > &in)
Lvr to OpenCV coordinate change: Point.
void transformAndReducePointCloud(ModelPtr model, int modulo, const T &sx, const T &sy, const T &sz, const unsigned char &xPos, const unsigned char &yPos, const unsigned char &zPos)
Transforms (scale and switch coordinates) and reduces a model containing point cloud data using a mod...
Transform< T > poseToMatrix(const Vector3< T > &position, const Vector3< T > &rotation)
Converts a Pose to a Matrix.
Transform< T > transformFrame(const Transform< T > &frame, const CoordinateTransform< T > &ct)
Transforms the given source frame according to the given coordinate transform struct.
Transform< T > transformRegistration(const Transform< T > &transform, const Transform< T > ®istration)
Transforms a registration matrix according to the given transformation matrix, i.e., applies transform to registration.
void transformPointCloud(ModelPtr model, const Transform< T > &transformation)
Transforms a model containing a point cloud according to the given transformation (usually from a ...
Eigen::Matrix< T, 3, 1 > Vector3
Eigen 3D vector.
Transform< T > inverseTransform(const Transform< T > &transform)
Computes the inverse transformation from the given transformation matrix, which means if transform en...
static Vector3< T > openCvToLvr(const Vector3< T > &in)
OpenCV to Lvr coordinate change: Point.
static Vector3< T > lvrToSlam6d(const Vector3< T > &in)
Lvr to Slam6D coordinate change: Point.
static Transform< T > slam6dToRieglTransform(const Transform< T > &in)
Converts a transformation matrix that is used in slam6d coordinate system into a transformation matri...
std::shared_ptr< Model > ModelPtr
Transform< T > buildTransformation(T *alignxf)
Transforms an slam6d transformation matrix into an Eigen 4x4 matrix.
static Vector3< T > slam6dToLvr(const Vector3< T > &in)
Slam6D to LVR coordinate change: Point.
static Vector3< T > slam6DToRieglPoint(const Vector3< T > &in)
static Transform< T > rieglToSLAM6DTransform(const Transform< T > &in)
Converts a transformation matrix that is used in riegl coordinate system into a transformation matrix...
Eigen::Matrix< T, 4, 4 > Transform
General 4x4 transformation matrix (4x4)
Eigen::Matrix< T, 4, 4 > Extrinsics
4x4 extrinsic calibration