一、概述
CGAL中有现成的函数能够实现三个点确定一个平面。
二、代码实现
#include <iostream>
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Polygon_2_algorithms.h>
#include <CGAL/Plane_3.h>
#include <CGAL/Polygon_2.h>
using namespace std;
typedef CGAL::Simple_cartesian<double> Kernel;
typedef Kernel::Point_3 Point;
typedef Kernel::Plane_3 Plane;
int main()
{
Point P1(-0.9566, 0.3566, 0.0);
Point P2(0.9974, 0.21207, 0.0);
Point P3(0.0235, -0.3286, 0.0);
Plane p3(P1, P2, P3);
vector<Plane> planeFit;
planeFit.push_back(p3);
double A = planeFit[0].a();
double B = planeFit[0].b();
double C = planeFit[0].c();
double D = planeFit[0].d();
cout << "平面的系数为:" << "\n A = " << A << "\n B = " << B << "\n C = " << C << "\n D = " << D << endl;
return 0;
}
三、结果展示
1、实验数据
2、CloudCompare计算结果
0,0,1
3、矩阵分解计算结果
4、PCL计算结果
平面方程系数:
a=0
b=0
c=-1
d=-0
5、CGAL计算结果
平面的系数为:
A = 0
B = 0
C = -1.19723
D = 0
可以看出,CGAL计算结果,法向量未进行归一化。