#include<pcl/point_cloud.h>
#include<pcl/point_types.h>
#include<pcl/visualization/pcl_visualizer.h> //cout endl
#include <pcl/common/angles.h>
typedef pcl::PointXYZ PointT;
int main()
{
float a1 = pcl::rad2deg((float)M_PI / 2);
double a2 = pcl::rad2deg(M_PI / 2);
float b1 = pcl::deg2rad((float)90.0);
double b2 = pcl::deg2rad(90.0);
float c = pcl::normAngle(4);//将弧度归一化,输入为弧度然后取余,取值范围:(-PI — PI)
system("pause");
return 0;
}
inline float
normAngle (float alpha)
{
return (alpha >= 0 ?
std::fmod (alpha + static_cast<float>(M_PI),
2.0f * static_cast<float>(M_PI))
- static_cast<float>(M_PI)
:
-(std::fmod (static_cast<float>(M_PI) - alpha,
2.0f * static_cast<float>(M_PI))
- static_cast<float>(M_PI)));
}
fmodf是求取余数,在这里是想把弧度转换到-M_PI到M_PI之间
fmodf(12.3,5)=2.3;
参考文章:
https://pointclouds.org/documentation/angles_8h.html
https://pointclouds.org/documentation/angles_8h_source.html