7 #ifndef __FWDATATOOLS_VECTOR_HXX__ 8 #define __FWDATATOOLS_VECTOR_HXX__ 10 #include <fwCore/base.hpp> 25 Point() : x(0.), y(0.), z(0.)
28 Point(
const float p[3]) : x(p[0]), y(p[1]), z(p[2])
32 Point(
float _x,
float _y,
float _z) : x(_x), y(_y), z(_z)
36 bool operator<(
const Point& pt)
const 38 return ( this->x < pt.x
39 ||(this->x == pt.x && this->y < pt.y)
40 ||(this->x == pt.x && this->y == pt.y && this->z < pt.z) );
53 Vector() : x(0.), y(0.), z(0.)
60 Vector(
const Point& p1,
const Point& p2) : x(p2.x-p1.x), y(p2.y-p1.y), z(p2.z-p1.z)
63 Vector(T _x, T _y, T _z) : x(_x), y(_y), z(_z)
68 bool operator<(
const Vector& v)
const 71 ||(x == v.x && y < v.y)
72 ||(x == v.x && y == v.y && z < v.z) );
75 void operator=(
const Vector& v)
77 x = v.x; y = v.y; z = v.z;
80 void operator-=(
const Vector& v)
82 x -= v.x; y -= v.y; z -= v.z;
85 void operator+=(
const Vector& v)
87 x += v.x; y += v.y; z += v.z;
90 void operator*=(
const float val)
92 x = val*x; y = val*y; z = val*z;
95 void operator/=(
const float val)
97 x = x/val; y = y/val; z = z/val;
102 return x*x + y*y + z*z;
107 return std::sqrt(this->norm2());
112 T norm = this->norm();
113 *
this /= (norm == 0) ? 1 : norm;
125 return x*v.x + y*v.y + z*v.z;
128 void crossWith(
const Vector& v)
130 T _x = y * v.z - z * v.y;
131 T _y = z * v.x - x * v.z;
132 T _z = x * v.y - y * v.x;
148 #endif // __FWDATATOOLS_VECTOR_HXX__