45 template <
int N,
typename Real>
80 std::array<Vector<N, Real>, N>
axis;
88 Real C,
std::array<Real, (N + 1)*(N + 2) / 2>& coeff);
101 template <
typename Real>
104 template <
typename Real>
108 template <
int N,
typename Real>
112 for (
int d = 0; d < N; ++d)
119 template <
int N,
typename Real>
130 template <
int N,
typename Real>
134 for (
int d = 0; d < N; ++d)
137 M += OuterProduct<N, N, Real>(ratio, ratio);
141 template <
int N,
typename Real>
145 for (
int d = 0; d < N; ++d)
148 MInverse += OuterProduct<N, N, Real>(product, product);
152 template <
int N,
typename Real>
154 std::array<Real, (N + 1)*(N + 2) / 2>& coeff)
const 156 int const numCoefficients = (N + 1)*(N + 2) / 2;
164 int quadIndex = numCoefficients - 1;
165 int maxIndex = quadIndex;
166 Real maxValue =
std::abs(coeff[quadIndex]);
167 for (
int d = 2; d < N; ++d)
170 Real absValue =
std::abs(coeff[quadIndex]);
171 if (absValue > maxValue)
173 maxIndex = quadIndex;
178 Real invMaxValue = ((Real)1) / maxValue;
179 for (
int i = 0; i < numCoefficients; ++i)
183 coeff[i] *= invMaxValue;
192 template <
int N,
typename Real>
198 B = ((Real)-2) * product;
199 C =
Dot(center, product) - (Real)1;
202 template <
int N,
typename Real>
204 std::array<Real, (N + 1)*(N + 2) / 2>
const& coeff)
213 template <
int N,
typename Real>
225 center = ((Real)-0.5) * (invA * B);
228 Real rightSide = -((Real)0.5) *
Dot(center, B) - C;
229 if (rightSide == (Real)0)
235 Real invRightSide = ((Real)1) / rightSide;
243 std::array<Real, N> diagonal;
249 auto negLast = -rotation.
GetCol(N - 1);
250 rotation.
SetCol(N - 1, negLast);
253 for (
int d = 0; d < N; ++d)
255 if (diagonal[d] <= (Real)0)
260 extent[d] = ((Real)1) / sqrt(diagonal[d]);
261 axis[d] = rotation.
GetCol(d);
267 template <
int N,
typename Real>
275 for (
int j = 0; j < N; ++j)
280 for (
int r = 0;
r < N; ++
r)
282 for (
int c = 0;
c <
r; ++
c)
287 A(r, r) = coeff[i++];
289 for (
int c = r + 1;
c < N; ++
c)
291 A(r,
c) = coeff[i++] * (Real)0.5;
296 template <
int N,
typename Real>
304 for (
int j = 0; j < N; ++j)
309 for (
int r = 0;
r < N; ++
r)
311 coeff[i++] = A(
r,
r);
312 for (
int c =
r + 1;
c < N; ++
c)
314 coeff[i++] = A(
r,
c) * (Real)2;
319 template <
int N,
typename Real>
323 return center == hyperellipsoid.
center && axis == hyperellipsoid.
axis 324 && extent == hyperellipsoid.
extent;
327 template <
int N,
typename Real>
334 template <
int N,
typename Real>
338 if (center < hyperellipsoid.
center)
343 if (center > hyperellipsoid.
center)
348 if (axis < hyperellipsoid.
axis)
353 if (axis > hyperellipsoid.
axis)
358 return extent < hyperellipsoid.
extent;
361 template <
int N,
typename Real>
368 template <
int N,
typename Real>
375 template <
int N,
typename Real>
static void Convert(std::array< Real,(N+1)*(N+2)/2 > const &coeff, Matrix< N, N, Real > &A, Vector< N, Real > &B, Real &C)
Vector< NumRows, Real > GetCol(int c) const
void GetM(Matrix< N, N, Real > &M) const
gte::BSNumber< UIntegerType > abs(gte::BSNumber< UIntegerType > const &number)
void GetMInverse(Matrix< N, N, Real > &MInverse) const
void GetEigenvalues(Real *eigenvalues) const
bool operator!=(Hyperellipsoid const &hyperellipsoid) const
void GetEigenvectors(Real *eigenvectors) const
unsigned int Solve(Real const *input, int sortType)
DualQuaternion< Real > Dot(DualQuaternion< Real > const &d0, DualQuaternion< Real > const &d1)
bool operator<(Hyperellipsoid const &hyperellipsoid) const
void ToCoefficients(std::array< Real,(N+1)*(N+2)/2 > &coeff) const
void SetCol(int c, Vector< NumRows, Real > const &vec)
bool FromCoefficients(std::array< Real,(N+1)*(N+2)/2 > const &coeff)
bool operator==(Hyperellipsoid const &hyperellipsoid) const
bool operator>=(Hyperellipsoid const &hyperellipsoid) const
bool operator<=(Hyperellipsoid const &hyperellipsoid) const
Quaternion< Real > Inverse(Quaternion< Real > const &d)
bool operator>(Hyperellipsoid const &hyperellipsoid) const
std::array< Vector< N, Real >, N > axis