INPUT r
SCREEN 11
a=1.047
CIRCLE(r,r),r/5
FOR i=0TO 5
j=1AND i
k=i-j
CIRCLE(r,r),r-j*r*.7,,k*a,k*a+a
x=COS(i*a)
y=SIN(i*a)
LINE(r+r*x,r+r*y)-(r+r*x*.3,r+r*y*.3)
NEXT
Takes the radius of the figure (i.e. \$5R\$ in the diagram) as input.
You can try it at Archive.org; here's what the output looks like for an input of 100:

Explanation
INPUT r
Input the radius.
SCREEN 11
Clear the screen and put it in graphics mode. Normally, I use SCREEN 9
, but it doesn't seem to draw very circular circles, so the arcs didn't line up with the lines. SCREEN 11
did the trick for +1 byte.
a=1.047
Save \$\pi/3\$ in a variable.
CIRCLE(r,r),r/5
Draw the central circle, centered at \$(r,r)\$, with a radius of \$r/5\$.
FOR i=0TO 5
Loop six times. Each time through the loop, we're going to draw one arc and one line segment.
j=1AND i
k=i-j
Set j
to i
mod 2 using bitwise AND. Then set k
to the value of i
, "rounded down" to the nearest even number.
i | j | k
---|---|---
0 | 0 | 0
1 | 1 | 0
2 | 0 | 2
3 | 1 | 2
4 | 0 | 4
5 | 1 | 4
We use k
to calculate the starting angle of each arc, and j
to determine its radius:
CIRCLE(r,r),r-j*r*.7,,k*a,k*a+a
The CIRCLE
command can take extra arguments indicating the starting and ending angles in radians. Here, we draw an arc centered at \$(r,r)\$, with a radius of \$r-j \cdot r \cdot \frac7{10}\$: that is, \$r\$ when j
is 0, and \$\frac3{10}r\$ when j
is 1. The starting angle is \$k \cdot a\$ and the ending angle is \$k \cdot a + a\$ (so \$0\$ to \$\frac\pi3\$ on the first two iterations, \$\frac{2\pi}3\$ to \$\pi\$ on the next two, and \$\frac{4\pi}3\$ to \$\frac{5\pi}3\$ on the last two).
x=COS(i*a)
y=SIN(i*a)
To draw the line segments, we'll need to calculate their endpoints. First we calculate the x
and y
coordinates of a point on the unit circle at each of our six angles.
LINE(r+r*x,r+r*y)-(r+r*x*.3,r+r*y*.3)
Then we scale each point by \$r\$ and \$\frac3{10}r\$, translate both of those points by \$r\$, and draw a line between them.
NEXT
And continue to the next value of i
.
n
such that the image has width2*n+1
? \$\endgroup\$