43 lines
1.6 KiB
C++
43 lines
1.6 KiB
C++
#ifndef _POINT_HH_
|
|
#define _POINT_HH_
|
|
|
|
#include <iostream>
|
|
#include <math.h>
|
|
|
|
using namespace std;
|
|
|
|
class Point
|
|
{
|
|
protected:
|
|
float x;
|
|
float y;
|
|
float z;
|
|
|
|
public:
|
|
Point(const float &_x = 0, const float &_y = 0, const float &_z = 0) { x = _x; y = _y; z = _z; } ;
|
|
Point(const Point &p) { x = p.x; y = p.y; z = p.z; } ;
|
|
Point(const float c[3]) { x = c[0] ; y = c[1] ; z = c[2] ; } ;
|
|
~Point() {};
|
|
float getX()const { return x; };
|
|
float getY()const { return y; };
|
|
float getZ()const { return z; };
|
|
void setX(const float &_x) { x = _x; };
|
|
void setY(const float &_y) { y = _y; };
|
|
void setZ(const float &_z) { z = _z; };
|
|
float squareDistance(const Point &p)const { return ((x-p.x)*(x-p.x))+((y-p.y)*(y-p.y))+((z-p.z)*(z-p.z)); };
|
|
float squareDistance(const float &mx, const float &my, const float &mz)const { return ((x-mx)*(x-mx))+((y-my)*(y-my))+((z-mz)*(z-mz)); };
|
|
float distance(const Point &p)const { return sqrt(((x-p.x)*(x-p.x))+((y-p.y)*(y-p.y))+((z-p.z)*(z-p.z))); };
|
|
float distance(const float &mx, const float &my, const float &mz)const { return sqrt(((x-mx)*(x-mx))+((y-my)*(y-my))+((z-mz)*(z-mz))); };
|
|
|
|
Point operator=(const Point &p) ;
|
|
bool operator==(const Point &p) const {return ((x == p.x) && (y == p.y) && (z == p.z)) ;} ;
|
|
bool operator!=(const Point &p) const {return !(*this == p) ;} ;
|
|
bool operator<(const Point &p) const ;
|
|
bool operator>(const Point &p) const {return (p < *this) ;} ;
|
|
bool operator<=(const Point &p) const {return (*this < p || *this == p) ;} ;
|
|
bool operator>=(const Point &p) const {return (p <= *this) ;} ;
|
|
friend ostream &operator<<(ostream & os, const Point &p);
|
|
};
|
|
|
|
#endif
|