資源簡介
多個三維空間點擬合平面,平面方程設為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? {
x?+=?point[i].x;
y?+=?point[i].y;
z?+=?point[i].z;
xy?+=?point[i].x*point[i].y;
xz?+=?
- 上一篇:huffmantree對英文短文編碼,譯碼
- 下一篇:c語言 自動售貨機 零錢計算
評論
共有 條評論