crossing_utils.cpp
Go to the documentation of this file.
00001 #include <lama_common/crossing_utils.h>
00002 
00003 namespace lama_common
00004 {
00005 
00008 void rotateCrossing(lama_msgs::Crossing& crossing, const double angle)
00009 {
00010   if ((crossing.center.x == 0) && (crossing.center.y == 0) && crossing.frontiers.empty())
00011   {
00012     return;
00013   }
00014 
00015   const double cosangle = std::cos(angle);
00016   const double sinangle = std::sin(angle);
00017 
00018   // Rotate crossing center.
00019   const double old_x = crossing.center.x;
00020   const double old_y = crossing.center.y;
00021   crossing.center.x = old_x * cosangle - old_y * sinangle;
00022   crossing.center.y = old_x * sinangle + old_y * cosangle;
00023 
00024   // Rotate frontier points and change frontier angles.
00025   typedef std::vector<lama_msgs::Frontier>::iterator frontier_it;
00026   for (frontier_it frontier = crossing.frontiers.begin(); frontier != crossing.frontiers.end(); ++frontier)
00027   {
00028     frontier->angle = angles::normalize_angle(frontier->angle + angle);
00029     double old_x = frontier->p1.x;
00030     double old_y = frontier->p1.y;
00031     frontier->p1.x = old_x * cosangle - old_y * sinangle;
00032     frontier->p1.y = old_x * sinangle + old_y * cosangle;
00033     old_x = frontier->p2.x;
00034     old_y = frontier->p2.y;
00035     frontier->p2.x = old_x * cosangle - old_y * sinangle;
00036     frontier->p2.y = old_x * sinangle + old_y * cosangle;
00037   }
00038 }
00039 
00040 } // namespace lama_common


lama_common
Author(s): Gaël Ecorchard , Karel Košnar , Vojtěch Vonásek
autogenerated on Thu Jun 6 2019 22:02:03