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

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

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


Vector3::Vector3() {
    X = Y = Z = 0.0f;
}

Vector3::Vector3(Real x, Real y, Real z) : X(x), Y(y), Z(z) {
}

Vector3::Vector3(const Vector3& v) : X(v.X), Y(v.Y), Z(v.Z) {
}

Vector3::Vector3(const Vector2& v) : X(v.X), Y(v.Y), Z(0.0f) {
}

void Vector3::init(Real x, Real y, Real z) {
    X = x;
    Y = y;
    Z = z;
}

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

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

    stringstream ss;

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


