#include <math.h>
#include "amra_point.h"


Point::Point(float x, float y, float z)
//constructor
{
	X = x;
	Y = y;
	Z = z;
}

Point::Point(const Point& p)
//initialisation from another point
{
	X = p.X;
	Y = p.Y;
	Z = p.Z;
}

Point& Point::operator=(const Point& p)
//assignment
{
	
	if(this == &p) return *this;
	
	X = p.X;
	Y = p.Y;
	Z = p.Z;
	
	return *this;
}

Point& Point::operator+(const Point& p)
{
	X += p.X;
	Y += p.Y;
	Z += p.Z;

	return *this;
}

Point& Point::operator/(const float& s)
{
	X /= s;
	Y /= s;
	Z /= s;

	return *this;
}

float Point::dist(const Point& p)
{
	return sqrt((X - p.X) * (X - p.X) + (Y - p.Y) * (Y - p.Y) + (Z - p.Z) * (Z - p.Z));
}

ostream& operator<<(ostream& s,Point p)
//writing
{	
	s << "(" << p.X << "," << p.Y << "," << p.Z << ")";
	return s;
}

istream& operator>>(istream& s,Point& p)
//reading
{
	s >> p.X;
	s >> p.Y;
	s >> p.Z;
	return s;
}
