MCPcopy Create free account
hub / github.com/SimHacker/micropolis / n_spin

Method n_spin

MicropolisCore/src/CellEngine/src/cellengine.cpp:3613–3656  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3611
3612
3613void CellEngine::n_spin()
3614{
3615 Byte *front = frontMem;
3616 Byte *back = backMem +
3617 (backBorder - 1) +
3618 ((backBorder - 1) * backRowBytes);
3619 Byte *f = front;
3620 long xx, yy;
3621// float jitter = ((float)1.0 * ((float)Rand8() / (float)255.0));
3622 float jitter = 0.0;
3623 float angle = ((float)8.0 * (float)frob) + jitter;
3624 angle += ((float) hubba) * (float)-0.3;
3625 float rad = (-angle) / (float)(180.0 / 3.14152973);
3626 float dy = (float)sin(rad);
3627 float dx = (float)cos(rad);
3628 float cx = (float)width / (float)2.0;
3629 float cy = (float)height / (float)2.0;
3630
3631 for (yy = 0;
3632 yy < height;
3633 f += screenRowBytes,
3634 yy++) {
3635 for (xx = 0;
3636 xx < width;
3637 xx++) {
3638 float x1, y1;
3639 long x2, y2;
3640
3641 x1 = (float)xx - cx;
3642 y1 = (float)yy - cy;
3643
3644 x2 = (long)floor(1.5 + (x1 * dx) + (y1 * dy) + cx);
3645 y2 = (long)floor(1.5 + (y1 * dx) - (x1 * dy) + cy);
3646
3647 if ((x2 >= 0) &&
3648 (x2 < width) &&
3649 (y2 >= 0) &&
3650 (y2 < height)) {
3651
3652 f[xx] = back[(y2 * backRowBytes) + x2];
3653 }
3654 }
3655 }
3656}
3657
3658
3659// Driven Diffusion by Two Species

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected