Ellipses

You can draw an ellipse with the command E(rx,ry) where rx is the radius of the ellipse in the current direction and ry is the radius perpendicular to the current direction. The program (ellip1.nll) shows two ways to draw two ellipses of the same kind oriented perpendicular to each other. With the E1 command string a turn of pi/2 is made to draw the second ellipse. With the E2 command string the rx and ry values are swapped for the second ellipse which has the same effect.

Program: (ellip1.nll)

rx = 2;
ry = 1;
E1 : P(2,2) E(rx,ry) T(pi/2) E(rx,ry);
E2 : P(2,2) E(rx,ry) E(ry,rx);

Command line

nell ellip1.nll E1 3 | nellsvg 4 4 in 0.02 1 > ellip1.svg
nell ellip1.nll E2 3 | nellsvg 4 4 in 0.02 1 > ellip1.svg

You can also create Moire patterns with sets of equally spaced concentric ellipses. The patterns are similar to those created with circles but there are differences. The program (ellip2.nll) will draw two sets of 40 concentric ellipses spaced a small horizontal distance apart.

Program: (ellip2.nll)

n = 40;
rx = 0.05;
ry = 0.025;
drx = rx;
dry = ry;
T1 : E(rx,ry) A(rx,rx+drx) A(ry,ry+dry);
START : P(2.05,2.05) S(T1,n) A(rx,drx) A(ry,dry) M(4*drx) S(T1,n)

Command line

nell ellip2.nll START 3 | nellsvg 4.3 2.1 in 0.02 1 > ellip2.svg

A circle can be defined as all points whose distance from a point, called the center of the circle, is a constant value. Likewise an ellipse can be defined as all points whose distances from two points, called the foci of the ellipse, have a constant sum. The two foci are located on the long axis of the ellipse. If rx>ry then the foci are located a distance c=sqrt(rx^2-ry^2) from the center of the ellipse. The following program will draw n ellipses rotated about a common focus with a circle surrounding them all (ellip3.nll).

Program: (ellip3.nll)

n = 48;
a = 2*pi/n;
rx = 1.5;
ry = 3/4;
c = sqrt(rx^2-ry^2);
E1 : [M(c) E(rx,ry)] T(a);
START : P(rx+c+0.04,rx+c+0.04) S(E1,n) C(rx+c);

Command line

nell ellip3.nll START 3 | nellsvg 5.7 5.7 in 0.02 1 > ellip3.svg