Go to the documentation of this file. 1 #ifndef __GfxTL_VECTORXD_HEADER__
2 #define __GfxTL_VECTORXD_HEADER__
4 #ifndef _USE_MATH_DEFINES
5 #define _USE_MATH_DEFINES
19 template<
unsigned int D,
class T >
21 :
public MatrixXX< 1, D, T >
42 memcpy(SuperType::_m,
v,
sizeof(SuperType::_m));
48 for (
unsigned int i = 0; i <
Dim; ++i)
50 SuperType::_m[i] = (
T)
v[i];
57 for (
unsigned int i = 0; i <
Dim; ++i)
59 SuperType::_m[i] = (
T)
v[i];
69 for (
unsigned int i = 0; i <
Dim; ++i)
79 for (
unsigned int i = 0; i <
Dim; ++i)
85 template<
unsigned int X >
88 for (
unsigned int i = 0; i <
std::min(D, X); ++i)
90 SuperType::_m[i] = vec[i];
92 for (
unsigned int i = X; i < D; ++i)
100 for (
unsigned int i = 0; i < D - 1; ++i)
102 SuperType::_m[i] =
v[i];
104 SuperType::_m[D - 1] =
s;
109 for (
unsigned int i = 0; i < D - 2; ++i)
111 SuperType::_m[i] =
v[i];
113 SuperType::_m[D - 2] =
s;
114 SuperType::_m[D - 1] = s2;
119 for (
unsigned int i = 0; i < D - 2; ++i)
121 SuperType::_m[i] =
v[i];
123 SuperType::_m[D - 3] =
s;
124 SuperType::_m[D - 2] = s2;
125 SuperType::_m[D - 1] = s3;
133 SuperType::_m[0] = x;
134 SuperType::_m[1] = y;
142 SuperType::_m[0] = x;
143 SuperType::_m[1] = y;
144 SuperType::_m[2] = z;
152 SuperType::_m[0] = x;
153 SuperType::_m[1] = y;
154 SuperType::_m[2] = z;
155 SuperType::_m[3] = w;
173 for (
unsigned int i = 0; i < D; ++i)
175 SuperType::_m[i] = (
T)
v[0][i];
182 return SuperType::_m[i];
187 return SuperType::_m[i];
202 for (
unsigned int i = 0; i < D; ++i)
204 SuperType::_m[i] +=
a.Data()[i];
211 for (
unsigned int i = 0; i < D; ++i)
213 SuperType::_m[i] -=
a.Data()[i];
221 for (
unsigned int i = 0; i < D; ++i)
223 SuperType::_m[i] *=
s;
231 for (
unsigned int i = 0; i < D; ++i)
233 SuperType::_m[i] /=
s;
251 for (
unsigned int i = 0; i < D; ++i)
253 s += SuperType::_m[i] * SuperType::_m[i];
261 for (
unsigned int i = 0; i < D; ++i)
263 s +=
abs(SuperType::_m[i]);
270 memset(SuperType::_m, 0,
sizeof(SuperType::_m));
275 return memcmp(SuperType::_m,
a._m,
sizeof(SuperType::_m)) == 0;
281 diff = SuperType::_m[0] -
v[0];
283 for (
unsigned int i = 1; i <
Dim; ++i)
285 diff = SuperType::_m[i] -
v[i];
299 for (
unsigned int i = 1; i <
Dim; ++i)
310 for (
unsigned int i = 1; i <
Dim; ++i)
324 for (
unsigned int i = 0; i <
Dim; ++i)
326 p[i] = SuperType::_m[i];
337 return SuperType::_m;
341 return SuperType::_m + D;
345 return SuperType::_m;
349 return SuperType::_m + D;
353 template<
unsigned int D,
class T >
357 for (
unsigned int i = 0; i < D; ++i)
369 template<
unsigned int D,
class T >
374 for (
unsigned int i = 0; i < D; ++i)
410 template<
unsigned int D,
class T >
415 for (
unsigned int i = 0; i < D; ++i)
452 template<
unsigned int D,
class T >
457 for (
unsigned int i = 1; i < D; ++i)
459 retVal +=
a[i] * b[i];
465 template<
unsigned int A,
unsigned int B,
class T >
469 for (
unsigned int c = 0;
c < B; ++
c)
470 for (
unsigned int r = 0; r <
A; ++r)
472 m[
c][r] =
a[r] * b[
c];
477 template<
unsigned int D,
class T >
481 for (
unsigned int c = 0;
c < D; ++
c)
484 for (
unsigned int r =
c + 1; r < D; ++r)
486 m[
c][r] =
a[r] *
a[
c];
504 return a[0] * b[0] +
a[1] * b[1];
511 return a[0] * b[0] +
a[1] * b[1] +
a[2] * b[2];
518 return a[0] * b[0] +
a[1] * b[1] +
a[2] * b[2] +
a[3] * b[3];
521 template<
unsigned int D,
class T >
525 for (
unsigned int i = 0; i < D; ++i)
557 template<
unsigned int D,
class T >
561 for (
unsigned int i = 0; i < D; ++i)
593 template<
unsigned int D,
class T >
597 for (
unsigned int i = 0; i < D; ++i)
634 a[2] * b[0] -
a[0] * b[2],
a[0] * b[1] -
a[1] * b[0]);
637 template<
unsigned int D,
class T >
642 for (
unsigned int r = 0; r < D; ++r)
644 m[r] =
min(
a[r], b[r]);
649 template<
unsigned int D,
class T >
654 for (
unsigned int r = 0; r < D; ++r)
656 m[r] =
max(
a[r], b[r]);
661 template<
unsigned int D,
class T >
665 for (
unsigned int i = 0; i < D; ++i)
730 T rad = (deg * (
T)
M_PI / (
T)180.0) / (
T)2.0;
731 (*this)[0] = std::cos(rad);
741 (*this)[0] = std::cos(rad / 2);
742 T s = std::sin(rad / 2);
757 *deg = ((
T)std::acos((*
this)[0]) * (
T)2.0) * (
T)180.0 / (
T)
M_PI;
758 T sinA = (
T)
std::sqrt(1.0 - (*
this)[0] * (*this)[0]);
759 T absSin = sinA < 0 ? -sinA : sinA;
760 if (absSin < (
T)0.00005)
764 *a0 = (*this)[1] / sinA;
765 *a1 = (*this)[2] / sinA;
766 *a2 = (*this)[3] / sinA;
771 *rad = ((
T)std::acos((*
this)[0]) * (
T)2.0);
772 T sinA = (
T)
std::sqrt(1.0 - (*
this)[0] * (*this)[0]);
773 T absSin = sinA < 0 ? -sinA : sinA;
774 if (absSin < (
T)0.00005)
778 *a0 = (*this)[1] / sinA;
779 *a1 = (*this)[2] / sinA;
780 *a2 = (*this)[3] / sinA;
785 Rotation(deg, &(*axis)[0], &(*axis)[1], &(*axis)[2]);
808 for (
unsigned int i = 0; i < 4; ++i)
823 T xy =
q[1] *
q[2] * 2;
824 T zw =
q[0] *
q[3] * 2;
825 T xz =
q[1] *
q[3] * 2;
826 T xw =
q[1] *
q[0] * 2;
827 T yw =
q[0] *
q[2] * 2;
828 T yz =
q[2] *
q[3] * 2;
830 (*mat)[0][0] = ww + xx - yy - zz;
831 (*mat)[0][1] = xy + zw;
832 (*mat)[0][2] = xz - yw;
834 (*mat)[1][0] = xy - zw;
835 (*mat)[1][1] = ww - xx + yy - zz;
836 (*mat)[1][2] = yz + xw;
838 (*mat)[2][0] = xz + yw;
839 (*mat)[2][1] = yz - xw;
840 (*mat)[2][2] = ww - xx - yy + zz;
861 a[0] * b[0] -
a[1] * b[1] -
a[2] * b[2] -
a[3] * b[3],
862 a[0] * b[1] +
a[1] * b[0] +
a[2] * b[3] -
a[3] * b[2],
863 a[0] * b[2] -
a[1] * b[3] +
a[2] * b[0] +
a[3] * b[1],
864 a[0] * b[3] +
a[1] * b[2] -
a[2] * b[1] +
a[3] * b[0]
void Rotation(T *deg, VectorXD< 3, T > *axis) const
VectorXD< D, T > sqrt(const VectorXD< D, T > &a)
ThisType & operator=(const SuperType &s)
void Rotation(T *deg, T *a0, T *a1, T *a2) const
void RotationRad(T *rad, T *a0, T *a1, T *a2) const
void Rotate(const V &p, V *r) const
VectorXD< 3, double > Vector3Dd
VectorXD< 2, float > vec2
Quaternion< T > Inverse() const
VectorXD< 1, double > Vec1d
MatrixXX< C, R, T > max(const MatrixXX< C, R, T > &a, const MatrixXX< C, R, T > &b)
MatrixXX< B, A, T > OuterProduct(const VectorXD< A, T > &a, const VectorXD< B, T > &b)
Quaternion< T > Conjugate() const
VectorXD< 3, float > vec3
MatrixXX< 1, D, T > SuperType
VectorXD< D, T > operator/(const VectorXD< D, T > &a, T s)
ScalarType SqrLength() const
const ScalarType * end() const
VectorXD< 3, unsigned int > uvec3
VectorXD(const S x, typename std::enable_if< std::is_convertible< S, ScalarType >::value, NullClass >::type &dummy= *((NullClass *) 0))
VectorXD< 2, double > Vec2d
MatrixXX< C, R, T > min(const MatrixXX< C, R, T > &a, const MatrixXX< C, R, T > &b)
ScalarType operator[](unsigned int i) const
ScalarType Distance(const VectorXD< D, T > &v) const
static ScalarT Abs(ScalarT s)
VectorXD(const VectorXD< D - 2, T > &v, T s, T s2)
VectorXD< D, T > & operator*=(S s)
VectorXD< 1, float > vec1
const typedef ScalarType * const_iterator
ScalarType L1Distance(const VectorXD< D, T > &v) const
Quaternion< T > & operator*=(const Quaternion< T > &b)
VectorXD< 4, T > SuperType
VectorXD< 3, float > Vector3Df
VectorXD< 2, float > vec2f
void Rotation(T deg, T a0, T a1, T a2)
double a(double t, double a0, double j)
std::shared_ptr< Value > value()
VectorXD< 1, unsigned int > uvec1
std::ostream & operator<<(std::ostream &o, const Array< DimT, IteratorT > &a)
VectorXD< 4, float > Vector4Df
std::vector< T > abs(const std::vector< T > &v)
ScalarType MaxDistance(const VectorXD< D, T > &v) const
VectorXD< 4, unsigned int > uvec4
VectorXD< 1, float > Vector1Df
ThisType & operator=(T v)
const ScalarType * begin() const
VectorXD< 3, double > Vec3d
VectorXD< D, T > & operator/=(S s)
VectorXD< 4, double > Vec4d
VectorXD(const SuperType &s)
Quaternion(T w, T x, T y, T z)
void Rotation(T deg, const VectorXD< 3, T > &a)
const MatrixXX< C, R, T > operator*(T s, const MatrixXX< C, R, T > &a)
VectorXD(const VectorXD< D, S > &v)
VectorXD< 1, float > Vec1f
VectorXD(const VectorXD< D, T > &v)
VectorXD< 1, float > vec1f
ThisType & operator=(const ThisType &v)
const VectorXD< 3, T > operator%(const VectorXD< 3, T > &a, const VectorXD< 3, T > &b)
VectorXD< D, T > operator-() const
class A(deque< T, A >)) ARMARX_OVERLOAD_STD_HASH_FOR_ITERABLE((class T
Enables hashing of std::list.
VectorXD(const VectorXD< D - 1, T > &v, T s)
VectorXD(const VectorXD< X, T > &vec)
VectorXD< 3, float > vec3f
double v(double t, double v0, double a0, double j)
VectorXD< 2, float > Vector2Df
void RotationRad(T rad, T a0, T a1, T a2)
static void AssertEqual()
ThisType & operator=(const MatrixXX< 1, D, S > &v)
VectorXD< 4, float > Vec4f
VectorXD< 1, double > Vector1Dd
const MatrixXX< C, R, T > operator+(const MatrixXX< C, R, T > &a, const MatrixXX< C, R, T > &b)
void RotationMatrix(M *mat)
bool operator==(const VectorXD< D, T > &a) const
ScalarType L1Length() const
VectorXD< 3, float > Vec3f
VectorXD< D, T > & operator+=(const MatrixXX< 1, D, T > &a)
VectorXD< D, T > ThisType
VectorXD< 4, float > vec4
ScalarType & operator[](unsigned int i)
VectorXD< 2, unsigned int > uvec2
VectorXD< 2, double > Vector2Dd
MatrixXX< C, R, T > operator-(const MatrixXX< C, R, T > &a)
VectorXD< Dim+1, T > Homogene() const
double s(double t, double s0, double v0, double a0, double j)
VectorXD(const VectorXD< D - 3, T > &v, T s, T s2, T s3)
ScalarType SqrDistance(const VectorXD< D, T > &v) const
VectorXD< 2, float > Vec2f
VectorXD(T x, T y, T z, T w)
VectorXD< 4, double > Vector4Dd
VectorXD< D, T > & operator-=(const MatrixXX< 1, D, T > &a)
MatrixXX< D, D, T > SqrOuterProduct(const VectorXD< D, T > &a)
ScalarType Length() const
VectorXD< 4, float > vec4f