20 #ifndef MIRTK_Vector4D_H 21 #define MIRTK_Vector4D_H 23 #include "mirtk/Math.h" 24 #include "mirtk/Stream.h" 38 typedef T ComponentType;
104 template <
typename S>
135 template <
typename S>
139 template <
typename S>
312 template <
typename T>
354 return ((
_z == v._z) && (
_y == v._y) && (
_x == v._x) && (
_t == v._t));
360 return ((
_z != v._z) || (
_y != v._y) || (
_x != v._x) || (
_t != v._t));
366 return ( (
_t < v._t) ||
367 ((
_t == v._t) && (
_z < v._z)) ||
368 ((
_t == v._t) && (
_z == v._z) && (
_y < v._y)) ||
369 ((
_t == v._t) && (
_z == v._z) && (
_y == v._y) && (
_x < v._x)));
375 return ( (
_t > v._t) ||
376 ((
_t == v._t) && (
_z > v._z)) ||
377 ((
_t == v._t) && (
_z == v._z) && (
_y > v._y)) ||
378 ((
_t == v._t) && (
_z == v._z) && (
_y == v._y) && (
_x > v._x)));
384 return ((*
this < v) || (*
this == v));
390 return ((*
this > v) || (*
this == v));
415 _x =
static_cast<T
>(
_x/length);
416 _y =
static_cast<T
>(
_y/length);
417 _z =
static_cast<T
>(
_z/length);
418 _t =
static_cast<T
>(_t/length);
431 return v1._x*v2._x + v1._y*v2._y + v1._z*v2._z + v1._t*v2._t;
448 cerr <<
"Invalid 4D vector element index: " << n << endl;
449 cerr <<
"Set breakpoint in " << __FILE__ <<
":" << __LINE__ <<
" to debug." << endl;
456 inline T put(
Vector4D<T> &v,
int n,
const T &value)
459 case 0: v._x = value;
460 case 1: v._y = value;
461 case 2: v._z = value;
462 case 3: v._t = value;
464 cerr <<
"Invalid 4D vector element index: " << n << endl;
465 cerr <<
"Set breakpoint in " << __FILE__ <<
":" << __LINE__ <<
" to debug." << endl;
475 template <
typename T>
478 return Vector4D<T>(pow(v._x, e), pow(v._y, e), pow(v._z, e), pow(v._t, e));
482 template <
typename T>
485 return Vector4D<T>(pow(v._x, e), pow(v._y, e), pow(v._z, e), pow(v._t, e));
489 template <
typename T>
492 return Vector4D<T>(sqrt(v._x), sqrt(v._y), sqrt(v._z), sqrt(v._t));
498 #endif // __IRTKVECTOR4D_H Vector4D operator-() const
Vector4D & operator+=(S s)
Vector4D & operator=(T s)
bool operator<(const Vector4D &v) const
bool operator==(const Vector4D &v) const
bool operator!=(const Vector4D &v) const
Vector4D & operator-=(S s)
bool operator<=(const Vector4D &v) const
Vector4D & operator*=(S s)
Vector4D & operator/=(const Vector4D &v)
Vector4D operator/(const Vector4D &v) const
bool operator>(const Vector4D &v) const
Vector4D operator*(S s) const
static double DotProduct(const Vector4D &v1, const Vector4D &v2)
Vector4D operator+(S s) const
bool operator>=(const Vector4D &v) const