-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathextra.w
More file actions
28 lines (28 loc) · 757 Bytes
/
extra.w
File metadata and controls
28 lines (28 loc) · 757 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
write('Recommended parameters: size=28, rings=10');
writeln;
write('Size: ');
read(size);
write('Number of rings: ');
read(nRings);
{x and y range from -size to +size}
y := 0 - size;
while y <= size do (
x := 0 - size;
while x <= size do (
distSq := x*x + y*y; {distSq is square of distance from centre to (x,y)}
ring := 0;
while (2*ring + 1) * (2*ring + 1) * (2*size + 1) * (2*size + 1) <=
distSq * 4 * (2*nRings - 1) * (2*nRings - 1) do
ring := ring + 1;
{ring width = (2*size+1)/(2*nRings-1)}
{loop exits when distance < (ring+1/2)*width = (2*ring+1)*(2*size+1)/(2*(2*nRings-1))}
if nRings <= ring then
write(' ')
else
write(ring);
write(' ');
x := x + 1
);
writeln;
y := y + 1
)