



#include <iostream>
#include <vector>
#include <math.h>
using namespace std;
struct Point
{
int id;
float x,y,z;
Point(int _id,float _x,float _y,float _z):id(_id),x(_x),y(_y),z(_z){}
};
struct Triangle
{
Point p1,p2,p3;
};
class PointCloud
{
public:
bool readFile(char *filename);
//void PointMatch(const PointCloud& pc1,const PointCloud &pc2);
vector<Point> pData;
int r,g,b;
};
bool PointCloud::readFile(char *filename)
{
if(filename==NULL)return false;
FILE *fp=fopen(filename,"r");
if (!fp)
{
printf("Load file %s failed\n", filename);
return false;
}
char buffer[100];
int count=0;
while(!feof(fp))
{
fgets(buffer, 300, fp);
float x,y,z;
sscanf_s(buffer,"%f%f%f",&x,&y,&z);
Point p(count++,x,y,z);
pData.push_back(p);
}
pData.pop_back();
}
float calDis(const Point &p1,const Point &p2)
{
return sqrt((p2.x-p1.x)*(p2.x-p1.x)+(p2.y-p1.y)*(p2.y-p1.y)+(p2.z-p1.z)*(p2.z-p1.z));
}
void PointMatch(const PointCloud& pc1,const PointCloud &pc2)
{
for (int i=0;i<pc1.pData.size()-2;++i)
for(int j=i+1;j<pc1.pData.size()-1;++j)
for (int k=j+1;k<pc1.pData.size();++k)
{
Point p1=pc1.pData[i];
Point p2=pc1.pData[j];
Point p3=pc1.pData[k];
float s12=calDis(p1,p2);
float s13=calDis(p1,p3);
float s23=calDis(p2,p3);
for (int m=0;m<pc2.pData.size();++m)
for (int n=0;n<pc2.pData.size();++n)
for (int l=0;l<pc2.pData.size();++l)
{
if (n!=m&&m!=l&&n!=l)
{
Point _p1=pc2.pData[m];
Point _p2=pc2.pData[n];
Point _p3=pc2.pData[l];
float _s12=calDis(_p1,_p2);
float _s13=calDis(_p1,_p3);
float _s23=calDis(_p2,_p3);
if (fabs(s12-_s12)<0.45&&fabs(s13-_s13)<0.45&&fabs(s23-_s23)<0.45)
{
cout<<"pc1....."<<p1.id<<"pc2......"<<_p1.id<<endl;
cout<<"pc1....."<<p2.id<<"pc2......"<<_p2.id<<endl;
cout<<"pc1....."<<p3.id<<"pc2......"<<_p3.id<<endl;
}
}
}
}
}
int main()
{
char *file1="測(cè)試點(diǎn)云\\點(diǎn)云Mark0.txt";
char *file2="測(cè)試點(diǎn)云\\點(diǎn)云Mark1.txt";
PointCloud pc1,pc2;
pc1.readFile(file1);
pc2.readFile(file2);
PointMatch(pc1,pc2);
}另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)建站chinadenli.net,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。
網(wǎng)站題目:c語言同名標(biāo)靶點(diǎn)自動(dòng)匹配算法實(shí)現(xiàn)實(shí)例代碼-創(chuàng)新互聯(lián)
鏈接地址:http://chinadenli.net/article28/didcjp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站內(nèi)鏈、移動(dòng)網(wǎng)站建設(shè)、關(guān)鍵詞優(yōu)化、搜索引擎優(yōu)化、全網(wǎng)營(yíng)銷推廣、外貿(mào)建站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容