TPlane


This template represents plane.

You can find more information in comments below.

template<class TYPE>
union TPlane
{
    struct
    {
        union // Normal
        {
            struct
            {
                TYPE Nx;
                TYPE Ny;
                TYPE Nz;
            };
            TVec3<TYPE> N;
        };
        TYPE D;
    };
    TVec4<TYPE> V4; // As TVec4
    TQuaternion<TYPE> Q; // As TQuaternion
    TMatrix<TYPE, 1, 4> M; // As matrix

    TPlane(const TPlane &other) = default;
    TPlane(TPlane &&other) = default;

    TPlane(); : // Create invalid plane(all elements are zero)
    TPlane(const TYPE nx, const TYPE ny, const TYPE nz, const TYPE d); // Create with specified elements
    TPlane(const TYPE nx, const TYPE ny, const TYPE nz, const TYPE d, const bool normalize); // Create with specified elements. Aditionally normal normalization can be requested
    TPlane(const TVec2<TYPE> &n, const TVec2<TYPE> &p); // Create from normal and point in 2D space
    TPlane(const TVec3<TYPE> &n, const TVec3<TYPE> &p); // Create from normal and point in 3D space
    TPlane(const TVec2<TYPE> &p1, const TVec2<TYPE> &p2, const TVec2<TYPE> &p3); // Create by 2 points in 2D space
    TPlane(const TVec3<TYPE> &p1, const TVec3<TYPE> &p2, const TVec3<TYPE> &p3); // Create by 3 points in 3D space

    TPlane &operator=(const TPlane &other) = default;
    TPlane &operator=(TPlane &&other) = default;
};

Additionally following operators exists.

template<class TYPE>
bool operator==(const TPlane<TYPE> &a, const TPlane<TYPE> &b); // Check whether planes are equal. Can be used for non-float data types only
template<class TYPE>
bool operator!=(const TPlane<TYPE> &a, const TPlane<TYPE> &b); // Check whether planes aren't equal. Can be used for non-float data types only

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

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