#include "Vector4.h"
#include "math.h"

using namespace std;

Vector4::Vector4()
{
	data[0]=0;
	data[1]=0;
	data[2]=0;
	data[3]=1;
}

Vector4::Vector4(Vector3 other)
{
	data[0]=other[0];
	data[1]=other[1];
	data[2]=other[2];
	data[3]=1;
}

Vector4::Vector4(float x, float y, float z)
{
	data[0]=x;
	data[1]=y;
	data[2]=z;
	data[3]=1;
}

Vector4::Vector4(float x, float y, float z, float w)
{
	data[0]=x;
	data[1]=y;
	data[2]=z;
	data[3]=w;
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Vector3 Vector4::toVector3()
{
	return Vector3(data[0], data[1], data[2]);
}

Vector4::~Vector4(void)
{}
