Skip to content

Instantly share code, notes, and snippets.

@shilrobot
Created January 6, 2012 20:15
Show Gist options
  • Save shilrobot/1572210 to your computer and use it in GitHub Desktop.
Save shilrobot/1572210 to your computer and use it in GitHub Desktop.
Parallel.For(0, H, y =>
{
int j = y * 3 * W;
//for(; y<ymax; ++y)
{
for (int x = 0; x < W; ++x)
{
float a = max,
b = max,
c = max;
float t0, t1;
Vector2 xy = new Vector2(x, y);
for (int i = 0; i < N; ++i)
{
float distSq;
Vector2.DistanceSquared(ref xy, ref pts[i], out distSq);
if (distSq < c)
{
if (distSq < b)
{
if (distSq < a)
{
// Xab
t0 = a; t1 = b;
a = distSq; b = t0; c = t1;
}
else
{
// aXb
t0 = a; t1 = b;
a = t0; b = distSq; c = t1;
}
}
else
{
//abX
t0 = a; t1 = b;
a = t0; b = t1; c = distSq;
}
}
}
data[j++] = a;
data[j++] = b;
data[j++] = c;
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment