本文整理汇总了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);
}
示例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);
}
示例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;
}