16 template <
typename Real>
28 template <
int N,
typename Real>
32 template <
int N,
typename Real>
39 template <
int N,
typename Real>
50 template <
typename Real>
59 template <
typename Real>
62 Real bary[4], Real epsilon = (Real)0);
67 template <
typename Real>
116 template <
int N,
typename Real>
119 static_assert(N == 3 || N == 4,
"Dimension must be 3 or 4.");
123 result[0] = v0[1] * v1[2] - v0[2] * v1[1];
124 result[1] = v0[2] * v1[0] - v0[0] * v1[2];
125 result[2] = v0[0] * v1[1] - v0[1] * v1[0];
129 template <
int N,
typename Real>
132 static_assert(N == 3 || N == 4,
"Dimension must be 3 or 4.");
139 template <
int N,
typename Real>
143 static_assert(N == 3 || N == 4,
"Dimension must be 3 or 4.");
148 template <
typename Real>
153 if (fabs(v[0][0]) > fabs(v[0][1]))
155 v[1] = { -v[0][2], (Real)0, +v[0][0] };
159 v[1] = { (Real)0, +v[0][2], -v[0][1] };
166 v[2] =
Cross(v[0], v[1]);
167 return Orthonormalize<3, Real>(3,
v, robust);
173 template <
typename Real>
181 Real det =
DotCross(diff[0], diff[1], diff[2]);
182 if (det < -epsilon || det > epsilon)
184 Real invDet = ((Real)1) / det;
185 bary[0] =
DotCross(diff[3], diff[1], diff[2]) * invDet;
186 bary[1] =
DotCross(diff[3], diff[2], diff[0]) * invDet;
187 bary[2] =
DotCross(diff[3], diff[0], diff[1]) * invDet;
188 bary[3] = (Real)1 - bary[0] - bary[1] - bary[2];
192 for (
int i = 0; i < 4; ++i)
199 template <
typename Real>
206 origin({ (Real)0, (Real)0, (Real)0 }),
212 direction[0] = { (Real)0, (Real)0, (Real)0 };
213 direction[1] = { (Real)0, (Real)0, (Real)0 };
214 direction[2] = { (Real)0, (Real)0, (Real)0 };
220 if (numVectors > 0 &&
v &&
epsilon >= (Real)0)
224 int j, indexMin[3], indexMax[3];
225 for (j = 0; j < 3; ++j)
234 for (i = 1; i < numVectors; ++i)
236 for (j = 0; j < 3; ++j)
238 if (
v[i][j] <
min[j])
243 else if (
v[i][j] >
max[j])
262 range =
max[2] - min[2];
278 for (j = 0; j < 3; ++j)
280 extreme[j + 1] = extreme[0];
307 Real maxDistance = (Real)0;
309 extreme[2] = extreme[0];
310 for (i = 0; i < numVectors; ++i)
315 distance =
Length(proj,
false);
316 if (distance > maxDistance)
327 extreme[2] = extreme[1];
328 extreme[3] = extreme[1];
345 direction[2] =
Cross(direction[0], direction[1]);
349 maxDistance = (Real)0;
350 Real maxSign = (Real)0;
351 extreme[3] = extreme[0];
352 for (i = 0; i < numVectors; ++i)
355 distance =
Dot(direction[2], diff);
356 Real sign = (distance >(Real)0 ? (Real)1 :
357 (distance < (Real)0 ? (Real)-1 : (Real)0));
358 distance = fabs(distance);
359 if (distance > maxDistance)
367 if (maxDistance <=
epsilon * maxRange)
372 extreme[3] = extreme[2];
Vector< N, Real > UnitCross(Vector< N, Real > const &v0, Vector< N, Real > const &v1, bool robust=false)
GLsizei GLsizei GLfloat distance
IntrinsicsVector3(int numVectors, Vector3< Real > const *v, Real inEpsilon)
DualQuaternion< Real > Dot(DualQuaternion< Real > const &d0, DualQuaternion< Real > const &d1)
GLfloat GLfloat GLfloat GLfloat v3
Vector3< Real > direction[3]
Real Normalize(GVector< Real > &v, bool robust=false)
DualQuaternion< Real > Cross(DualQuaternion< Real > const &d0, DualQuaternion< Real > const &d1)
Real DotCross(Vector< N, Real > const &v0, Vector< N, Real > const &v1, Vector< N, Real > const &v2)
bool ComputeBarycentrics(Vector2< Real > const &p, Vector2< Real > const &v0, Vector2< Real > const &v1, Vector2< Real > const &v2, Real bary[3], Real epsilon=(Real) 0)
DualQuaternion< Real > Length(DualQuaternion< Real > const &d, bool robust=false)
GLfloat GLfloat GLfloat v2
Real ComputeOrthogonalComplement(int numInputs, Vector2< Real > *v, bool robust=false)