#pragma once

#include <d3dx9math.h>

struct DXPlane
{
	float a;
	float b;
	float c;
	float d;

	DXPlane() {}
	DXPlane(const float _a, const float _b, const float _c, const float _d);
	DXPlane(const float* const p);
	DXPlane(const DXPlane &p);

	//casting
	operator float* ();
	operator const float* () const;
	
    // assignment operators
    DXPlane& operator *= (const float);
    DXPlane& operator /= (const float);

    // unary operators
    DXPlane operator + () const;
    DXPlane operator - () const;

    // binary operators
    DXPlane operator * (float) const;
    DXPlane operator / (float) const;

    friend DXPlane operator * (float, const DXPlane&);

    bool operator == (const DXPlane&) const;
    bool operator != (const DXPlane&) const;

	//get-set functions
	DXVector3 GetNormal(void) const;

	//calculations
	float DotCoord(const DXVector3& p) const;
	float DotNormal(const DXVector3& p) const;

	//plane construction
	static DXPlane FromPointNormal(const DXVector3& p, const DXVector3& n);
	static DXPlane FromPoints(const DXVector3& v1, const DXVector3& v2, const DXVector3& v3);
};

#include "DXPlane.inl"