
#include <WFX/math/Vector2.h>
#include <WFX/util/StringUtils.h>

using namespace WFX::math;
using namespace WFX::util;
using namespace std;

/** static members */
const Vector2 Vector2::UNITX(1.0f,0.0f);
const Vector2 Vector2::UNITY(0.0f,1.0f);
const Vector2 Vector2::ZERO(0.0f,0.0f);

Vector2::Vector2() {
    X = 0.0f;
    Y = 0.0f;
}

Vector2::Vector2(Real x, Real y) {
    X = x;
    Y = y;
}

Vector2::Vector2(const Vector2& src) {
    X = src.X;
    Y = src.Y;
}

Vector2& Vector2::operator =(const Vector2& src) {
    X = src.X;
    Y = src.Y;
    return *this;
}

bool Vector2::operator ==(const Vector2 src) {
    return ((X == src.X) && (Y == src.Y));
}

bool Vector2::operator !=(const Vector2 src) {
    return ((X != src.X) && (Y != src.Y));
}

void Vector2::parseStr(std::string str) {
    vector<string> tokens = StringUtils::tokenize(str," ");

    if (tokens.size() < 2)
        THROW("Unable to parse " << str << " into a Vector2");

    stringstream ss;

    X = StringUtils::toReal(tokens[0]);
    Y = StringUtils::toReal(tokens[1]);
}

