//Vector2.h
#ifndef _VECTOR2_H_
#define _VECTOR2_H_

#define PI 3.141592654f
#define DEGTORAD(degree) ((PI / 180.0f) * (degree))
#define RADTODEG(radian) ((180.0f / PI) * (radian))

class Vector2
{
	public:
	Vector2() : x(0.0f), y(0.0f) {}
	Vector2(const float &x, const float &y) : x(x), y(y) {}
	Vector2(const Vector2 &vector) : x(vector.x), y(vector.y) {}
	~Vector2() {}

	void set(float xx, float yy) { x = xx; y = yy; }

	operator const float*() const;
	Vector2  operator+  (const Vector2 &vector) const;
	Vector2& operator+= (const Vector2 &vector);
	Vector2  operator-  (const Vector2 &vector) const;
	Vector2& operator-= (const Vector2 &vector);
	Vector2  operator*  (const Vector2 &vector) const;
	Vector2  operator*  (const float &f) const;
	Vector2& operator*= (const float &f);
	Vector2  operator/  (const float &f) const;
	Vector2& operator/= (const float &f);
	Vector2& operator=  (const Vector2 &vector);
	bool	 operator== (const Vector2 &vector) const; //Not to be used unless in some bizarre circumstance where 
																//floats aren't terribly slow at comparisons.
	void normalise();
	Vector2 perpendicular();
	float getLength() const;
	float getLengthSqrd() const;

	static float dot(const Vector2 &left, const Vector2 &right);
	static float cross(const Vector2 &left, const Vector2 &right);
	static Vector2 vmin(const Vector2 &a, const Vector2 &b);
	static Vector2 vmax(const Vector2 &a, const Vector2 &b);
	static bool isRoughlyEqual(const Vector2 &a, const Vector2 &b);

	float x, y;
};

class Vector2i
{
	public:
	Vector2i() : x(0), y(0) {}
	Vector2i(const int &x, const int &y) : x(x), y(y) {}
	Vector2i(const Vector2i &vector) : x(vector.x), y(vector.y) {}
	~Vector2i() {}

	void set(int xx, int yy) { x = xx; y = yy; }

	operator const int*() const;
	Vector2i  operator+  (const Vector2i &vector) const;
	Vector2i& operator+= (const Vector2i &vector);
	Vector2i  operator-  (const Vector2i &vector) const;
	Vector2i& operator-= (const Vector2i &vector);
	Vector2i  operator*  (const Vector2i &vector) const;
	Vector2i  operator*  (const int &n) const;
	Vector2i& operator*= (const int &n);
	Vector2i  operator/  (const int &n) const;
	Vector2i& operator/= (const int &n);
	Vector2i& operator=  (const Vector2i &vector);
	bool	 operator== (const Vector2i &vector) const; 

	float getLength() const;
	int getLengthSqrd() const;
	Vector2i perpendicular();

	static int dot(const Vector2i &left, const Vector2i &right);
	static int cross(const Vector2i &left, const Vector2i &right);
	static Vector2i vmin(const Vector2i &a, const Vector2i &b);
	static Vector2i vmax(const Vector2i &a, const Vector2i &b);

	int x, y;
};


#endif
