29 #ifndef __MATH_PLANE_H__
30 #define __MATH_PLANE_H__
44 #define ON_EPSILON 0.1f
45 #define DEGENERATE_DIST_EPSILON 1e-4f
53 #define PLANESIDE_FRONT 0
54 #define PLANESIDE_BACK 1
55 #define PLANESIDE_ON 2
56 #define PLANESIDE_CROSS 3
62 #define PLANETYPE_NEGX 3
63 #define PLANETYPE_NEGY 4
64 #define PLANETYPE_NEGZ 5
65 #define PLANETYPE_TRUEAXIAL 6 // all types < 6 are true axial planes
66 #define PLANETYPE_ZEROX 6
67 #define PLANETYPE_ZEROY 7
68 #define PLANETYPE_ZEROZ 8
69 #define PLANETYPE_NONAXIAL 9
87 bool Compare(
const idPlane &p,
const float normalEps,
const float distEps )
const;
95 float Normalize(
bool fixDegenerate =
true );
98 float Dist(
void )
const;
99 void SetDist(
const float dist );
100 int Type(
void )
const;
112 int Side(
const idVec3 &v,
const float epsilon = 0.0
f )
const;
125 const char *
ToString(
int precision = 2 )
const;
135 #define plane_zero plane_origin
188 return (
a == p.
a &&
b == p.
b &&
c == p.
c &&
d == p.
d );
230 a =
b =
c =
d = 0.0f;
240 return *
reinterpret_cast<const idVec3 *
>(&
a);
244 return *
reinterpret_cast<idVec3 *
>(&
a);
250 if ( fixDegenerate ) {
280 Normal() = (p1 - p2).Cross( p3 - p2 );
281 if (
Normalize( fixDegenerate ) == 0.0f ) {
325 return a * v.
x +
b * v.
y +
c * v.
z +
d;
330 if ( dist > epsilon ) {
333 else if ( dist < -epsilon ) {
342 float d1, d2, fraction;
349 if ( d1 > 0.0
f && d2 > 0.0
f ) {
352 if ( d1 < 0.0
f && d2 < 0.0
f ) {
355 fraction = ( d1 / ( d1 - d2 ) );
356 return ( fraction >= 0.0
f && fraction <= 1.0
f );
367 scale = -( d1 / d2 );
376 return *
reinterpret_cast<const idVec4 *
>(&
a);
380 return *
reinterpret_cast<idVec4 *
>(&
a);
384 return reinterpret_cast<const float *
>(&
a);
388 return reinterpret_cast<float *
>(&
a);
GLsizei const GLfloat * points
bool FromPoints(const idVec3 &p1, const idVec3 &p2, const idVec3 &p3, bool fixDegenerate=true)
const idVec3 & Normal(void) const
bool Compare(const idPlane &p) const
GLenum GLenum GLenum GLenum GLenum scale
float Distance(const idVec3 &v) const
bool PlaneIntersection(const idPlane &plane, idVec3 &start, idVec3 &dir) const
const float * ToFloatPtr(void) const
const idVec4 & ToVec4(void) const
idPlane & TranslateSelf(const idVec3 &translation)
idPlane & RotateSelf(const idVec3 &origin, const idMat3 &axis)
void SetNormal(const idVec3 &normal)
idVec3 Cross(const idVec3 &a) const
static float Rint(float f)
idPlane Rotate(const idVec3 &origin, const idMat3 &axis) const
const char * ToString(int precision=2) const
idPlane & operator*=(const idMat3 &m)
idPlane operator-() const
void SetDist(const float dist)
static float Fabs(float f)
bool HeightFit(const idVec3 *points, const int numPoints)
bool FromVecs(const idVec3 &dir1, const idVec3 &dir2, const idVec3 &p, bool fixDegenerate=true)
bool operator!=(const idPlane &p) const
bool FixDegenerateNormal(void)
int GetDimension(void) const
GLubyte GLubyte GLubyte a
bool RayIntersection(const idVec3 &start, const idVec3 &dir, float &scale) const
float Normalize(bool fixDegenerate=true)
bool FixDegenerateNormal(void)
idPlane operator+(const idPlane &p) const
int Side(const idVec3 &v, const float epsilon=0.0f) const
bool LineIntersection(const idVec3 &start, const idVec3 &end) const
idPlane & operator=(const idVec3 &v)
GLsizei const GLcharARB const GLint * length
idPlane Translate(const idVec3 &translation) const
bool operator==(const idPlane &p) const
bool FixDegeneracies(float distEpsilon)
float operator[](int index) const
void FitThroughPoint(const idVec3 &p)