// // Created by zx on 22-12-1. // #ifndef LIO_LIVOX_CPP_MPC_POSE2D_H_ #define LIO_LIVOX_CPP_MPC_POSE2D_H_ #include #include #include #include /* * 带direction的二维点,与x轴正方向逆时针为正方向 */ class Pose2d { public: Pose2d(); Pose2d(float x,float y,float theta); Pose2d(const Pose2d& point) { m_x=point.x(); m_y=point.y(); m_theta=point.theta(); } ~Pose2d(); Pose2d& operator=(const Pose2d& point) { m_x=point.x(); m_y=point.y(); m_theta=point.theta(); return *this; } /* * 两位姿相减,角度在-PI ,PI */ Pose2d operator-(const Pose2d& pose)const { float x=m_x-pose.x(); float y=m_y-pose.y(); float theta=m_theta-pose.theta(); if(theta<=-M_PI) theta+=2*M_PI; if(theta>M_PI) theta-=2*M_PI; return Pose2d(x,y,theta); } Pose2d operator+(const Pose2d& pose)const { float x=m_x+pose.x(); float y=m_y+pose.y(); float theta=m_theta+pose.theta(); //转换到 (-PI,PI),下 if(theta<=-M_PI) theta+=2*M_PI; if(theta>M_PI) theta-=2*M_PI; return Pose2d(x,y,theta); } static Pose2d abs(const Pose2d& pose) { Pose2d ret(fabs(pose.x()),fabs(pose.y()),fabs(pose.theta())); return ret; } bool operator<(const Pose2d& pose)const { return x() generate_rectangle_vertexs(const Pose2d& pose,float w,float h){ std::vector poses; //std::cout<<" obs:"<