c语言 自动匹配,c语言同名标靶点自动匹配算法实现实例代码.pdf

c语语言言同同名名标标靶靶点点自自动动匹匹配配算算法法实实现现实实例例代代码码

1.两两个个标标靶靶数数据据

2.匹匹配配结结果果

3.代代码码

#include

#include

#include

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 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

for(int j=i+1;j

for (int k=j+1;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

for (int n=0;n

for (int l=0;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)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值