owlps/GuiNuMo-server/point.hh

37 lines
1.1 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() { x = 0; y = 0; z = 0; };
Point(const Point &p) { x = p.x; y = p.y; z = p.z; } ;
Point(float my_x, float my_y, float my_z) { x = my_x; y = my_y; z = my_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