Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <OpenKarto/Geometry.h>
00023 #include <OpenKarto/RigidBodyTransform.h>
00024
00025 using namespace karto;
00026
00027 RigidBodyTransform::RigidBodyTransform(const karto::Pose2& rPose)
00028 {
00029 SetTransform(karto::Pose2(), rPose);
00030 }
00031
00032 RigidBodyTransform::RigidBodyTransform(const karto::Pose2& rPose1, const karto::Pose2& rPose2)
00033 {
00034 SetTransform(rPose1, rPose2);
00035 }
00036
00037 void RigidBodyTransform::SetTransform(const karto::Pose2& rPose1, const karto::Pose2& rPose2)
00038 {
00039 m_Transform = rPose2;
00040 m_Transform.SetX(m_Transform.GetX() - rPose1.GetX());
00041 m_Transform.SetY(m_Transform.GetY() - rPose1.GetY());
00042
00043 karto::Matrix3 rotation;
00044 rotation.FromAxisAngle(0, 0, 1, -rPose1.GetHeading());
00045 m_Transform = rotation * m_Transform;
00046 m_Transform.SetHeading(m_Transform.GetHeading() - rPose1.GetHeading());
00047
00048 m_InvTransform = rPose1;
00049 m_InvTransform.SetX(m_InvTransform.GetX() - rPose2.GetX());
00050 m_InvTransform.SetY(m_InvTransform.GetY() - rPose2.GetY());
00051
00052 karto::Matrix3 invRotation;
00053 invRotation.FromAxisAngle(0, 0, 1, -rPose2.GetHeading());
00054 m_InvTransform = invRotation * m_InvTransform;
00055 m_InvTransform.SetHeading(m_InvTransform.GetHeading() - rPose2.GetHeading());
00056 }
00057
00058 karto::Pose2 RigidBodyTransform::TransformPose(const karto::Pose2& rSourcePose)
00059 {
00060 karto::Matrix3 rotation;
00061 rotation.FromAxisAngle(0, 0, 1, rSourcePose.GetHeading());
00062 karto::Pose2 newPose = rotation * m_Transform;
00063 newPose += rSourcePose;
00064
00065 return newPose;
00066 }
00067
00068 karto::Pose2 RigidBodyTransform::InverseTransformPose(const karto::Pose2& rSourcePose)
00069 {
00070 karto::Matrix3 rotation;
00071 rotation.FromAxisAngle(0, 0, 1, rSourcePose.GetHeading());
00072 karto::Pose2 newPose = rotation * m_InvTransform;
00073 newPose += rSourcePose;
00074
00075 return newPose;
00076 }