给这段代码加上注释 //计算AGV矩形轮廓路径 计算角点:利用车头正方向的夹角差值计算车的四个角度 QPainterPath path; double carWidth =m_para.width; double carLength =m_para.length; double carAngle =m_attri->angle/100; double angle = atan((carWidth)/(carLength));//夹角差值 double length = sqrt(pow(carWidth,2)+pow(carLength,2))/2;//对角线长度的一半 //计算AGV外接矩形轮廓路径 /m_boundPath //矩形的四个顶点存储在m_agvRectPoints中,绘制AGV锁定区域需要用到m_agvRectPoints QPointF pointRT = calLinePath(path,length,carAnglePI/180+angle,true);//右上角 m_agvRectPoints[0]=pointRT; QPointF pointRB = calLinePath(path,length,carAnglePI/180-angle);//右下角--头 m_agvRectPoints[1]=pointRB; QPointF pointLB = calLinePath(path,length,carAnglePI/180+angle+PI);//左下角--尾 m_agvRectPoints[2]=pointLB; QPointF pointLT = calLinePath(path,length,carAnglePI/180-angle+PI);//左上角--尾 m_agvRectPoints[3]=pointLT; path.closeSubpath(); m_path = path; //计算AGV锁定矩形轮廓路径 /m_trackPath QPainterPath trackPath; double tracklength = sqrt(pow(carWidth+carWidth/2.0,2)+pow(carLength+carLength/2.0,2))/2;//对角线长度的一半 //agv锁定矩形随agv旋转 --MYJ 2021.12.14 calLinePath(trackPath, tracklength, -(carAnglePI / 180 + angle), true);//右上角 calLinePath(trackPath, tracklength, -(carAnglePI / 180 - angle));//右下角--头 calLinePath(trackPath, tracklength, -(carAnglePI / 180 + angle + PI));//左下角--尾 calLinePath(trackPath, tracklength, -(carAnglePI / 180 - angle + PI));//左上角--尾 trackPath.closeSubpath(); m_boundaryPath = trackPath;
时间: 2024-01-22 19:01:57 浏览: 96
基于dijkstra算法的AGV路径规划和两车避让C++源码+项目说明+详细注释.zip
//计算AGV矩形轮廓路径
//计算角点:利用车头正方向的夹角差值计算车的四个角度
QPainterPath path; //定义画笔路径对象
double carWidth = m_para.width; //获取AGV宽度
double carLength = m_para.length; //获取AGV长度
double carAngle = m_attri->angle / 100; //获取AGV车头角度
double angle = atan((carWidth) / (carLength)); //计算夹角差值
double length = sqrt(pow(carWidth, 2) + pow(carLength, 2)) / 2; //计算对角线长度的一半
//计算AGV外接矩形轮廓路径 /m_boundPath
//矩形的四个顶点存储在m_agvRectPoints中,绘制AGV锁定区域需要用到m_agvRectPoints
QPointF pointRT = calLinePath(path, length, carAngle * PI / 180 + angle, true); //计算右上角点
m_agvRectPoints[0] = pointRT; //存储右上角点
QPointF pointRB = calLinePath(path, length, carAngle * PI / 180 - angle); //计算右下角点(车头)
m_agvRectPoints[1] = pointRB; //存储右下角点(车头)
QPointF pointLB = calLinePath(path, length, carAngle * PI / 180 + angle + PI); //计算左下角点(车尾)
m_agvRectPoints[2] = pointLB; //存储左下角点(车尾)
QPointF pointLT = calLinePath(path, length, carAngle * PI / 180 - angle + PI); //计算左上角点(车尾)
m_agvRectPoints[3] = pointLT; //存储左上角点(车尾)
path.closeSubpath(); //闭合路径
m_path = path; //存储路径
//计算AGV锁定矩形轮廓路径 /m_trackPath
QPainterPath trackPath; //定义画笔路径对象
double tracklength = sqrt(pow(carWidth + carWidth / 2.0, 2) + pow(carLength + carLength / 2.0, 2)) / 2; //计算对角线长度的一半
//agv锁定矩形随agv旋转 --MYJ 2021.12.14
calLinePath(trackPath, tracklength, -(carAngle * PI / 180 + angle), true); //计算右上角点
calLinePath(trackPath, tracklength, -(carAngle * PI / 180 - angle)); //计算右下角点(车头)
calLinePath(trackPath, tracklength, -(carAngle * PI / 180 + angle + PI)); //计算左下角点(车尾)
calLinePath(trackPath, tracklength, -(carAngle * PI / 180 - angle + PI)); //计算左上角点(车尾)
trackPath.closeSubpath(); //闭合路径
m_boundaryPath = trackPath; //存储路径
阅读全文