82 Vec3(
double _x,
double _y,
double _z) {
x = _x;
y = _y;
z = _z; };
87 return x*v.
x +
y*v.
y +
z*v.
z;
120 if (fM02 != (
double)0.0)
122 double fLength = sqrt(fM01*fM01+fM02*fM02);
123 double fInvLength = ((double)1.0)/fLength;
126 double fQ = ((double)2.0)*fM01*fM12+fM02*(fM22-fM11);
163 const int iMaxIter = 32;
165 for (
int i0 = 0; i0 <3; i0++)
168 for (i1 = 0; i1 < iMaxIter; i1++)
171 for (i2 = i0; i2 <= (3-2); i2++)
174 if ( fabs(
m_afSubd[i2]) + fTmp == fTmp )
183 double fR = sqrt(fG*fG+(
double)1.0);
184 if (fG < (
double)0.0)
192 double fSin = (double)1.0, fCos = (
double)1.0, fP = (double)0.0;
193 for (
int i3 = i2-1; i3 >= i0; i3--)
197 if (fabs(fF) >= fabs(fG))
200 fR = sqrt(fCos*fCos+(
double)1.0);
202 fSin = ((double)1.0)/fR;
208 fR = sqrt(fSin*fSin+(
double)1.0);
210 fCos = ((double)1.0)/fR;
214 fR = (
m_afDiag[i3]-fG)*fSin+((
double)2.0)*fB*fCos;
218 for (
int i4 = 0; i4 < 3; i4++)
240 for (
int i0 = 0, i1; i0 <= 3-2; i0++)
246 for (i2 = i0+1; i2 < 3; i2++)
261 for (i2 = 0; i2 < 3; i2++)
278 for (
int iRow = 0; iRow <3; iRow++)
293 const double *points,
294 unsigned int vstride,
295 const double *weights,
296 unsigned int wstride,
307 const char *source = (
const char *) points;
308 const char *wsource = (
const char *) weights;
310 for (
unsigned int i=0; i<vcount; i++)
313 const double *p = (
const double *) source;
319 const double *ws = (
const double *) wsource;
334 double recip = 1.0f / wtotal;
352 const char *source = (
const char *) points;
353 const char *wsource = (
const char *) weights;
355 for (
unsigned int i=0; i<vcount; i++)
358 const double *p = (
const double *) source;
364 const double *ws = (
const double *) wsource;
371 kDiff.
x = w*(p[0] - kOrigin.
x);
372 kDiff.
y = w*(p[1] - kOrigin.
y);
373 kDiff.
z = w*(p[2] - kOrigin.
z);
375 fSumXX+= kDiff.
x * kDiff.
x;
376 fSumXY+= kDiff.
x * kDiff.
y;
377 fSumXZ+= kDiff.
x * kDiff.
z;
379 fSumYY+= kDiff.
y * kDiff.
y;
380 fSumYZ+= kDiff.
y * kDiff.
z;
381 fSumZZ+= kDiff.
z * kDiff.
z;
424 plane[3] = 0 - kNormal.
dot(kOrigin);
431 double getBoundingRegion(
unsigned int vcount,
const double *points,
unsigned int pstride,
double *bmin,
double *bmax)
434 const unsigned char *source = (
const unsigned char *) points;
445 for (
unsigned int i=1; i<vcount; i++)
448 const double *p = (
const double *) source;
450 if ( p[0] < bmin[0] ) bmin[0] = p[0];
451 if ( p[1] < bmin[1] ) bmin[1] = p[1];
452 if ( p[2] < bmin[2] ) bmin[2] = p[2];
454 if ( p[0] > bmax[0] ) bmax[0] = p[0];
455 if ( p[1] > bmax[1] ) bmax[1] = p[1];
456 if ( p[2] > bmax[2] ) bmax[2] = p[2];
460 double dx = bmax[0] - bmin[0];
461 double dy = bmax[1] - bmin[1];
462 double dz = bmax[2] - bmin[2];
464 return sqrt( dx*dx + dy*dy + dz*dz );
469 bool overlapAABB(
const double *bmin1,
const double *bmax1,
const double *bmin2,
const double *bmax2)
471 if ( bmax2[0] < bmin1[0] )
return false;
472 if ( bmax2[1] < bmin1[1] )
return false;
473 if ( bmax2[2] < bmin1[2] )
return false;
475 if ( bmin2[0] > bmax1[0] )
return false;
476 if ( bmin2[1] > bmax1[1] )
return false;
477 if ( bmin2[2] > bmax1[2] )
return false;