TPoint


This template represents 2-element object. It may be interpreted as point in 2D space, range, etc. Arithmetical operators are per component and available for arithmetic data types only. Comparison operators are available for non-float data types only.

You can find more information in comments below.

template<class TYPE>
union TPoint
{
    struct
    {
        union
        {
            TYPE X; // First element
            TVec1<TYPE> V1; // First element as TVec1
        };
        TYPE Y; // Second element
    };
    struct
    {
        TYPE A; // First element
        TYPE B; // Second element
    };
    struct
    {
        TYPE From; // First element
        TYPE Till; // Second element
    };
    struct
    {
        TYPE First; // First element
        TYPE Second; // Second element
    };
    struct
    {
        TYPE _1; // First element
        TYPE _2; // Second element
    };
    TYPE Data[2]; // Array of elements
    TMatrix<TYPE, 1, 2> M; // Elements as matrix
    TVec2<TYPE> V2; // Elements as TVec2

    TYPE operator[](const size_t index) const; // Return element by index. Only 0 and 1 are accepted as indices. Used only when TPoint 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 TVec3() const; // Convert to TVec3
    explicit operator TVec4() const; // Convert to TVec4
    explicit operator TQuaternion() const; // Convert to TQuaternion
};

Additionally following operators exists.

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

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

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