去除由凸多边形构成的复杂多变性的拼接边

前端之家收集整理的这篇文章主要介绍了去除由凸多边形构成的复杂多变性的拼接边前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

/**

* 挑出传入的所有点中重复的点~

*/

- (vector<b2Vec2>*)selectDuplicatedVertices:(vector<vector<b2Vec2>*>*)allVertices {

vector<b2Vec2> *target = new vector<b2Vec2>();

for(uint i = 0; i < allVertices->size(); ++ i) {

vector<b2Vec2> *poly = allVertices->at(i);

for(uint j = i + 1; j < allVertices->size(); ++ j) {

vector<b2Vec2> *beCompared = allVertices->at(j);

b2Vec2 vA;

b2Vec2 vB;

int counter = 0;

for(uint k = 0; k < poly->size(); ++ k) {

b2Vec2 m = poly->at(k);

for(uint l = 0; l < beCompared->size(); ++ l) {

b2Vec2 n = beCompared->at(l);

if((m.x == n.x && m.y == n.y) ||

(m.x <= n.x+_floatErrorRange && m.x >= n.x-_floatErrorRange &&

m.y <= n.y+_floatErrorRange && m.y >= n.y-_floatErrorRange))

{

if(counter >=2) {

break;

}

if(counter ==0) {

vA =b2Vec2(m.x,m.y);

}else {

vB =b2Vec2(m.x,m.y);

}

counter +=1;

}

}

}

if(counter == 2) {

target->push_back(vA);

target->push_back(vB);

}

}

}

return target;

}

猜你在找的VB相关文章