c語言同名標(biāo)靶點(diǎn)自動匹配算法實(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="測試點(diǎn)云\\點(diǎn)云Mark0.txt"; char *file2="測試點(diǎn)云\\點(diǎn)云Mark1.txt"; PointCloud pc1,pc2; pc1.readFile(file1); pc2.readFile(file2); PointMatch(pc1,pc2); }
總結(jié)
以上就是本文關(guān)于c語言同名標(biāo)靶點(diǎn)自動匹配算法實(shí)現(xiàn)實(shí)例代碼的全部內(nèi)容,希望對大家有所幫助。感興趣的朋友可以繼續(xù)參閱本站其他相關(guān)專題,如有不足之處,歡迎留言指出。感謝朋友們對本站的支持!
上一篇:C語言通訊錄實(shí)例分享
欄 目:C語言
下一篇:C語言實(shí)現(xiàn)數(shù)字雨效果
本文標(biāo)題:c語言同名標(biāo)靶點(diǎn)自動匹配算法實(shí)現(xiàn)實(shí)例代碼
本文地址:http://mengdiqiu.com.cn/a1/Cyuyan/885.html
您可能感興趣的文章
- 04-02c語言函數(shù)調(diào)用后清空內(nèi)存 c語言調(diào)用函數(shù)刪除字符
- 04-02c語言的正則匹配函數(shù) c語言正則表達(dá)式函數(shù)庫
- 04-02func函數(shù)+在C語言 func函數(shù)在c語言中
- 04-02c語言中對數(shù)函數(shù)的表達(dá)式 c語言中對數(shù)怎么表達(dá)
- 04-02c語言用函數(shù)寫分段 用c語言表示分段函數(shù)
- 04-02c語言編寫函數(shù)冒泡排序 c語言冒泡排序法函數(shù)
- 04-02c語言沒有round函數(shù) round c語言
- 04-02c語言分段函數(shù)怎么求 用c語言求分段函數(shù)
- 04-02C語言中怎么打出三角函數(shù) c語言中怎么打出三角函數(shù)的值
- 04-02c語言調(diào)用函數(shù)求fibo C語言調(diào)用函數(shù)求階乘


閱讀排行
本欄相關(guān)
- 04-02c語言函數(shù)調(diào)用后清空內(nèi)存 c語言調(diào)用
- 04-02func函數(shù)+在C語言 func函數(shù)在c語言中
- 04-02c語言的正則匹配函數(shù) c語言正則表達(dá)
- 04-02c語言用函數(shù)寫分段 用c語言表示分段
- 04-02c語言中對數(shù)函數(shù)的表達(dá)式 c語言中對
- 04-02c語言編寫函數(shù)冒泡排序 c語言冒泡排
- 04-02c語言沒有round函數(shù) round c語言
- 04-02c語言分段函數(shù)怎么求 用c語言求分段
- 04-02C語言中怎么打出三角函數(shù) c語言中怎
- 04-02c語言調(diào)用函數(shù)求fibo C語言調(diào)用函數(shù)求
隨機(jī)閱讀
- 01-10使用C語言求解撲克牌的順子及n個(gè)骰子
- 08-05dedecms(織夢)副欄目數(shù)量限制代碼修改
- 01-11ajax實(shí)現(xiàn)頁面的局部加載
- 08-05DEDE織夢data目錄下的sessions文件夾有什
- 08-05織夢dedecms什么時(shí)候用欄目交叉功能?
- 01-10delphi制作wav文件的方法
- 01-11Mac OSX 打開原生自帶讀寫NTFS功能(圖文
- 01-10C#中split用法實(shí)例總結(jié)
- 01-10SublimeText編譯C開發(fā)環(huán)境設(shè)置
- 04-02jquery與jsp,用jquery