本文整理汇总了C++中QVec::normalize方法的典型用法代码示例。如果您正苦于以下问题:C++ QVec::normalize方法的具体用法?C++ QVec::normalize怎么用?C++ QVec::normalize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QVec
的用法示例。
在下文中一共展示了QVec::normalize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: checkFreeWay
bool SpecificWorker::checkFreeWay( const QVec &targetInRobot)
{
qDebug() << __FUNCTION__ ;
//First turn the robot to point towards the new target
if (alignToTarget( targetInRobot ) != true )
{
stopAction();
qFatal("Could not align the robot");
}
QList<QVec> lPoints;
//points on the corners of thw square
lPoints.append( QVec::vec3(ROBOT_RADIUS,0,ROBOT_RADIUS));
lPoints.append( QVec::vec3(ROBOT_RADIUS,0,-ROBOT_RADIUS));
lPoints.append( QVec::vec3(-ROBOT_RADIUS,0,-ROBOT_RADIUS));
lPoints.append( QVec::vec3(-ROBOT_RADIUS,0,ROBOT_RADIUS));
//points on the sides
lPoints.append( QVec::vec3(ROBOT_RADIUS,0,0));
lPoints.append( QVec::vec3(0,0,-ROBOT_RADIUS));
lPoints.append( QVec::vec3(-ROBOT_RADIUS,0,0));
lPoints.append( QVec::vec3(0,0, ROBOT_RADIUS));
float dist = targetInRobot.norm2();
float alpha =atan2(targetInRobot.x(), targetInRobot.z() );
float step = ceil(dist/ (ROBOT_SIZE/3));
QVec tNorm = targetInRobot.normalize();
QVec r;
inner->updateTransformValues ("vbox",0, 0, 0, 0, 0, 0, "robot");
for(size_t i = 0; i<ldata.size(); i++)
{
if(ldata[i].angle <= alpha)
{
for(float landa=400; landa<=dist; landa+=step)
{
r = tNorm * landa;
inner->updateTransformValues ("vbox",r.x(), r.y(), r.z(), 0, alpha, 0, "robot");
foreach(QVec p, lPoints)
{
QVec pointInRobot = inner->transform("robot", p, "vbox");
float dPR = pointInRobot.norm2();
float alphaPR = atan2(pointInRobot.x(), pointInRobot.z());
for(auto ld : ldata)
if(ld.angle <= alphaPR)
{
if( ld.dist>0 and ld.dist < LASER_MAX and ld.dist >= dPR)
{
//qDebug()<<__FUNCTION__<< "Hay camino libre al target" << ldata[i].dist << d;
break;
}
else
{
qDebug() << "collision of point(R) " << inner->transform("robot", p, "vbox");
return false;
}
}
}
}
qDebug()<<__FUNCTION__<< "Hay camino libre al target. Laser distance:" << ldata[i].dist << ". Target distance:" << dist;
break; //We found the laser ray aligned with the target.
}
}