当前位置: 首页>>代码示例>>C++>>正文


C++ polygon::begin方法代码示例

本文整理汇总了C++中polygon::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ polygon::begin方法的具体用法?C++ polygon::begin怎么用?C++ polygon::begin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在polygon的用法示例。


在下文中一共展示了polygon::begin方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: polygonCollision

bool polygonCollision( polygon & poly1, polygon & poly2 )
{
	polyIterator itr1 = poly1.begin();
	int intersectionCount = 0;
	
	while( itr1 != poly1.end() )
	{
		polyIterator itr2 = poly2.begin();
		while( itr2 != poly2.end() )
		{
			point intersection = itr1->checkIntersection( *itr2 );
			if ( itr1->isPointOnLine( intersection ) )
			{
				intersectionCount++;
				if( intersectionCount >= 8 )
				{
					return true;
				}
			}
			++itr2;
		}
		++itr1;
	}	
	return false;
}
开发者ID:thurtt,项目名称:gameengine,代码行数:25,代码来源:collision.cpp

示例2: convex_hull

void convex_hull(polygon in, polygon& hull){
	hull.clear();
	
	if(in.size() < 3){ hull = in; return; }
	
	int pos = 0;
	for(int i = 1; i < in.size(); i++) if(in[i] < in[pos]) pos = i;
	swap(in[0], in[pos]);
	refer = in[0];
	
	sort(in.begin() + 1, in.end(), cmp_angle);
	in.resize(unique(in.begin(), in.end()) - in.begin());
	
	hull.push_back(in[0]); hull.push_back(in[1]);
	
	in.push_back(in[0]); //isto evita pontos colineares no final do poligono
	for(int i = 2; i < in.size(); ){
		if(hull.size() > 2 && side_sign(hull[hull.size() - 2], hull[hull.size() - 1], in[i]) <= 0){
			hull.pop_back();
		}
		else hull.push_back(in[i++]);
	}
	//tira a duplicata
	hull.pop_back();
}
开发者ID:campagnuci,项目名称:icpc_material,代码行数:25,代码来源:2d-geometry.cpp

示例3: convex_hull_2

// Returns a list of points on the convex hull in counter-clockwise order.
// NOTE: the last point in the returned list is the same as the first one.
void convex_hull_2(polygon P, polygon& hull) {
	hull.clear();
	
	// Sort points lexicographically
	sort(P.begin(), P.end());
	P.resize(unique(P.begin(), P.end()) - P.begin());
	
	// Build lower hull
	for (int i = 0; i < P.size(); i ++) {
		while (hull.size() >= 2 && side_sign(hull[hull.size() - 2], hull[hull.size() - 1], P[i]) <= 0)
			hull.pop_back();
		hull.push_back(P[i]);
	};
 
	// Build upper hull
	for (int i = P.size()-2, t = hull.size() + 1; i >= 0; i --) {
		while (hull.size() >= t && side_sign(hull[hull.size()-2], hull[hull.size()-1], P[i]) <= 0)
			hull.pop_back();
		hull.push_back(P[i]);
	};
}
开发者ID:campagnuci,项目名称:icpc_material,代码行数:23,代码来源:2d-geometry.cpp

示例4: linePolyCollision

bool linePolyCollision( line & testLine, polygon & testPoly)
{
	// 2 intersections should be a collision
	polyIterator itr = testPoly.begin();
	int collCounter = 0;
	int pointCount = 1;
	while( itr != testPoly.end() )
	{
		point collPoint = testLine.checkIntersection( *itr );
		if ( testLine.isPointOnLine( collPoint ) )
		{
			collCounter++;
		}
		++itr;
		pointCount++;
	}

	if( collCounter > 1 )
	{
		return true;
	}
	return false;
}
开发者ID:thurtt,项目名称:gameengine,代码行数:23,代码来源:collision.cpp

示例5: split

pair<polygon, polygon> split(polygon & P, int k) {
    polygon p1(P.begin(), P.begin() + k);
    polygon p2(P.begin() + k, P.end());
    return {p1, p2};
}
开发者ID:AVBelyy,项目名称:CompGeometry,代码行数:5,代码来源:hp-intersection-nm.cpp


注:本文中的polygon::begin方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。