详解平面点云面积计算

部分代码展示:

(1)利用格网法计算面积:

cpp 复制代码
//(2)测试使用格网法计算平面点云面积
void main()
{
	char *inputpath = "D:\\testdata\\data.txt";
	vector<pcl::PointXYZ> points = ReadPointXYZIntoVector(inputpath);
	double area_01 = statisGrids(points, 0.5);
	double area_02 = statisGrids(points, 1.0);
	double area_03 = statisGrids(points, 2.0);
	double area_04 = statisGrids(points, 3.0);
	cout << "格网尺寸为0.5时面积 " << area_01 << endl;
	cout << "格网尺寸为1.0时面积 " << area_02 << endl;
	cout << "格网尺寸为2.0时面积 " << area_03 << endl;
	cout << "格网尺寸为3.0时面积 " << area_04 << endl;
	system("pause");

}

(2)利用鞋带定理矩阵计算面积:

cpp 复制代码
//(5)利用鞋带矩阵定理计算面积
void main()
{
	char *filepath = "D:\\testdata\\data.txt";
	vector<pcl::PointXYZ> origipts = ReadPointXYZIntoVector(filepath);
	//假设其z坐标都为0,为平面坐标
	for (int i = 0; i < origipts.size(); i++)
	{
		origipts[i].z = 0;
	}

	vector<pcl::PointXYZ> boundpts, nonbounpts;
	double r = 0.8;
	Bounpts(origipts, r, boundpts, nonbounpts);

	double area = AreaCalculation(boundpts);
	cout << "使用边缘点计算的点云面积为 " << area << endl;
	cout << "真实点云面积为 1078.23" << endl;
	system("pause");
}

源代码及测试数据下载链接:https://download.csdn.net/download/qq_32867925/88847794