///////////////////////////////////////////////////////////////////////////////
//  S2DI.cpp

#include <math.h>
#include "3DDefine.h"
#include "S2D.h"
#include "S2DI.h"

namespace math3d {

S2DI::S2DI() :
	x(0),
	y(0)
{
}

S2DI::S2DI(int x_, int y_) :
	x(x_),
	y(y_)
{
}

S2DI::~S2DI()
{
}

S2DI S2DI::operator+(const S2DI& Obj) const
{
	return S2DI(x + Obj.x, y + Obj.y);
}

S2DI S2DI::operator-(const S2DI& Obj) const
{
	return S2DI(x - Obj.x, y - Obj.y);
}

S2DI S2DI::operator*(int n) const
{
	return S2DI(x * n, y * n);
}

S2DI S2DI::operator/(int n) const
{
	return S2DI(x / n, y / n);
}

S2DI S2DI::operator/(float f) const
{
	return S2DI(static_cast<int>(x / f), static_cast<int>(y / f));
}

S2DI& S2DI::operator+=(const S2DI& Obj)
{
	x += Obj.x;
	y += Obj.y;

	return *this;
}

bool S2DI::operator==(const S2DI& Obj) const
{
	return ((x == Obj.x) && (y == Obj.y));
}

bool S2DI::operator!=(const S2DI& Obj) const
{
	return ((x != Obj.x) || (y != Obj.y));
}

S2D S2DI::GetS2D() const
{
	return S2D(static_cast<float>(x), static_cast<float>(y));
}

void S2DI::Set(int x_, int y_)
{
	x = x_;
	y = y_;
}

float S2DI::Distance(const S2DI& pos1, const S2DI& pos2)
{
	return sqrtf(static_cast<float>(POW2(pos1.x - pos2.x) + POW2(pos1.y - pos2.y)));
}

}

