TVec2


This template represents 2D vector.

You can find more information in comments below.

template<class TYPE>
union TVec2
{
    struct // As coordinate
    {
        union
        {
            TYPE X;
            TVec1<TYPE> V1;
        };
        TYPE Y;
    };
    struct // As elements
    {
        TYPE _1;
        TYPE _2;
    };
    TYPE Data[2]; // Array of elements
    TMatrix<TYPE, 1, 2> M; // As matrix

    TYPE operator[](const size_t index) const; // Return element by index. Only 0 and 1 are accepted as indices. Used only when TVec2 object is a constant object
    TYPE &operator[](const size_t index); // Return element by index. Only 0 and 1 are accepted as indices
    explicit operator TPoint<TYPE>(); const // Convert to TPoint
    explicit operator TVec3<TYPE>() const; // Convert to TVec3
    explicit operator TVec4<TYPE>() const; // Convert to TVec4
    explicit operator TQuaternion<TYPE>() const; // Convert to TQuaternion
};

Additionally following operators exists.

template<class TYPE>
bool operator==(const TVec2<TYPE> &a, const TVec2<TYPE> &b); // Check whether vectors are equal. Can be used for non-float data types only
template<class TYPE>
bool operator!=(const TVec2<TYPE> &a, const TVec2<TYPE> &b); // Check whether vectors aren't equal. Can be used for non-float data types only
template<class TYPE>
TVec2<TYPE> operator+(const TVec2<TYPE> &v, const TYPE val); // Add vector and scalar
template<class TYPE>
TVec2<TYPE> operator-(const TVec2<TYPE> &v, const TYPE val); // Subtract vector and scalar
template<class TYPE>
TVec2<TYPE> operator*(const TVec2<TYPE> &v, const TYPE val); // Multiply vector and scalar
template<class TYPE>
TVec2<TYPE> operator/(const TVec2<TYPE> &v, const TYPE val); // Divide vector and scalar
template<class TYPE>
TVec2<TYPE> operator+(const TYPE val, const TVec2<TYPE> &v); // Add scalar and vector
template<class TYPE>
TVec2<TYPE> operator-(const TYPE val, const TVec2<TYPE> &v); // Subtract scalar and vector
template<class TYPE>
TVec2<TYPE> operator*(const TYPE val, const TVec2<TYPE> &v); // Multiply scalar and vector
template<class TYPE>
TVec2<TYPE> operator/(const TYPE val, const TVec2<TYPE> &v); // Divide scalar and vector
template<class TYPE>
TVec2<TYPE> &operator+=(TVec2<TYPE> &v, const TYPE val); // Add scalar to vector
template<class TYPE>
TVec2<TYPE> &operator-=(TVec2<TYPE> &v, const TYPE val); // Subtract scalar from vector
template<class TYPE>
TVec2<TYPE> &operator*=(TVec2<TYPE> &v, const TYPE val); // Multiply vector by scalar
template<class TYPE>
TVec2<TYPE> &operator/=(TVec2<TYPE> &v, const TYPE val); // Divide vector by scalar
template<class TYPE>
TVec2<TYPE> operator+(const TVec2<TYPE> &a, const TVec2<TYPE> &b); // Add vectors
template<class TYPE>
TVec2<TYPE> operator-(const TVec2<TYPE> &a, const TVec2<TYPE> &b); // Subtract vectors
template<class TYPE>
TYPE operator*(const TVec2<TYPE> &a, const TVec2<TYPE> &b); // Multiply vectors(dot product)
template<class TYPE>
TVec2<TYPE> operator/(const TVec2<TYPE> &a, const TVec2<TYPE> &b); // Divide vectors
template<class TYPE>
TVec2<TYPE> &operator+=(TVec2<TYPE> &a, const TVec2<TYPE> &b); // Add vector to vector
template<class TYPE>
TVec2<TYPE> &operator-=(TVec2<TYPE> &a, const TVec2<TYPE> &b); // Subtract vector from vector
template<class TYPE>
TVec2<TYPE> &operator/=(TVec2<TYPE> &a, const TVec2<TYPE> &b); // Divide vector by vector
template<class TYPE>
TVec2<TYPE> operator-(const TVec2<TYPE> &v); // Return inversed vector

Also there are some functions which can be used with TVec2 template. Here they are.

Namespace: ntl
Include: NTL/Core/Vec2.h