/**
 * \file Point.h
 * \date 21.04.2002
 *
 * Interface for the Point class
 */

#ifndef COMMON_WORLD_POINT_H
#define COMMON_WORLD_POINT_H

class Vector;

/**
 * \class Point
 * \author Marek Lehuta
 * \author Matus Horvath
 * \brief Point in orthogonal coordinate system
 */
class Point
{
public:
// Construction and destruction
	Point() : xPos(0), yPos(0) {}
	Point(float x, float y) : xPos(x), yPos(y) {}
	Point(const Point& p) : xPos(p.xPos), yPos(p.yPos) {}

// Member access
	float GetX() const { return xPos; }
	float GetY() const { return yPos; }
	void SetX(float x) { xPos = x; }
	void SetY(float y) { yPos = y; }
	void Set(float x, float y){ xPos = x; yPos = y;}

// Operations 
	inline Point operator+(const Vector& vector) const;
	inline Point operator-(const Vector& vector) const;
	inline Vector operator-(const Point& point) const;

	inline const Point& operator=(const Point& point);
	inline const Point& operator+=(const Vector& vect);
	inline const Point& operator-=(const Vector& vect);

private:
	float xPos;
	float yPos;

};


#include "Common/World/Vector.h"

Point Point::operator+(const Vector& vector) const
{
	return Point(xPos + vector.GetX(), yPos + vector.GetY());
}

Point Point::operator-(const Vector& vector) const
{
	return Point(xPos - vector.GetX(), yPos - vector.GetY());
}

Vector Point::operator-(const Point& point) const
{
	return RectVector(xPos - point.xPos, yPos - point.yPos);
}


const Point& Point::operator=(const Point& point)
{
	xPos = point.xPos; yPos = point.yPos;
	return *this;
}

const Point& Point::operator+=(const Vector& vector)
{
	xPos += vector.GetX(); yPos += vector.GetY();
	return *this;
}

const Point& Point::operator-=(const Vector& vector)
{
	xPos -= vector.GetX(); yPos -= vector.GetY();
	return *this;
}

#endif // SUPPORT_POINT_H
