36 lines
1.0 KiB
C++
36 lines
1.0 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(float _x = 0, float _y = 0, float _z = 0) { x = _x; y = _y; z = _z; } ;
|
|
Point(const Point &p) { x = p.x; y = p.y; z = p.z; } ;
|
|
~Point() {};
|
|
float getX()const { return x; };
|
|
float getY()const { return y; };
|
|
float getZ()const { return z; };
|
|
void setX(float my_x) { x = my_x; };
|
|
void setY(float my_y) { y = my_y; };
|
|
void setZ(float my_z) { z = my_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(float mx, float my, 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))); };
|
|
Point operator=(const Point &p);
|
|
bool operator==(const Point &p)const;
|
|
bool operator!=(const Point &p)const;
|
|
friend ostream &operator<<(ostream & os, const Point &p);
|
|
};
|
|
|
|
#endif
|