CloudCompare——点云空间圆拟合

在这里插入图片描述

本文由CSDN点云侠原创,CloudCompare——点云空间圆拟合,爬虫自重。如果你不是在点云侠的博客中看到该文章,那么此处便是不要脸的爬虫与GPT生成的文章。

1.概述

   CloudCompare软件中的'Tools——>Fit——>Circle功能可以实现点云的空间圆拟合。

2.软件实现

1. 首先选中点云
在这里插入图片描述

2. 拟合功能
在这里插入图片描述

3. 拟合结果
白色的线为拟合出来的空间圆模型
在这里插入图片描述

4. 拟合参数
在这里插入图片描述

5. 修改拟合圆的颜色
选中拟合的空间圆模型使用Edit中的Colors功能即可对拟合结果进行颜色修改。
在这里插入图片描述

3.完整操作

在这里插入图片描述

4.算法源码

void MainWindow::doActionFitCircle()
{
	ccProgressDialog pDlg(true, this);
	pDlg.setAutoClose(false);

	for (ccHObject* entity : getSelectedEntities())
	{
		ccPointCloud* cloud = ccHObjectCaster::ToPointCloud(entity);
		if (!cloud)
			continue;

		CCVector3 center;
		CCVector3 normal;
		PointCoordinateType radius = 0;
		double rms = std::numeric_limits<double>::quiet_NaN();
		if (CCCoreLib::GeometricalAnalysisTools::DetectCircle(	cloud,
																center,
																normal,
																radius,
																rms,
																&pDlg) != CCCoreLib::GeometricalAnalysisTools::NoError)
		{
			ccLog::Warning(tr("[Fit circle] Failed to fit a circle on cloud '%1'").arg(cloud->getName()));
			continue;
		}

		ccLog::Print(tr("[Fit circle] Cloud '%1': center (%2,%3,%4) - radius = %5 [RMS = %6]")
						.arg(cloud->getName())
						.arg(center.x)
						.arg(center.y)
						.arg(center.z)
						.arg(radius)
						.arg(rms));

		ccLog::Print(tr("[Fit circle] Normal (%1,%2,%3)")
			.arg(normal.x)
			.arg(normal.y)
			.arg(normal.z));

		// create the circle representation as a polyline
		ccPolyline* circle = ccPolyline::Circle(CCVector3(0, 0, 0), radius, 128);
		if (circle)
		{
			circle->setName(QObject::tr("Circle r=%1").arg(radius));
			cloud->addChild(circle);
			circle->prepareDisplayForRefresh();
			circle->copyGlobalShiftAndScale(*cloud);
			circle->setMetaData("RMS", rms);

			ccGLMatrix trans = ccGLMatrix::FromToRotation(CCVector3(0, 0, 1), normal);
			trans.setTranslation(center);
			circle->applyGLTransformation_recursive(&trans);


			addToDB(circle, false, false, false);
		}
	}

	refreshAll();
}

5.相关代码

  • 15
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 10
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 10
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

点云侠

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值