#ifndef		__VECTOR_2D_H__
#define		__VECTOR_2D_H__

#include <math.h>

class Vector2D {
	protected:
		float x_;
		float y_;

	public:
		inline float x() const { return x_; }
		inline float y() const { return y_; }
		inline void x(float x_) { this->x_ = x_; }
		inline void y(float y_) { this->y_ = y_; }
		inline float Distance(const Vector2D &p) const { return (*this - p).Length(); }
		inline float Length() const { return sqrt(x()*x() + y()*y()); }
		inline Vector2D& operator+=(const Vector2D &p) { x_ += p.x(); y_ += p.y(); return *this; }
		inline Vector2D& operator-=(const Vector2D &p) { x_ -= p.x(); y_ -= p.y(); return *this; }
		inline Vector2D operator+(const Vector2D &p) const { return Vector2D(x() + p.x(), y() + p.y()); }
		inline Vector2D operator-(const Vector2D &p) const { return Vector2D(x() - p.x(), y() - p.y()); }

	public:
		Vector2D() : x_(0), y_(0) {}
		Vector2D(float x, float y) : x_(x), y_(y) {}
};


#endif		//__VECTOR_2D_H__
