Circles
You can draw a circle with the command C(r)
. This will draw a
circle of radius r
centered on the current position. The
current position and direction are not changed so you can easily draw
concentric circles as shown in program (circ1.nll)
.
Program: (circ1.nll)
n = 10; r = 1; dr = 0.1; T1 : C(r) A(r,r+dr); START : P(2,2) S(T1,n);
Command line
nell circ1.nll START 3 | nellsvg 4 4 in 0.02 1 > circ1.svg
You can create a
Moire pattern
with two sets of equally spaced concentric circles. As you move apart
the centers of the two sets of circles you will see different patterns
emerge. These patterns are analogous the constructive and destructive
interference produced by two point sources of light (or any source of
transverse waves). Program (circ2.nll)
draws two sets of 40
concentric circles spaced a distance dr=0.05
apart with the
centers of the two sets separated by a distance 4*dr=0.2
.
Program: (circ2.nll)
n = 40; r = 0.05; dr = 0.05; T1 : C(r) A(r,r+dr); START : P(2.05,2.05) S(T1,n) A(r,dr) M(4*dr) S(T1,n)
Command line
nell circ2.nll START 3 | nellsvg 4.3 4.1 in 0.02 1 > circ2.svg
The program (circ3.nll)
will draw a circle of radius
r0
that is completely encircled by n
circles. The
radius of the outer circles shrinks as n
increases as long as
the radius of the inner circle stays constant. The square canvas size
is 2*r0*(1+2*cos(b)/(1-cos(b)))
where b=pi*(n-2)/(2*n)
.
Program: (circ3.nll)
r0 = 1; n = 12; b = pi*(n-2)/(2*n); x = r0/(1-cos(b)); distance from center of inner circle r = x*cos(b); radius of outer circles a = 2*pi/n; T1 : [M(x) C(r)] T(a); START : P(r0+2*r,r0+2*r) C(r0) T(-pi/2) S(T1,n);
Command line
nell circ3.nll START 10 | nellsvg 3.4 3.4 in 0.02 1 > circ3.svg
The program (circ4.nll)
will inscribe a circle inside an
n-sided regular polygon. A program for circumscribing a circle around
an n-sided regular polygon would be almost identical. See if you can
modify (circ4.nll)
to circumscribe a circle. Hint the radius of
the circumscribed circle is r=l/(2*cos(b))
.
Program: (circ4.nll)
n = 5; l = 1; b = pi*(n-2)/(2*n); r = l*tan(b)/2; radius of circle a = 2*pi/n; T1 : L(l) T(a); START : M(0.5) <S(T1,n-1) Z()> T(b) M(l/(2*cos(b))) C(r);
Command line
nell circ4.nll START 10 | nellsvg 2 1.6 in 0.02 1 > circ4.svg