libalmath  2.8.7.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
almathqigeometry.hpp
Go to the documentation of this file.
1 
10 #pragma once
11 #ifndef LIBALMATH_SCENEGRAPH_ALMATHQIGEOMETRY_HPP
12 #define LIBALMATH_SCENEGRAPH_ALMATHQIGEOMETRY_HPP
13 
17 
18 namespace AL
19 {
20 namespace Math
21 {
22 
23  inline Transform transformFromQiTransform(const qi::geometry::Transform& r)
24  {
25  Quaternion almathQuat(static_cast<float>(r.rotation.w),
26  static_cast<float>(r.rotation.x),
27  static_cast<float>(r.rotation.y),
28  static_cast<float>(r.rotation.z));
29  Transform almathTf = transformFromQuaternion(almathQuat);
30  almathTf.r1_c4 = static_cast<float>(r.translation.x);
31  almathTf.r2_c4 = static_cast<float>(r.translation.y);
32  almathTf.r3_c4 = static_cast<float>(r.translation.z);
33  return almathTf;
34  }
35 
36  inline qi::geometry::Transform qiTransformFromALMath(const Transform &tf)
37  {
38  Eigen::Map<const Matrix34frm> atfm (&tf.r1_c1);
39  qi::geometry::Transform result;
40  Eigen::Map<Eigen::Quaterniond>(&result.rotation.x) = atfm.block<3, 3>(0, 0).cast<double>();
41  Eigen::Map<Eigen::Vector3d>(&result.translation.x) = atfm.block<3, 1>(0, 3).cast<double>();
42  return result;
43  };
44 
45 
47  const qi::geometry::Transform& r)
48  {
50  }
51 
52  inline qi::geometry::Transform qiTransformFromPose2D(const Pose2D& pose)
53  {
55  pose.theta, 0.0f, 0.0f, 1.0f);
57  qi::geometry::makeQuaternion(quat.x, quat.y, quat.z, quat.w),
58  qi::geometry::makeVector3(pose.x, pose.y, 0.0f));
59  }
60 
61 }
62 }
63 #endif
Quaternion makeQuaternion(double x, double y, double z, double w)
Definition: qigeometry.h:29
ALMATH_API Pose2D pose2DFromTransform(const Transform &pT)
Create a Pose2D from a Transform.
Transform transformFromQiTransform(const qi::geometry::Transform &r)
Vector3 makeVector3(double x, double y, double z)
Definition: qigeometry.h:19
ALMATH_API Quaternion quaternionFromAngleAndAxisRotation(const float pAngle, const float pAxisX, const float pAxisY, const float pAxisZ)
Create a Quaternion initialized with explicit angle and axis rotation.
qi::geometry::Transform qiTransformFromALMath(const Transform &tf)
qi::geometry::Transform qiTransformFromPose2D(const Pose2D &pose)
AL::Math::Pose2D pose2DFromQiTransform(const qi::geometry::Transform &r)
ALMATH_API Transform transformFromQuaternion(const Quaternion &pQua)
A pose in a 2-dimentional space.
Definition: alpose2d.h:26
A homogenous transformation matrix.
Definition: altransform.h:23
Transform makeTransform(const Quaternion &rotation, const Vector3 &translation)
Definition: qigeometry.h:74
Create and play with a Quaternion.
Definition: alquaternion.h:24