MCPcopy Create free account
hub / github.com/NVIDIA/cuda-samples / createGaussianMap

Function createGaussianMap

cpp/5_Domain_Specific/nbody/render_particles.cpp:337–365  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

335}
336
337unsigned char *createGaussianMap(int N)
338{
339 float *M = new float[2 * N * N];
340 unsigned char *B = new unsigned char[4 * N * N];
341 float X, Y, Y2, Dist;
342 float Incr = 2.0f / N;
343 int i = 0;
344 int j = 0;
345 Y = -1.0f;
346
347 // float mmax = 0;
348 for (int y = 0; y < N; y++, Y += Incr) {
349 Y2 = Y * Y;
350 X = -1.0f;
351
352 for (int x = 0; x < N; x++, X += Incr, i += 2, j += 4) {
353 Dist = (float)sqrtf(X * X + Y2);
354
355 if (Dist > 1)
356 Dist = 1;
357
358 M[i + 1] = M[i] = evalHermite(1.0f, 0, 0, 0, Dist);
359 B[j + 3] = B[j + 2] = B[j + 1] = B[j] = (unsigned char)(M[i] * 255);
360 }
361 }
362
363 delete[] M;
364 return (B);
365}
366
367void ParticleRenderer::_createTexture(int resolution)
368{

Callers 1

_createTextureMethod · 0.70

Calls 1

evalHermiteFunction · 0.70

Tested by

no test coverage detected