写一段代码,使用pcl和eigen,能够将稠密点云绕y轴旋转30度
时间: 2023-02-26 14:46:08 浏览: 156
pcd文件点云数据刚体变换,可绕x,y,z轴旋转一定角度 + 平移 运行速度快
5星 · 资源好评率100%
#include <pcl/point_types.h>
#include <pcl/io/pcd_io.h>
#include <pcl/common/eigen.h>
#include <pcl/common/transforms.h>int main( int argc, char** argv )
{
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>);
pcl::io::loadPCDFile("example.pcd", *cloud); Eigen::Matrix4f transform = Eigen::Matrix4f::Identity();
float theta = 30.0;
transform (1,1) = cos (theta);
transform (1,2) = -sin(theta);
transform (2,1) = sin (theta);
transform (2,2) = cos (theta); pcl::PointCloud<pcl::PointXYZ>::Ptr transformed_cloud (new pcl::PointCloud<pcl::PointXYZ> ());
pcl::transformPointCloud (*cloud, *transformed_cloud, transform); pcl::io::savePCDFile ("transformed.pcd", *transformed_cloud);
return (0);
}
阅读全文