
#ifndef __WFX_MATH_VECTOR2_H__
#define __WFX_MATH_VECTOR2_H__

#include <WFX/WFXIncludes.h>

namespace WFX {

    namespace math {

        /**
         * standard 2 element vector
         */
        class Vector2 {
            public:
                /** static members */
                static const Vector2 UNITX;
                static const Vector2 UNITY;
                static const Vector2 ZERO;
                
                /**
                 * elements
                 */
                Real X,Y;

                /** Ctor */
                Vector2();
                Vector2(Real x, Real y);
                Vector2(const Vector2& src);

                /** 
                 * takes a string and tries to parse it
                 * values are whitespace seperated
                 */
                void parseStr(std::string str);

                Vector2& operator =(const Vector2& src);
                bool operator ==(const Vector2 src);
                bool operator !=(const Vector2 src);

                Real& operator [](unsigned int id) {
                    assert(id < 2);
                    return *(&X+id);
                }

                inline Vector2 operator /(Real s) const {
                    assert( s != 0.0 );
                    Vector2 kDiv;
                    Real fInv = 1.0 / s;
                    kDiv.X = X * fInv;
                    kDiv.Y = Y * fInv;
                    return kDiv;
                }

                inline Vector2 operator -() const {
                    Vector2 kNeg;
                    kNeg.X = -X;
                    kNeg.Y = -Y;
                    return kNeg;
                }

                inline friend Vector2 operator *(Real s, const Vector2& v) {
                    Vector2 kProd;
                    kProd.X = s * v.X;
                    kProd.Y = s * v.Y;
                    return kProd;
                }

                // arithmetic updates
                inline Vector2& operator +=(const Vector2& v) {
                    X += v.X;
                    Y += v.Y;
                    return *this;
                }

                inline Vector2& operator -=(const Vector2& v) {
                    X -= v.X;
                    Y -= v.Y;
                    return *this;
                }

                inline Vector2 operator *(Real s) {
                    Vector2 r;
                    r.X = X*s;
                    r.Y = Y*s;
                    return r;
                }

                inline Vector2 operator /(Real s) {
                    Vector2 r;
                    r.X = X/s;
                    r.Y = Y/s;
                    return r;
                }

                inline Vector2& operator *=(Real s) {
                    X *= s;
                    Y *= s;
                    return *this;
                }

                inline Vector2& operator /=(Real s) {
                    assert(s != 0.0 );
                    Real fInv = 1.0 / s;
                    X *= fInv;
                    Y *= fInv;
                    return *this;
                }

                /**
                 * prints some debug info...
                 */
                const void printDebug() const {
                    LOG(" |" << X << "| |" << Y << "|");
                }


        
            protected:
                
                
        };

    }

}


#endif //include guard


