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


C++ Point::RoundedIsEqual方法代码示例

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


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

示例1: Rasterize

/*!
	@brief Fills the point array with all the points on the curve, starting at
	parameter u' >= u and ending at point lastPt (which is also added). If
	pts is empty, the first point added is at u' = u. Otherwise, the first 
	point added is at u' > u and meets the following condition:
	     u' = argmin_u'(u' - u) AND (cb(u').x != x0 || cb(u').y != y0).
	
	The points in the array are one-pixel thin and connected.
*/
void CubicBezierParams::Rasterize(double u, const Point& endPt, double stepsize, 
							      POINTS& pts, SmartArray<double>* pParamMap)
{
	Point pt;

	int sz = pts.Size();

	// If not the first point, then cb(u) is already in the array
	if (sz > 0) 
		u += stepsize;

	do
	{
		GetCurvePoint(u, &pt.x, &pt.y);

		//pt.Round(); //point must be rounded (uncomment to get integer coordinates)

		// check that current point is not equal to last point
		if (sz == 0 || !pt.RoundedIsEqual(pts[sz - 1])/*pt != pts[sz - 1]*/)  /*uncomment for integer coords*/
		{
			// check if we have two disconnected points. max dist is sqrt(2)
			if (sz > 1 && pt.SqDist(pts[sz - 1]) > 2)
			{
				Rasterize(u - stepsize, pt, stepsize / 2, pts, pParamMap);
				sz = pts.Size(); // update current size
			}
			// avoid having a "thick" set of 3 pts
			else if (sz > 2 && pt.SqDist(pts[sz - 2]) <= 2)
			{
				// Replace the last point with the current point
				pts[sz - 1] = pt;

				if (pParamMap) 
					(*pParamMap)[sz - 1] = u;
			}
			else // first iteration enters here ALWAYS
			{
				// Add a new point to the array
				pts.AddTail(pt);

				if (pParamMap) 
					pParamMap->AddTail(u);

				sz = pts.Size(); // update current size
			}
		}

		u += stepsize;   // step to the next point

		// The curve param u must be in [-1, 1]. Adding the step size should
		// keep it smaller than 1 + max_stepsize, for max_stepsize == 2
		ASSERT(u <= 3);

	} while (!pt.RoundedIsEqual(endPt)/*pt != endPt*/); /*uncomment for integer coords*/
}
开发者ID:ChrisWhiten,项目名称:VideoParser,代码行数:64,代码来源:PolyBezierApprox.cpp


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