32 template <
typename Real>
47 template <
typename Real>
55 std::function<Real(Real const*)> energy =
68 for (
int i = 0; i < 3; ++i)
71 diagonal[i] = box.
extent[i];
79 diagonal[0] *
std::abs(rotate(0, 0)) +
80 diagonal[1] *
std::abs(rotate(0, 1)) +
81 diagonal[2] *
std::abs(rotate(0, 2)),
83 diagonal[0] *
std::abs(rotate(1, 0)) +
84 diagonal[1] *
std::abs(rotate(1, 1)) +
85 diagonal[2] *
std::abs(rotate(1, 2)),
87 diagonal[0] *
std::abs(rotate(2, 0)) +
88 diagonal[1] *
std::abs(rotate(2, 1)) +
94 ((Real)0.5)*diagonal[0],
95 ((Real)0.5)*diagonal[1],
96 ((Real)0.5)*diagonal[2],
97 center[0] - extent[0],
98 center[1] - extent[1],
99 center[2] - extent[2],
107 ((Real)2)*diagonal[0],
108 ((Real)2)*diagonal[1],
109 ((Real)2)*diagonal[2],
110 center[0] + extent[0],
111 center[1] + extent[1],
112 center[2] + extent[2],
132 minimizer.
GetMinimum(v0, v1, vInitial, vMin, error);
134 diagonal[0] = vMin[0];
135 diagonal[1] = vMin[1];
136 diagonal[2] = vMin[2];
145 template <
typename Real>
152 Real
const zero = (Real)0;
153 Real
const one = (Real)1;
156 if (-one < aa.
axis[2])
158 if (aa.
axis[2] < one)
160 angle[0] = atan2(aa.
axis[1], aa.
axis[0]);
161 angle[1] = acos(aa.
axis[2]);
176 template <
typename Real>
183 Real cs0 = cos(angle[0]);
184 Real sn0 = sin(angle[0]);
185 Real cs1 = cos(angle[1]);
186 Real sn1 = sin(angle[1]);
188 aa.
axis = { cs0*sn1, sn0*sn1, cs1 };
193 template <
typename Real>
203 Real maxValue = std::max(std::max(input[0], input[1]), input[2]);
204 Real invMax = ((Real)1) / maxValue;
207 invMax*input[1], invMax*input[2] });
212 Real energy = (Real)0;
213 for (
int i = 0; i < numPoints; ++i)
219 Real dist = peQuery(prod, ellipsoid).distance;
220 energy += maxValue * dist;
std::array< Vector< N, Real >, N > axis
static void MatrixToAngles(Matrix3x3< Real > const &rotate, Real angle[3])
gte::BSNumber< UIntegerType > abs(gte::BSNumber< UIntegerType > const &number)
bool GetContainer(int numPoints, Vector3< Real > const *points, Capsule3< Real > &capsule)
void GetMinimum(Real const *t0, Real const *t1, Real const *tInitial, Real *tMin, Real &fMin)
GLfixed GLfixed GLint GLint GLfixed points
Real operator()(int numPoints, Vector3< Real > const *points, Vector3< Real > ¢er, Matrix3x3< Real > &rotate, Real diagonal[3])
static void AnglesToMatrix(Real const angle[3], Matrix3x3< Real > &rotate)
GLenum GLenum GLenum input
void SetRow(int r, Vector< NumCols, Real > const &vec)
static Real Energy(int numPoints, Vector3< Real > const *points, Real const *input)
static Vector Unit(int d)