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


C++ Sphere::Enclose方法代码示例

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


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

示例1: Sphere_Enclose

void Sphere_Enclose(Sphere &s, const T &obj)
{
	PointWithDistance corners[n];
	for(int i = 0; i < n; ++i)
	{
		corners[i].pt = obj.CornerPoint(i);
		corners[i].d = s.pos.DistanceSq(corners[i].pt);
	}
	std::sort(corners, corners+n);

	for(int i = n-1; i >= 0; --i)
		s.Enclose(corners[i].pt);
}
开发者ID:juj,项目名称:MathGeoLib,代码行数:13,代码来源:Sphere.cpp

示例2: Sphere_Enclose_pts

// Encloses n points into the Sphere s, in the order of farthest first, in order to
// generate the tightest resulting enclosure.
void Sphere_Enclose_pts(Sphere &s, const vec *pts, int n)
{
	AutoArrayPtr<PointWithDistance> cornersPtr(AlignedNew<PointWithDistance>(n, 16));
	PointWithDistance *corners = cornersPtr.ptr;

	for(int i = 0; i < n; ++i)
	{
		corners[i].pt = pts[i];
		corners[i].d = s.pos.DistanceSq(corners[i].pt);
	}
	std::sort(corners, corners+n);

	for(int i = n-1; i >= 0; --i)
		s.Enclose(corners[i].pt);
}
开发者ID:juj,项目名称:MathGeoLib,代码行数:17,代码来源:Sphere.cpp

示例3: FastEnclosingSphere

Sphere Sphere::FastEnclosingSphere(const vec *pts, int numPoints)
{
	Sphere s;
	if (numPoints == 0)
	{
		s.SetNegativeInfinity();
		return s;
	}
	assume(pts || numPoints == 0);
#ifndef MATH_ENABLE_INSECURE_OPTIMIZATIONS
	if (!pts)
		return Sphere();
#endif

	// First pass: Pick the cardinal axis (X,Y or Z) which has the two most distant points.
	int minx, maxx, miny, maxy, minz, maxz;
	AABB::ExtremePointsAlongAABB(pts, numPoints, minx, maxx, miny, maxy, minz, maxz);
	float dist2x = pts[minx].DistanceSq(pts[maxx]);
	float dist2y = pts[miny].DistanceSq(pts[maxy]);
	float dist2z = pts[minz].DistanceSq(pts[maxz]);

	int min = minx;
	int max = maxx;
	if (dist2y > dist2x && dist2y > dist2z)
	{
		min = miny;
		max = maxy;
	}
	else if (dist2z > dist2x && dist2z > dist2y)
	{
		min = minz;
		max = maxz;
	}

	// The two points on the longest axis define the initial sphere.
	s.pos = (pts[min] + pts[max]) * 0.5f;
	s.r = pts[min].Distance(s.pos);

	// Second pass: Make sure each point lies inside this sphere, expand if necessary.
	for(int i = 0; i < numPoints; ++i)
		s.Enclose(pts[i]);
	return s;
}
开发者ID:juj,项目名称:MathGeoLib,代码行数:43,代码来源:Sphere.cpp


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