23 #include "worldsimconfig.h"
24 #include "qglviewer/vec.h"
38 template <
bool Shared>
70 template <
bool Shared = false>
76 template <
bool OtherShared>
79 wVectorT(
const wVectorT& );
81 wVectorT(
const real *ptr );
83 wVectorT(
real *ptr );
88 operator QString()
const;
98 wVectorT& normalize();
106 real& operator[](
int i );
108 const real& operator[](
int i )
const;
113 const wVectorT& operator+()
const;
116 template <
bool OtherShared>
119 template <
bool OtherShared>
122 wVectorT& operator=(
const wVectorT &A );
124 template <
bool OtherShared>
127 template <
bool OtherShared>
130 template <
bool OtherShared>
134 template <
bool OtherShared>
138 template <
bool OtherShared>
142 template <
bool OtherShared>
146 template <
bool OtherShared>
153 template <
bool SharedA,
bool SharedB>
180 template <
bool Shared>
185 template <
bool Shared>
190 template <
bool Shared>
209 template <
bool OtherShared>
211 x(InternalData<false>::data[0]),
212 y(InternalData<false>::data[1]),
213 z(InternalData<false>::data[2]),
214 w(InternalData<false>::data[3])
224 x(InternalData<false>::data[0]),
225 y(InternalData<false>::data[1]),
226 z(InternalData<false>::data[2]),
227 w(InternalData<false>::data[3])
237 x(InternalData<false>::data[0]),
238 y(InternalData<false>::data[1]),
239 z(InternalData<false>::data[2]),
240 w(InternalData<false>::data[3])
248 template <
bool Shared>
273 x(InternalData<false>::data[0]),
274 y(InternalData<false>::data[1]),
275 z(InternalData<false>::data[2]),
276 w(InternalData<false>::data[3])
284 template <
bool Shared>
286 return QString(
"[%1, %2, %3, %4]").arg(x).arg(y).arg(z).arg(w);
289 template <
bool Shared>
294 template <
bool Shared>
299 template <
bool Shared>
304 template <
bool Shared>
309 template <
bool Shared>
312 const real n = sqrt(
self%
self );
320 template <
bool Shared>
323 const real n = norm();
331 template <
bool Shared>
336 template <
bool Shared>
341 template <
bool Shared>
342 template <
bool OtherShared>
347 template <
bool Shared>
348 template <
bool OtherShared>
353 template <
bool Shared>
363 template <
bool Shared>
364 template <
bool OtherShared>
373 template <
bool Shared>
374 template <
bool OtherShared>
383 template <
bool Shared>
384 template <
bool OtherShared>
393 template <
bool Shared>
394 template <
bool OtherShared>
396 return ( x==A.x && y==A.y && z==A.z );
399 template <
bool Shared>
400 template <
bool OtherShared>
402 return x*A.x + y*A.y + z*A.z;
405 template <
bool Shared>
406 template <
bool OtherShared>
415 template <
bool Shared>
416 template <
bool OtherShared>
421 template <
bool Shared>
423 return sqrt( x*x + y*y + z*z );
426 template <
bool Shared>
427 template <
bool SharedA,
bool SharedB>
429 return sqrt( (A.x-B.x)*(A.x-B.x) + (A.y-B.y)*(A.y-B.y) + (A.z-B.z)*(A.z-B.z) );
432 template <
bool Shared>
436 double costheta, sintheta;
438 costheta = cos(theta);
439 sintheta = sin(theta);
440 q.x += (costheta + (1 - costheta) * axis.x * axis.x) * x;
441 q.x += ((1 - costheta) * axis.x * axis.y - axis.z * sintheta) * y;
442 q.x += ((1 - costheta) * axis.x * axis.z + axis.y * sintheta) * z;
444 q.y += ((1 - costheta) * axis.x * axis.y + axis.z * sintheta) * x;
445 q.y += (costheta + (1 - costheta) * axis.y * axis.y) * y;
446 q.y += ((1 - costheta) * axis.y * axis.z - axis.x * sintheta) * z;
448 q.z += ((1 - costheta) * axis.x * axis.z - axis.y * sintheta) * x;
449 q.z += ((1 - costheta) * axis.y * axis.z + axis.x * sintheta) * y;
450 q.z += (costheta + (1 - costheta) * axis.z * axis.z) * z;
real operator%(const wVectorT< OtherShared > &A) const
return dot product
wVectorT< false > compProduct(const wVectorT< OtherShared > &A) const
component wise multiplication
static real distance(const wVectorT< SharedA > &A, const wVectorT< SharedB > &B)
return the distance from A to B
wVectorT & operator+=(const wVectorT< OtherShared > &A)
Operator +=.
real norm() const
return the norm of this vector
wVectorT & operator-=(const wVectorT< OtherShared > &A)
Operator -=.
wVectorT & normalize()
Normalize the vector.
bool operator==(const wVectorT< OtherShared > &A) const
Compare only the first three elements and return true if their are equals.
The Vec class represents 3D positions and 3D vectors.
wVectorT< false > normalized() const
Returns a normalized vector with the same direction of the current vector.
wVectorT< false > operator-() const
Operator - (unary)
wVectorT & rotateAround(wVectorT< false > axis, real theta)
rotate the position indicated by this wVectorT around the axis by the angle theta ...
static wVectorT< false > X()
X axis vector.
const wVectorT & operator+() const
Operator + (unary)
Internal data for wVectorT.
wVectorT< false > operator*(const wVectorT< OtherShared > &B) const
return cross product
wVectorT< false > scale(real s) const
return a new wVectorT with element scaled by s
static wVectorT< false > Y()
Y axis vector.
real & operator[](int i)
indexing operator
static wVectorT< false > Z()
Z axis vector.
wVectorT & operator=(const wVectorT &A)
Assignment.