24 #include "mirtk/Object.h" 25 #include "mirtk/Math.h" 58 Point(
double,
double,
double);
61 Point(
const double [3]);
95 operator const double *()
const;
267 #include "mirtk/Vector.h" 268 #include "mirtk/Vector3.h" 269 #include "mirtk/Matrix.h" 278 ostream& operator <<(ostream&,
const Point&);
281 istream& operator >>(istream&,
Point&);
330 if ((v.
Rows() < 0) || (v.
Rows() > 3)) {
331 cerr <<
"Point::Point(const Vector&) Illegal dimension: " << v.
Rows() << endl;
365 cerr <<
"Point::operator []: Invalid coorindate index: " << i << endl;
378 cerr <<
"Point::operator []: Invalid coorindate index: " << i << endl;
396 inline Point::operator
double *()
402 inline Point::operator
const double *()
const 649 return (
Point(*
this) += v);
655 return (
Point(*
this) -= v);
661 return (
Point(*
this) *= v);
667 return (
Point(*
this) /= v);
674 cerr <<
"Point::operator+=(const Vector& v): Size mismatch" << endl;
687 cerr <<
"Point::operator-=(const Vector& v): Size mismatch" << endl;
700 cerr <<
"Point::operator*=(const Vector& v): Size mismatch" << endl;
713 cerr <<
"Point::operator/=(const Vector& v): Size mismatch" << endl;
727 cerr <<
"Point::operator+(const Vector& v): Size mismatch" << endl;
741 cerr <<
"Point::operator-(const Vector& v): Size mismatch" << endl;
755 cerr <<
"Point::operator*(const Vector& v): Size mismatch" << endl;
769 cerr <<
"Point::operator/(const Vector& v): Size mismatch" << endl;
782 if ((m.
Rows() != 4) && (m.
Cols() != 4)) {
783 cerr <<
"Point::operator*(const Matrix& m): Size mismatch" << endl;
786 tmp.
_x =
_x * m(0, 0) +
_y * m(0, 1) +
_z * m(0, 2) + m(0, 3);
787 tmp.
_y =
_x * m(1, 0) +
_y * m(1, 1) +
_z * m(1, 2) + m(1, 3);
788 tmp.
_z =
_x * m(2, 0) +
_y * m(2, 1) +
_z * m(2, 2) + m(2, 3);
796 if ((m.
Rows() != 4) && (m.
Cols() != 4)) {
797 cerr <<
"Point::operator*(const Matrix& m): Size mismatch" << endl;
800 tmp.
_x =
_x * m(0, 0) +
_y * m(0, 1) +
_z * m(0, 2) + m(0, 3);
801 tmp.
_y =
_x * m(1, 0) +
_y * m(1, 1) +
_z * m(1, 2) + m(1, 3);
802 tmp.
_z =
_x * m(2, 0) +
_y * m(2, 1) +
_z * m(2, 2) + m(2, 3);
816 const double dx =
_x - p.
_x;
817 const double dy =
_y - p.
_y;
818 const double dz =
_z - p.
_z;
819 return dx*dx + dy*dy + dz*dz;
837 #endif // MIRTK_Point_H int operator<(const Point &) const
Comparison operator <.
int operator!=(const Point &) const
Comparison operator != (if USE_STL is defined, negate == operator)
Point operator-(const Point &) const
Return result of point substraction.
double SquaredDistance() const
Squared distance from origin.
Point operator/(const Point &) const
Return result of point division.
Point operator+(const Point &) const
Return result of point addition.
int operator==(const Point &) const
Comparison operator ==.
Point & operator*=(const Point &)
Multiplication operator for point.
double _x
x coordinate of Point
Point operator*(const Point &) const
Return result of point multiplication.
int Cols() const
Get number of columns.
double & operator()(int i)
Get reference to i-th point coordinate.
int Rows() const
Returns number of rows.
Point & operator-=(const Point &)
Substraction operator for point.
virtual ~Point()
Default destructor.
Point & operator=(const Point &)
Copy operator for point.
double _z
z coordinate of Point
Point & operator/=(const Point &)
Division operator for point.
double _y
y coordinate of Point
int Rows() const
Get number of rows.
int operator>(const Point &) const
Comparison operator >
double Distance() const
Distance from origin.
Point & operator+=(const Point &)
Addition operator for point.
double & operator[](int i)
Get reference to i-th point coordinate.