0ad/source/maths/Plane.h
pyrolink 50e5e9acd9 # Aura and territory rendering
-Auras now take additional parameters from XML, containing a tag for r,
g, b, and a.  No line thickness parameter yet.
-For territories, added function to frustum for determining if line
segment passes through the frustum.

This was SVN commit r4242.
2006-08-25 06:04:33 +00:00

59 lines
1.5 KiB
C++

//***********************************************************
//
// Name: Plane.h
// Last Update: 17/2/02
// Author: Poya Manouchehri
//
// Description: A Plane in R3 and several utility methods.
// Note that the format used for the plane
// equation is Ax + By + Cz + D = 0, where
// <A,B,C> is the normal vector.
//
//***********************************************************
#ifndef PLANE_H
#define PLANE_H
#include "Vector3D.h"
enum PLANESIDE
{
PS_FRONT,
PS_BACK,
PS_ON
};
class CPlane
{
public:
CPlane ();
//sets the plane equation from 3 points on that plane
void Set (const CVector3D &p1, const CVector3D &p2, const CVector3D &p3);
//sets the plane equation from a normal and a point on
//that plane
void Set (const CVector3D &norm, const CVector3D &point);
//normalizes the plane equation
void Normalize ();
//returns the side of the plane on which this point
//lies.
PLANESIDE ClassifyPoint (const CVector3D &point) const;
//solves the plane equation for a particular point
float DistanceToPlane (const CVector3D &point) const;
//calculates the intersection point of a line with this
//plane. Returns false if there is no intersection
bool FindLineSegIntersection (const CVector3D &start, const CVector3D &end, CVector3D *intsect);
bool FindRayIntersection (CVector3D &start, CVector3D &direction, CVector3D *intsect);
public:
CVector3D m_Norm; //normal vector of the plane
float m_Dist; //Plane distance (ie D in the plane eq.)
};
#endif