c語(yǔ)言同名標(biāo)靶點(diǎn)自動(dòng)匹配算法實(shí)現(xiàn)實(shí)例代碼
1.兩個(gè)標(biāo)靶數(shù)據(jù)
2.匹配結(jié)果
3.代碼
#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); }
總結(jié)
以上就是本文關(guān)于c語(yǔ)言同名標(biāo)靶點(diǎn)自動(dòng)匹配算法實(shí)現(xiàn)實(shí)例代碼的全部?jī)?nèi)容,希望對(duì)大家有所幫助。感興趣的朋友可以繼續(xù)參閱本站其他相關(guān)專題,如有不足之處,歡迎留言指出。感謝朋友們對(duì)本站的支持!
相關(guān)文章
用QT實(shí)現(xiàn)計(jì)時(shí)器功能
這篇文章主要為大家詳細(xì)介紹了用QT實(shí)現(xiàn)計(jì)時(shí)器功能,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-08-08淺析VSCode launch.json中的各種替換變量的意思 ${workspaceFolder} ${file} $
這篇文章主要介紹了VSCode launch.json中的各種替換變量的意思 ${workspaceFolder} ${file} ${fileBasename} ${fileDirname}等,非常不錯(cuò)具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-03-03C語(yǔ)言簡(jiǎn)易實(shí)現(xiàn)掃雷小游戲
這篇文章主要為大家詳細(xì)介紹了C語(yǔ)言簡(jiǎn)易實(shí)現(xiàn)掃雷小游戲,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2021-10-10c++之解決char轉(zhuǎn)string時(shí)出現(xiàn)的亂碼問(wèn)題
這篇文章主要介紹了c++之解決char轉(zhuǎn)string時(shí)出現(xiàn)的亂碼問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-08-08淺析C/C++ 中return *this和return this的區(qū)別
return *this返回的是當(dāng)前對(duì)象的克隆或者本身,return this返回當(dāng)前對(duì)象的地址,下面通過(guò)本文給大家介紹C/C++ 中return *this和return this的區(qū)別,感興趣的朋友一起看看吧2019-10-10C語(yǔ)言關(guān)鍵字之a(chǎn)uto register詳解
這篇文章主要為大家介紹了C語(yǔ)言關(guān)鍵字之a(chǎn)uto register,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下,希望能夠給你帶來(lái)幫助2022-01-01C語(yǔ)言數(shù)據(jù)結(jié)構(gòu)之串插入操作
這篇文章主要介紹了C語(yǔ)言數(shù)據(jù)結(jié)構(gòu)之串插入操作的相關(guān)資料,希望通過(guò)本文能幫助到大家,讓大家實(shí)現(xiàn)這樣的功能,需要的朋友可以參考下2017-10-10