资源简介
多个三维空间点拟合平面,平面方程设为Ax+By+Cz+1=0。
代码片段和文件信息
#include
#include
using namespace std;
using namespace cv;
void getpoint(vector& point3d)
{
float a = 1;
float b = 1;
float c = 1;
float d = 1;
float x;
float y;
float z;
float random;
for (int i = 0; i<100; ++i)
for (int j = 0; j < 10; ++j)
{
random = rand() % 10;
random = random / 1000;// 随机产生噪声,加到z坐标上。
x = i;
y = j;
z = (-d - a*x - b*y) / c + random;
point3d.push_back(Point3f(x y z));
}
}
void get_plane(vector point double& A double& B double& C)
{
double x = 0 y = 0 z = 0 xy = 0 xz = 0 yz = 0 x2 = 0 y2 = 0 z2 = 0;
for (int i = 0; i < point.size(); ++i)
{
x += point[i].x;
y += point[i].y;
z += point[i].z;
xy += point[i].x*point[i].y;
xz +=
- 上一篇:huffmantree对英文短文编码,译码
- 下一篇:c语言 自动售货机 零钱计算
评论
共有 条评论