TVec3


This template represents 3D vector.

You can find more information in comments below.

template<class TYPE>
union TVec3
{
    struct // As coordinates
    {
        union
        {
            struct
            {
                union
                {
                    TYPE X;
                    TVec1<TYPE> V1;
                };
                TYPE Y;
            };
            TVec2<TYPE> V2;
        };
        TYPE Z;
    };
    struct // As elements
    {
        TYPE _1;
        TYPE _2;
        TYPE _3;
    };
    TYPE Data[3]; // Array of elements
    TMatrix<TYPE, 1, 3> M; // As matrix

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

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

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