Skip to content

Instantly share code, notes, and snippets.

View slembcke's full-sized avatar
👣
Gruntled

Scott Lembcke slembcke

👣
Gruntled
View GitHub Profile
const NSUInteger testCount = 1000000;
{
GLKMatrix4 m = M; // Initialized from a global to prevent constant folding when inlining.
CFAbsoluteTime t = CFAbsoluteTimeGetCurrent();
for (NSUInteger i = 0; i < testCount; i++) {
m = GLKMatrix4Multiply(m, m);
}
NSLog(@"time GLKit: %f", CFAbsoluteTimeGetCurrent() - t);
M = m; // Need to save the value of m to avoid it being optimized away
@slembcke
slembcke / cpConvexMoment.c
Created May 17, 2012 15:54 — forked from andykorth/cpConvexMoment.c
Convex Moment
// This is a little annoying:
cpVect *hullVerts = (cpVect *)calloc(NUM_VERTS, sizeof(cpVect));
int hullCount = cpConvexHull(NUM_VERTS, verts, hullVerts, NULL, 0.0);
cpFloat mass = 1.0;
cpFloat moment = cpMomentForPoly(mass, hullCount, hullVerts, cpvzero);
body = cpSpaceAddBody(space, cpBodyNew(mass, moment));
shape = cpSpaceAddShape(space, cpPolyShapeNew(body, hullCount, hullVerts, cpvzero));