本文整理汇总了C++中tf::Vector3::closestAxis方法的典型用法代码示例。如果您正苦于以下问题:C++ Vector3::closestAxis方法的具体用法?C++ Vector3::closestAxis怎么用?C++ Vector3::closestAxis使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tf::Vector3
的用法示例。
在下文中一共展示了Vector3::closestAxis方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
/**
* Return vector of two Vector3s that form a basis for the space orthogonal to the ray
*/
std::vector<tf::Vector3> RayTracePluginUtils::getOrthogonalBasis(tf::Vector3 ray)
{
// ROS_INFO("Orthogonal Parts of %f, %f, %f", ray.getX(), ray.getY(), ray.getZ());
ray.normalize();
std::vector<tf::Vector3> v;
//Initialize vector on the most orthogonal axis
switch(ray.closestAxis()){
case 0:
v.push_back(tf::Vector3(0,0,1));
v.push_back(tf::Vector3(0,1,0));
break;
case 1:
v.push_back(tf::Vector3(0,0,1));
v.push_back(tf::Vector3(1,0,0));
break;
case 2:
default:
v.push_back(tf::Vector3(0,1,0));
v.push_back(tf::Vector3(1,0,0));
break;
}
//Recover the pure orthogonal parts
for(int i = 0; i < 2; i++){
v[i] = (v[i] - ray * ray.dot(v[i])).normalize();
// ROS_INFO("%f, %f, %f", v[i].getX(), v[i].getY(), v[i].getZ());
}
return v;
}