使用PCL绘制空间圆

阅读: 评论:0

使用PCL绘制空间圆

使用PCL绘制空间圆

参考算法公式:

代码:

void DisplayMessage::createTheoryCircle(Point3d planeNormal, Point3d centerPoint, double R)
{double nx = planeNormal.x, ny = planeNormal.y, nz = planeNormal.z;double cx = centerPoint.x, cy = centerPoint.y, cz = centerPoint.z;double r = R;double ux = ny, uy = -nx, uz = 0;double vx = nx*nz,vy = ny*nz,vz = -nx*nx - ny*ny;double sqrtU = sqrt(ux*ux + uy*uy + uz*uz);double sqrtV = sqrt(vx*vx + vy*vy + vz*vz);double ux_ = (1 / sqrtU)*ux;double uy_ = (1 / sqrtU)*uy;double uz_ = (1 / sqrtU)*uz;double vx_ = (1 / sqrtV)*vx;double vy_ = (1 / sqrtV)*vy;double vz_ = (1 / sqrtV)*vz;double xi, yi, zi;double t = 0;double angle = (t / 180.0)*Pi;vector<double> x, y, z;while (t < 360.0){xi = cx + r*(ux_*cos(angle) + vx_*sin(angle));yi = cy + r*(uy_*cos(angle) + vy_*sin(angle));zi = cz + r*(uz_*cos(angle) + vz_*sin(angle));x.push_back(xi);y.push_back(yi);z.push_back(zi);t = t + 1;angle = (t / 180.0)*Pi;}pcl::PointCloud<pcl::PointXYZ>::Ptr theroyCirclePoints(new pcl::PointCloud<pcl::PointXYZ>);//定义cloudPoints大小,无序点云theroyCirclePoints->resize(x.size());for (int i = 0; i < x.size(); i++){//将三维坐标赋值给PCL点云坐标(*theroyCirclePoints)[i].x = x[i];(*theroyCirclePoints)[i].y = y[i];(*theroyCirclePoints)[i].z = z[i];}//圆心点云设置//设置点云颜色viewer->removePointCloud("theroyCircleCloud");pcl::visualization::PointCloudColorHandlerCustom<pcl::PointXYZ> theroyCircleCloud_color(theroyCirclePoints, 255, 0, 0);//点云颜色渲染	viewer->addPointCloud(theroyCirclePoints, theroyCircleCloud_color, "theroyCircleCloud");//设置点云大小viewer->setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 2, "theroyCircleCloud");viewer->resetCamera();ui.widget->update();}

本类用于QT显示PCL点云,可参考本栏博客QT显示PCL点云

本文发布于:2024-01-29 02:07:09,感谢您对本站的认可!

本文链接:https://www.4u4v.net/it/170646523411958.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:空间   PCL
留言与评论(共有 0 条评论)
   
验证码:

Copyright ©2019-2022 Comsenz Inc.Powered by ©

网站地图1 网站地图2 网站地图3 网站地图4 网站地图5 网站地图6 网站地图7 网站地图8 网站地图9 网站地图10 网站地图11 网站地图12 网站地图13 网站地图14 网站地图15 网站地图16 网站地图17 网站地图18 网站地图19 网站地图20 网站地图21 网站地图22/a> 网站地图23