#include "Vector2.h"
#include "math.h"

using namespace std;

Vector2::Vector2()
{
	data[0]=0;
	data[1]=0;
}

Vector2::Vector2(float x, float y)
{
	data[0]=x;
	data[1]=y;
}

float* Vector2::getData()
{
	return (float*)data;
}

void Vector2::print() const
{
	cout << '(' << data[0] << ", " << data[1] << ")" << endl;
}

bool Vector2::operator==(Vector2 other) const
{
	return (data[0] == other[0]) && (data[1] == other[1]);
}

float& Vector2::operator[](int ind)
{
	return data[ind];
}

Vector2 Vector2::operator*(float scale) const
{
	return Vector2(data[0]*scale, data[1]*scale);
}

Vector2& Vector2::operator*=(float scale)
{
	data[0] = data[0]*scale;
	data[1] = data[1]*scale;
	return *this;
}

Vector2 Vector2::operator*(Vector2 other) const
{
	return Vector2(data[0]*other[0], data[1]*other[1]);
}

Vector2& Vector2::operator*=(Vector2 other)
{
	data[0] = data[0]*other[0];
	data[1] = data[1]*other[1];
	return *this;
}

Vector2 Vector2::operator/(float scale) const
{
	return Vector2(data[0]/scale, data[1]/scale);
}

Vector2& Vector2::operator/=(Vector2 other)
{
	data[0] = data[0]/other[0];
	data[1] = data[1]/other[1];
	return *this;
}

Vector2 Vector2::operator+(Vector2 add) const
{
	return Vector2(data[0]+add[0], data[1]+add[1]);
}

Vector2& Vector2::operator+=(Vector2 other)
{
	data[0] = data[0]+other[0];
	data[1] = data[1]+other[1];
	return *this;
}

Vector2 Vector2::operator-(Vector2 sub) const
{
	return Vector2(data[0]-sub[0], data[1]-sub[1]);
}

Vector2& Vector2::operator-=(Vector2 other)
{
	data[0] = data[0]-other[0];
	data[1] = data[1]-other[1];
	return *this;
}

Vector2 Vector2::operator-() const
{
	return Vector2(-data[0], -data[1]);
}

Vector2::~Vector2(void)
{}
