Describes plane. Since release of 6.0.0 the plane normal length should always be equal to 1. When constructing plane with parameters the normal is normalized automatically. If you construct plane directly assigning value to a plane components(Nx, Ny, Nz) you have to call N.normalize() to make the normal length equal to 1.
You can find more information in comments below.
template<class TYPE>
struct TPlane
{
union
{
struct
{
TYPE Nx; // Normal X-coordinate
TYPE Ny; // Normal Y-coordinate
TYPE Nz; // Normal Z-coordinate
};
TVec3<TYPE> N; // Normal. Length is assumed to be alwas equal to 1
};
TYPE D; // Plane equation is Nx * x + Ny * y + Nz * z + D
TPlane() = default;
TPlane(const TPlane &other) = default;
TPlane(TPlane &&other) = default;
TPlane(const TYPE nx, const TYPE ny, const TYPE nz, const TYPE d); // Create with specified parameters
TPlane(const TVec3<TYPE> &n, const TVec3<TYPE> &p); // Create by normal and point
TPlane(const TVec3<TYPE> &p1, const TVec3<TYPE> &p2, const TVec3<TYPE> &p3); // Create by 3 points
// Since 6.0.0
bool operator==(const TPlane &other) const; // Strict compare for equality
bool operator!=(const TPlane &other) const; // Strict compare for unequality
TPlane &operator=(const TPlane &other) = default;
TPlane &operator=(TPlane &&other) = default;
TYPE distance(const TVec3<TYPE> &p) const; // Return distance to point assuming the normal length is 1
// Since 6.0.0
template<class DEST_TYPE> TPlane<DEST_TYPE> convert() const; // Return plane with the same components but different data type
template<class DEST_TYPE> void convert(TPlane<DEST_TYPE> &dest) const; // Copy elements into the destination plane converting them to new data type
bool is_equal(const TPlane &other, const TYPE tolerance) const; // Compare whether the plane is equal to the other one with specified threshold
bool is_not_equal(const TPlane &other, const TYPE tolerance) const; // Compare whether the plane is not equal to the other one with specified threshold
void construct(const TVec3<TYPE> &p1, const TVec3<TYPE> &p2, const TVec3<TYPE> &p3); // Construct plane by 3 points
void inverse(); // Inverse this plane
TPlane inversed() const; // Return plane inversed to this one
};
Namespace: | nitisa::math |
Include: | Nitisa/Modules/Math/Plane.h |