13 #include <initializer_list> 18 template <
int N,
typename Real>
35 Vector(std::initializer_list<Real> values);
73 template <
int N,
typename Real>
76 template <
int N,
typename Real>
80 template <
int N,
typename Real>
84 template <
int N,
typename Real>
88 template <
int N,
typename Real>
91 template <
int N,
typename Real>
94 template <
int N,
typename Real>
97 template <
int N,
typename Real>
100 template <
int N,
typename Real>
103 template <
int N,
typename Real>
106 template <
int N,
typename Real>
110 template <
int N,
typename Real>
114 template <
int N,
typename Real>
118 template <
int N,
typename Real>
121 template <
int N,
typename Real>
130 template <
int N,
typename Real>
133 template <
int N,
typename Real>
136 template <
int N,
typename Real>
146 template <
int N,
typename Real>
153 template <
int N,
typename Real>
159 template <
int N,
typename Real>
164 template <
int N,
typename Real>
168 template <
int N,
typename Real>
174 template <
int N,
typename Real>
180 template <
int N,
typename Real>
184 template <
int N,
typename Real>
190 template <
int N,
typename Real>
197 template <
int N,
typename Real>
201 for (
auto value : values)
218 template <
int N,
typename Real>
224 template <
int N,
typename Real>
inline 230 template <
int N,
typename Real>
inline 236 template <
int N,
typename Real>
inline 242 template <
int N,
typename Real>
inline 248 template <
int N,
typename Real>
inline 254 template <
int N,
typename Real>
inline 260 template <
int N,
typename Real>
inline 266 template <
int N,
typename Real>
inline 272 template <
int N,
typename Real>
inline 278 template <
int N,
typename Real>
284 template <
int N,
typename Real>
294 template <
int N,
typename Real>
302 template <
int N,
typename Real>
312 template <
int N,
typename Real>
318 template <
int N,
typename Real>
322 for (
int i = 0; i < N; ++i)
329 template <
int N,
typename Real>
337 template <
int N,
typename Real>
345 template <
int N,
typename Real>
349 return result *= scalar;
352 template <
int N,
typename Real>
356 return result *= scalar;
359 template <
int N,
typename Real>
363 return result /= scalar;
366 template <
int N,
typename Real>
369 for (
int i = 0; i < N; ++i)
376 template <
int N,
typename Real>
379 for (
int i = 0; i < N; ++i)
386 template <
int N,
typename Real>
389 for (
int i = 0; i < N; ++i)
396 template <
int N,
typename Real>
399 if (scalar != (Real)0)
401 Real invScalar = ((Real)1) / scalar;
402 for (
int i = 0; i < N; ++i)
409 for (
int i = 0; i < N; ++i)
417 template <
int N,
typename Real>
425 template <
int N,
typename Real>
433 template <
int N,
typename Real>
436 for (
int i = 0; i < N; ++i)
443 template <
int N,
typename Real>
446 for (
int i = 0; i < N; ++i)
453 template <
int N,
typename Real>
456 Real dot = v0[0] * v1[0];
457 for (
int i = 1; i < N; ++i)
459 dot += v0[i] * v1[i];
464 template <
int N,
typename Real>
469 Real maxAbsComp = fabs(v[0]);
470 for (
int i = 1; i < N; ++i)
472 Real absComp = fabs(v[i]);
473 if (absComp > maxAbsComp)
475 maxAbsComp = absComp;
480 if (maxAbsComp > (Real)0)
483 length = maxAbsComp * sqrt(
Dot(scaled, scaled));
493 return sqrt(
Dot(v, v));
497 template <
int N,
typename Real>
502 Real maxAbsComp = fabs(v[0]);
503 for (
int i = 1; i < N; ++i)
505 Real absComp = fabs(v[i]);
506 if (absComp > maxAbsComp)
508 maxAbsComp = absComp;
513 if (maxAbsComp > (Real)0)
516 length = sqrt(
Dot(v, v));
518 length *= maxAbsComp;
523 for (
int i = 0; i < N; ++i)
533 if (length > (Real)0)
539 for (
int i = 0; i < N; ++i)
548 template <
int N,
typename Real>
551 if (v && 1 <= numInputs && numInputs <= N)
553 Real minLength =
Normalize(v[0], robust);
554 for (
int i = 1; i < numInputs; ++i)
556 for (
int j = 0; j < i; ++j)
558 Real dot =
Dot(v[i], v[j]);
562 if (length < minLength)
573 template <
int N,
typename Real>
578 for (
int i = 1; i < N; ++i)
590 int inext = imax + 1;
595 result[imax] = v[inext];
596 result[inext] = -v[imax];
600 result[imax] * result[imax] + result[inext] * result[inext];
601 Real invLength = ((Real)1) / sqrt(sqrDistance);
602 result[imax] *= invLength;
603 result[inext] *= invLength;
608 template <
int N,
typename Real>
612 if (v && numVectors > 0)
616 for (
int j = 1; j < numVectors; ++j)
619 for (
int i = 0; i < N; ++i)
621 if (vec[i] < vmin[i])
625 else if (vec[i] > vmax[i])
637 template <
int N,
typename Real>
641 for (
int i = 0; i < N; ++i)
649 template <
int N,
typename Real>
652 static_assert(N >= 2,
"Invalid dimension.");
654 for (
int i = 0; i < N - 1; ++i)
661 template <
int N,
typename Real>
666 for (i = 0; i < inject; ++i)
672 for (++j; i < N; ++i, ++j)
679 template <
int N,
typename Real>
682 static_assert(N >= 2,
"Invalid dimension.");
684 for (
int i = 0, j = 0; i < N - 1; ++i, ++j)
bool operator>=(Vector const &vec) const
gte::BSNumber< UIntegerType > abs(gte::BSNumber< UIntegerType > const &number)
GVector< Real > Project(GVector< Real > const &v, int reject)
DualQuaternion< Real > & operator*=(DualQuaternion< Real > &d, Real scalar)
bool operator>(Vector const &vec) const
GLsizei const GLfloat * value
bool operator<=(Vector const &vec) const
GLenum GLsizei GLsizei GLint * values
Vector< N, Real > GetOrthogonal(Vector< N, Real > const &v, bool unitLength)
GVector< Real > HLift(GVector< Real > const &v, Real last)
DualQuaternion< Real > operator+(DualQuaternion< Real > const &d)
GVector< Real > HProject(GVector< Real > const &v)
std::array< Real, N > mTuple
bool operator==(Vector const &vec) const
DualQuaternion< Real > & operator-=(DualQuaternion< Real > &d0, DualQuaternion< Real > const &d1)
DualQuaternion< Real > Dot(DualQuaternion< Real > const &d0, DualQuaternion< Real > const &d1)
Real Orthonormalize(int numElements, GVector< Real > *v, bool robust=false)
Real Normalize(GVector< Real > &v, bool robust=false)
GVector< Real > Lift(GVector< Real > const &v, int inject, Real value)
GLuint GLsizei GLsizei * length
Real const & operator[](int i) const
DualQuaternion< Real > Length(DualQuaternion< Real > const &d, bool robust=false)
bool operator<(Vector const &vec) const
bool operator!=(Vector const &vec) const
DualQuaternion< Real > operator-(DualQuaternion< Real > const &d)
DualQuaternion< Real > & operator+=(DualQuaternion< Real > &d0, DualQuaternion< Real > const &d1)
DualQuaternion< Real > & operator/=(DualQuaternion< Real > &d, Real scalar)
bool ComputeExtremes(int numVectors, GVector< Real > const *v, GVector< Real > &vmin, GVector< Real > &vmax)
Vector4< float > operator*(Transform const &M, Vector4< float > const &V)
static Vector Unit(int d)
DualQuaternion< Real > operator/(DualQuaternion< Real > const &d, Real scalar)