Skip to content

Spiral maps.

#55
Auto-translated
I rewrote the program for calculating arcs of various radii (which are needed for drawing these arcs on the "Heroes III" map).
I adapted the DOS version for Windows.
/*   p1
Visual C++ 6.0
Console application
Radius */

#include
#include

main ()
{
int a, b, c, d;
FILE *g;

/* a - radius for which the calculation is performed
b - maximum value for which the square root is calculated
c - counter
d - calculated value of the circle boundary */

g = fopen ("1.txt", "w");
for (a = 1; a < 61; a++) /* outer radius 1/8 of the circumference */
{
b = (int) (a / sqrt (2) + 2); /* upper limit of calculations */
fprintf (g, "r = %i\n", a);
for (c = 0; c < b; c++)
{
if (c == a) break;
d = (int) (sqrt (a * a - c * c - .0001) + 1);
if (d < c) break;
if (d == a) continue;
fprintf (g, "%i - %i\n", c, d);
}

fprintf (g, "\n");
}

fclose (g);
return 0;
}
Attachments 1
1 file attached • Total size: 13.7 KB