Code-style consistency improvement:

Apply clang-format-all.sh using the _clang-format file through all the cpp/.h files.
make sure not to apply it to certain serialization structures, since some parser expects the * as part of the name, instead of type.
This commit contains no other changes aside from adding and applying clang-format-all.sh
This commit is contained in:
erwincoumans
2018-09-23 14:17:31 -07:00
parent b73b05e9fb
commit ab8f16961e
1773 changed files with 1081087 additions and 474249 deletions

View File

@@ -6,7 +6,6 @@
#include "fitsphere.h"
/*----------------------------------------------------------------------
Copyright (c) 2004 Open Dynamics Framework Group
www.physicstools.org
@@ -53,27 +52,26 @@ from "Graphics Gems", Academic Press, 1990
/* The abs() of all coordinates must be < BIGNUMBER */
/* Code written by Jack Ritter and Lyle Rains. */
#define BIGNUMBER 100000000.0 /* hundred million */
#define BIGNUMBER 100000000.0 /* hundred million */
static inline void Set(float *n,float x,float y,float z)
static inline void Set(float *n, float x, float y, float z)
{
n[0] = x;
n[1] = y;
n[2] = z;
}
static inline void Copy(float *dest,const float *source)
static inline void Copy(float *dest, const float *source)
{
dest[0] = source[0];
dest[1] = source[1];
dest[2] = source[2];
}
float computeBoundingSphere(unsigned int vcount,const float *points,float *center)
float computeBoundingSphere(unsigned int vcount, const float *points, float *center)
{
float mRadius;
float mRadius2;
float mRadius;
float mRadius2;
float xmin[3];
float xmax[3];
@@ -84,119 +82,116 @@ float computeBoundingSphere(unsigned int vcount,const float *points,float *cente
float dia1[3];
float dia2[3];
/* FIRST PASS: find 6 minima/maxima points */
Set(xmin,BIGNUMBER,BIGNUMBER,BIGNUMBER);
Set(xmax,-BIGNUMBER,-BIGNUMBER,-BIGNUMBER);
Set(ymin,BIGNUMBER,BIGNUMBER,BIGNUMBER);
Set(ymax,-BIGNUMBER,-BIGNUMBER,-BIGNUMBER);
Set(zmin,BIGNUMBER,BIGNUMBER,BIGNUMBER);
Set(zmax,-BIGNUMBER,-BIGNUMBER,-BIGNUMBER);
/* FIRST PASS: find 6 minima/maxima points */
Set(xmin, BIGNUMBER, BIGNUMBER, BIGNUMBER);
Set(xmax, -BIGNUMBER, -BIGNUMBER, -BIGNUMBER);
Set(ymin, BIGNUMBER, BIGNUMBER, BIGNUMBER);
Set(ymax, -BIGNUMBER, -BIGNUMBER, -BIGNUMBER);
Set(zmin, BIGNUMBER, BIGNUMBER, BIGNUMBER);
Set(zmax, -BIGNUMBER, -BIGNUMBER, -BIGNUMBER);
for (unsigned i=0; i<vcount; i++)
for (unsigned i = 0; i < vcount; i++)
{
const float *caller_p = &points[i*3];
const float *caller_p = &points[i * 3];
if (caller_p[0]<xmin[0])
Copy(xmin,caller_p); /* New xminimum point */
if (caller_p[0]>xmax[0])
Copy(xmax,caller_p);
if (caller_p[1]<ymin[1])
Copy(ymin,caller_p);
if (caller_p[1]>ymax[1])
Copy(ymax,caller_p);
if (caller_p[2]<zmin[2])
Copy(zmin,caller_p);
if (caller_p[2]>zmax[2])
Copy(zmax,caller_p);
if (caller_p[0] < xmin[0])
Copy(xmin, caller_p); /* New xminimum point */
if (caller_p[0] > xmax[0])
Copy(xmax, caller_p);
if (caller_p[1] < ymin[1])
Copy(ymin, caller_p);
if (caller_p[1] > ymax[1])
Copy(ymax, caller_p);
if (caller_p[2] < zmin[2])
Copy(zmin, caller_p);
if (caller_p[2] > zmax[2])
Copy(zmax, caller_p);
}
/* Set xspan = distance between the 2 points xmin & xmax (squared) */
float dx = xmax[0] - xmin[0];
float dy = xmax[1] - xmin[1];
float dz = xmax[2] - xmin[2];
float xspan = dx*dx + dy*dy + dz*dz;
/* Set xspan = distance between the 2 points xmin & xmax (squared) */
float dx = xmax[0] - xmin[0];
float dy = xmax[1] - xmin[1];
float dz = xmax[2] - xmin[2];
float xspan = dx * dx + dy * dy + dz * dz;
/* Same for y & z spans */
dx = ymax[0] - ymin[0];
dy = ymax[1] - ymin[1];
dz = ymax[2] - ymin[2];
float yspan = dx*dx + dy*dy + dz*dz;
/* Same for y & z spans */
dx = ymax[0] - ymin[0];
dy = ymax[1] - ymin[1];
dz = ymax[2] - ymin[2];
float yspan = dx * dx + dy * dy + dz * dz;
dx = zmax[0] - zmin[0];
dy = zmax[1] - zmin[1];
dz = zmax[2] - zmin[2];
float zspan = dx*dx + dy*dy + dz*dz;
dx = zmax[0] - zmin[0];
dy = zmax[1] - zmin[1];
dz = zmax[2] - zmin[2];
float zspan = dx * dx + dy * dy + dz * dz;
/* Set points dia1 & dia2 to the maximally separated pair */
Copy(dia1,xmin);
Copy(dia2,xmax); /* assume xspan biggest */
float maxspan = xspan;
/* Set points dia1 & dia2 to the maximally separated pair */
Copy(dia1, xmin);
Copy(dia2, xmax); /* assume xspan biggest */
float maxspan = xspan;
if (yspan>maxspan)
if (yspan > maxspan)
{
maxspan = yspan;
Copy(dia1,ymin);
Copy(dia2,ymax);
maxspan = yspan;
Copy(dia1, ymin);
Copy(dia2, ymax);
}
if (zspan>maxspan)
if (zspan > maxspan)
{
Copy(dia1,zmin);
Copy(dia2,zmax);
Copy(dia1, zmin);
Copy(dia2, zmax);
}
/* dia1,dia2 is a diameter of initial sphere */
/* calc initial center */
center[0] = (dia1[0] + dia2[0]) * 0.5f;
center[1] = (dia1[1] + dia2[1]) * 0.5f;
center[2] = (dia1[2] + dia2[2]) * 0.5f;
/* dia1,dia2 is a diameter of initial sphere */
/* calc initial center */
center[0] = (dia1[0]+dia2[0])*0.5f;
center[1] = (dia1[1]+dia2[1])*0.5f;
center[2] = (dia1[2]+dia2[2])*0.5f;
/* calculate initial radius**2 and radius */
/* calculate initial radius**2 and radius */
dx = dia2[0] - center[0]; /* x component of radius vector */
dy = dia2[1] - center[1]; /* y component of radius vector */
dz = dia2[2] - center[2]; /* z component of radius vector */
dx = dia2[0]-center[0]; /* x component of radius vector */
dy = dia2[1]-center[1]; /* y component of radius vector */
dz = dia2[2]-center[2]; /* z component of radius vector */
mRadius2 = dx * dx + dy * dy + dz * dz;
mRadius = float(sqrt(mRadius2));
mRadius2 = dx*dx + dy*dy + dz*dz;
mRadius = float(sqrt(mRadius2));
/* SECOND PASS: increment current sphere */
/* SECOND PASS: increment current sphere */
if ( 1 )
if (1)
{
for (unsigned i=0; i<vcount; i++)
for (unsigned i = 0; i < vcount; i++)
{
const float *caller_p = &points[i*3];
const float *caller_p = &points[i * 3];
dx = caller_p[0]-center[0];
dy = caller_p[1]-center[1];
dz = caller_p[2]-center[2];
dx = caller_p[0] - center[0];
dy = caller_p[1] - center[1];
dz = caller_p[2] - center[2];
float old_to_p_sq = dx*dx + dy*dy + dz*dz;
float old_to_p_sq = dx * dx + dy * dy + dz * dz;
if (old_to_p_sq > mRadius2) /* do r**2 test first */
{ /* this point is outside of current sphere */
float old_to_p = float(sqrt(old_to_p_sq));
if (old_to_p_sq > mRadius2) /* do r**2 test first */
{ /* this point is outside of current sphere */
float old_to_p = float(sqrt(old_to_p_sq));
/* calc radius of new sphere */
mRadius = (mRadius + old_to_p) * 0.5f;
mRadius2 = mRadius*mRadius; /* for next r**2 compare */
float old_to_new = old_to_p - mRadius;
mRadius = (mRadius + old_to_p) * 0.5f;
mRadius2 = mRadius * mRadius; /* for next r**2 compare */
float old_to_new = old_to_p - mRadius;
/* calc center of new sphere */
/* calc center of new sphere */
float recip = 1.0f /old_to_p;
float recip = 1.0f / old_to_p;
float cx = (mRadius*center[0] + old_to_new*caller_p[0]) * recip;
float cy = (mRadius*center[1] + old_to_new*caller_p[1]) * recip;
float cz = (mRadius*center[2] + old_to_new*caller_p[2]) * recip;
float cx = (mRadius * center[0] + old_to_new * caller_p[0]) * recip;
float cy = (mRadius * center[1] + old_to_new * caller_p[1]) * recip;
float cz = (mRadius * center[2] + old_to_new * caller_p[2]) * recip;
Set(center,cx,cy,cz);
Set(center, cx, cy, cz);
}
}
}
return mRadius;
return mRadius;
}