TVec1


This template represents 1D vector.

You can find more information in comments below.

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

    TYPE operator[](const size_t index) const; // Return element by index. Only 0 is accepted as index. Used only when TVec1 object is a constant object
    TYPE &operator[](const size_t index); // Return element by index. Only 0 is accepted as index
    explicit operator TYPE() const; // Convert to scalar
    explicit operator TPoint<TYPE>() const; // Convert to TPoint
    explicit operator TVec2<TYPE>() const; // Convert to TVec2
    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 TVec1<TYPE> &a, const TVec1<TYPE> &b); // Check whether vectors are equal. Can be used for non-float data types only
template<class TYPE>
bool operator!=(const TVec1<TYPE> &a, const TVec1<TYPE> &b); // Check whether vectors aren't equal. Can be used for non-float data types only
template<class TYPE>
TVec1<TYPE> operator+(const TVec1<TYPE> &v, const TYPE val); // Add vector and scalar
template<class TYPE>
TVec1<TYPE> operator-(const TVec1<TYPE> &v, const TYPE val); // Subtract vector and scalar
template<class TYPE>
TVec1<TYPE> operator*(const TVec1<TYPE> &v, const TYPE val); // Multiply vector and scalar
template<class TYPE>
TVec1<TYPE> operator/(const TVec1<TYPE> &v, const TYPE val); // Divide vector and scalar
template<class TYPE>
TVec1<TYPE> operator+(const TYPE val, const TVec1<TYPE> &v); // Add scalar and vector
template<class TYPE>
TVec1<TYPE> operator-(const TYPE val, const TVec1<TYPE> &v); // Subtract scalar and vector
template<class TYPE>
TVec1<TYPE> operator*(const TYPE val, const TVec1<TYPE> &v); // Multiply scalar and vector
template<class TYPE>
TVec1<TYPE> operator/(const TYPE val, const TVec1<TYPE> &v); // Divide scalar and vector
template<class TYPE>
TVec1<TYPE> &operator+=(TVec1<TYPE> &v, const TYPE val); // Add scalar to vector
template<class TYPE>
TVec1<TYPE> &operator-=(TVec1<TYPE> &v, const TYPE val); // Subtract scalar from vector
template<class TYPE>
TVec1<TYPE> &operator*=(TVec1<TYPE> &v, const TYPE val); // Multiply vector by scalar
template<class TYPE>
TVec1<TYPE> &operator/=(TVec1<TYPE> &v, const TYPE val); // Divide vector by scalar
template<class TYPE>
TVec1<TYPE> operator+(const TVec1<TYPE> &a, const TVec1<TYPE> &b); // Add vectors
template<class TYPE>
TVec1<TYPE> operator-(const TVec1<TYPE> &a, const TVec1<TYPE> &b); // Subtract vectors
template<class TYPE>
TYPE operator*(const TVec1<TYPE> &a, const TVec1<TYPE> &b); // Multiply vectors(dot product)
template<class TYPE>
TVec1<TYPE> operator/(const TVec1<TYPE> &a, const TVec1<TYPE> &b); // Divide vectors
template<class TYPE>
TVec1<TYPE> &operator+=(TVec1<TYPE> &a, const TVec1<TYPE> &b); // Add vector to vector
template<class TYPE>
TVec1<TYPE> &operator-=(TVec1<TYPE> &a, const TVec1<TYPE> &b); // Subtract vector from vector
template<class TYPE>
TVec1<TYPE> &operator/=(TVec1<TYPE> &a, const TVec1<TYPE> &b); // Divide vector by vector
template<class TYPE>
TVec1<TYPE> operator-(const TVec1<TYPE> &v); // Return inversed vector

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

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