29 #include "../precompiled.h"
44 else if (
Normal()[2] == 0.0
f ) {
51 else if (
Normal()[1] == 0.0
f ) {
59 else if (
Normal()[2] == 0.0
f ) {
74 float sumXX = 0.0f, sumXY = 0.0f, sumXZ = 0.0f;
75 float sumYY = 0.0f, sumYZ = 0.0f;
78 if ( numPoints == 1 ) {
85 if ( numPoints == 2 ) {
86 dir = points[1] - points[0];
94 for ( i = 0; i < numPoints; i++) {
97 average = sum / numPoints;
99 for ( i = 0; i < numPoints; i++ ) {
100 dir = points[
i] - average;
101 sumXX += dir.
x * dir.
x;
102 sumXY += dir.
x * dir.
y;
103 sumXZ += dir.
x * dir.
z;
104 sumYY += dir.
y * dir.
y;
105 sumYZ += dir.
y * dir.
z;
108 idMat2 m( sumXX, sumXY, sumXY, sumYY );
113 a = - sumXZ * m[0][0] - sumYZ * m[0][1];
114 b = - sumXZ * m[1][0] - sumYZ * m[1][1];
117 d = -(
a * average.
x +
b * average.
y +
c * average.
z );
127 double n00, n01, n11, det, invDet, f0, f1;
132 det = n00 * n11 - n01 * n01;
139 f0 = ( n01 * plane.
d - n11 *
d ) * invDet;
140 f1 = ( n01 *
d - n00 * plane.
d ) * invDet;
GLsizei const GLfloat * points
const idVec3 & Normal(void) const
idPlane plane_origin(0.0f, 0.0f, 0.0f, 0.0f)
bool PlaneIntersection(const idPlane &plane, idVec3 &start, idVec3 &dir) const
const float * ToFloatPtr(void) const
static const char * FloatArrayToString(const float *array, const int length, const int precision)
#define PLANETYPE_NONAXIAL
idVec3 Cross(const idVec3 &a) const
const char * ToString(int precision=2) const
static float Fabs(float f)
bool HeightFit(const idVec3 *points, const int numPoints)
int GetDimension(void) const
float LengthSqr(void) const
GLubyte GLubyte GLubyte a
float Normalize(bool fixDegenerate=true)