25 template <
typename InputType,
typename ComputeType>
34 inline std::array<int, 4>
const&
GetSupport()
const;
63 template <
typename InputType,
typename ComputeType>
67 if (numPoints >= 1 && points)
70 std::function<Sphere3<ComputeType>(
int)> update[5];
77 std::vector<int> permuted(numPoints);
78 for (
int i = 0; i < numPoints; ++i)
82 std::sort(permuted.begin(), permuted.end(),
83 [
points](
int i0,
int i1) {
return points[i0] < points[i1]; });
84 auto end = std::unique(permuted.begin(), permuted.end(),
85 [
points](
int i0,
int i1) {
return points[i0] == points[i1]; });
86 permuted.erase(end, permuted.end());
87 numPoints =
static_cast<int>(permuted.size());
90 std::shuffle(permuted.begin(), permuted.end(),
91 std::default_random_engine());
96 for (
int i = 0; i < numPoints; ++i)
98 for (
int j = 0; j < 3; ++j)
118 for (
int i = 1 % numPoints,
n = 0; i !=
n; i = (i + 1) % numPoints)
134 for (
int j = 0; j < 3; ++j)
136 minimal.
center[j] =
static_cast<InputType
>(ctMinimal.
center[j]);
138 minimal.
radius =
static_cast<InputType
>(ctMinimal.
radius);
149 LogError(
"Input must contain points.");
151 minimal.
radius = std::numeric_limits<InputType>::max();
156 template <
typename InputType,
typename ComputeType>
inline 162 template <
typename InputType,
typename ComputeType>
inline 163 std::array<int, 4>
const&
169 template <
typename InputType,
typename ComputeType>
178 template <
typename InputType,
typename ComputeType>
184 minimal.
radius = (ComputeType)0;
188 template <
typename InputType,
typename ComputeType>
195 minimal.
center = ((ComputeType)0.5)*(P0 + P1);
197 minimal.
radius = ((ComputeType)0.25)*
Dot(diff, diff);
201 template <
typename InputType,
typename ComputeType>
236 A(0, 0) =
Dot(E0, E0);
237 A(0, 1) =
Dot(E0, E1);
239 A(1, 1) =
Dot(E1, E1);
241 ComputeType
const half = (ComputeType)0.5;
248 ComputeType
x2 = (ComputeType)1 - X[0] - X[1];
249 minimal.
center = X[0] * P0 + X[1] * P1 + x2 *P2;
256 minimal.
radius = (ComputeType)std::numeric_limits<InputType>::max();
261 template <
typename InputType,
typename ComputeType>
301 A(0, 0) =
Dot(E0, E0);
302 A(0, 1) =
Dot(E0, E1);
303 A(0, 2) =
Dot(E0, E2);
305 A(1, 1) =
Dot(E1, E1);
306 A(1, 2) =
Dot(E1, E2);
309 A(2, 2) =
Dot(E2, E2);
311 ComputeType
const half = (ComputeType)0.5;
318 ComputeType x3 = (ComputeType)1 - X[0] - X[1] - X[2];
319 minimal.
center = X[0] * P0 + X[1] * P1 + X[2] * P2 + x3 * P3;
326 minimal.
radius = (ComputeType)std::numeric_limits<InputType>::max();
331 template <
typename InputType,
typename ComputeType>
341 template <
typename InputType,
typename ComputeType>
346 int const numType2 = 2;
347 int const type2[numType2][2] =
354 int const numType3 = 1;
357 ComputeType minRSqr = (ComputeType)std::numeric_limits<InputType>::max();
358 int iSphere = 0, iMinRSqr = -1;
362 for (
int j = 0; j < numType2; ++j, ++iSphere)
366 if (sphere[iSphere].radius < minRSqr)
371 minRSqr = sphere[iSphere].
radius;
381 if (sphere[iSphere].radius < minRSqr)
383 minRSqr = sphere[iSphere].
radius;
409 return sphere[iMinRSqr];
412 template <
typename InputType,
typename ComputeType>
417 int const numType2 = 3;
418 int const type2[numType2][3] =
426 int const numType3 = 3;
427 int const type3[numType3][3] =
435 int const numType4 = 1;
438 ComputeType minRSqr = (ComputeType)std::numeric_limits<InputType>::max();
439 int iSphere = 0, iMinRSqr = -1;
443 for (
int j = 0; j < numType2; ++j, ++iSphere)
447 if (sphere[iSphere].radius < minRSqr)
454 minRSqr = sphere[iSphere].
radius;
461 for (
int j = 0; j < numType3; ++j, ++iSphere)
466 if (sphere[iSphere].radius < minRSqr)
471 minRSqr = sphere[iSphere].
radius;
482 if (sphere[iSphere].radius < minRSqr)
484 minRSqr = sphere[iSphere].
radius;
526 return sphere[iMinRSqr];
529 template <
typename InputType,
typename ComputeType>
534 int const numType2 = 4;
535 int const type2[numType2][4] =
544 int const numType3 = 6;
545 int const type3[numType3][4] =
556 int const numType4 = 4;
557 int const type4[numType4][4] =
566 ComputeType minRSqr = (ComputeType)std::numeric_limits<InputType>::max();
567 int iSphere = 0, iMinRSqr = -1;
571 for (
int j = 0; j < numType2; ++j, ++iSphere)
575 if (sphere[iSphere].radius < minRSqr)
584 minRSqr = sphere[iSphere].
radius;
591 for (
int j = 0; j < numType3; ++j, ++iSphere)
596 if (sphere[iSphere].radius < minRSqr)
603 minRSqr = sphere[iSphere].
radius;
610 for (
int j = 0; j < numType4; ++j, ++iSphere)
616 if (sphere[iSphere].radius < minRSqr)
621 minRSqr = sphere[iSphere].
radius;
696 return sphere[iMinRSqr];
699 template <
typename InputType,
typename ComputeType>
bool SupportContains(int j) const
Sphere3< ComputeType > UpdateSupport1(int i)
int GetNumSupport() const
std::array< int, 4 > const & GetSupport() const
std::array< int, 4 > mSupport
Sphere3< ComputeType > UpdateSupport3(int i)
Sphere3< ComputeType > UpdateSupport4(int i)
GLfixed GLfixed GLint GLint GLfixed points
Sphere3< ComputeType > ExactSphere4(int i0, int i1, int i2, int i3) const
typedef int(WINAPI *PFNWGLRELEASEPBUFFERDCARBPROC)(HPBUFFERARB hPbuffer
#define LogError(message)
Sphere3< ComputeType > ExactSphere1(int i0) const
DualQuaternion< Real > Dot(DualQuaternion< Real > const &d0, DualQuaternion< Real > const &d1)
Sphere3< ComputeType > ExactSphere2(int i0, int i1) const
Sphere3< ComputeType > UpdateSupport2(int i)
bool Contains(int i, Sphere3< ComputeType > const &sphere) const
bool operator()(int numPoints, Vector3< InputType > const *points, Sphere3< InputType > &minimal)
Sphere3< ComputeType > ExactSphere3(int i0, int i1, int i2) const
std::vector< Vector3< ComputeType > > mComputePoints