# Nell Blog

This is the blog for the book: Nell: An SVG Drawing Language. We will post new drawings here and other information about the book and related software.

## Making graph paper - log-linear grid

*March 26, 2020*

Log-linear grid graph paper is commonly used in math and engineering. Let's make some with the Nell language. Below is a Nell program that will do it.

; Creates a log-linear sheet of graph paper. ; nell gploglin1.nll START 3 | nellsvg 8.5 11 in 0.01 1 > gploglin1.svg w=8.5; width h=11; height mt=0.5; margin at top mb=0.5; margin at bottom dw=0.5; dh=2.0; nx=w/dw-1; ny=(h-mt-mb)/dh; y=1; dy=1; H0 : P(0,mb+dh*log(y)/log(10.0)) L(w) A(y,y+dy); HL : S(H0,9) A(dy,dy*10); VL : [T(pi/2) M(mb) L(h-mt-mb)] M(dw); START : [S(HL,ny) S(H0,1)] M(dw) S(VL,nx);

The above program creates a vertical log spacing versus a horizontal linear spacing grid on a letter size (8.5x11 inch) paper. There are 5 decades of log spacing, each decade taking 2 inches, and 17 steps of linear spacing, taking 1/2 inch each. Note that the thickness of the grid lines is set here as 0.01 inches. All of these parameters can be changed in the program or command line. The command line for generating the svg is shown as a comment on the second line of the program.

Below is a version of the program for an A4 paper size (210x297 mm).

; Creates a log-linear sheet of graph paper. ; nell gploglin2.nll START 3 | nellsvg 210 297 mm 0.254 1 > gploglin2.svg w=210; width h=297; height mt=24; margin at top mb=23; margin at bottom dw=12; dh=50; nx=w/dw-1; ny=(h-mt-mb)/dh; y=1; dy=1; H0 : P(0,mb+dh*log(y)/log(10.0)) L(w) A(y,y+dy); HL : S(H0,9) A(dy,dy*10); VL : [T(pi/2) M(mb) L(h-mt-mb)] M(dw); START : [S(HL,ny) S(H0,1)] M(dw) S(VL,nx);

You can get pdf versions of the above mentioned graph paper below:

Here we have changed the default solid lines to dotted lines by
opening up the svg output files in inkscape, selecting the grid, and
choosing from the menu: ```
Object | Fill and Stroke | Stroke
Syle
```

.

## Making graph paper - square grid

*March 21, 2020*

Square grid graph paper is commonly used in math and engineering. Let's make some with the Nell language. Below is a Nell program that will do it.

; Creates a linear-linear sheet of graph paper. ; nell gplinlin.nll START 3 | nellsvg 8.5 11 in 0.01 0 > gplinlin.svg w=8.5; w = width of graph h=11; h = height of graph d=0.25; d = distance between lines HL : [T(-pi/2) L(w)] M(d); VL : [T(pi/2) L(h)] M(d); START : [T(pi/2) M(d) S(HL,h/d-1)] M(d) S(VL,w/d);

The above program creates a 1/4 inch square grid on a letter size (8.5x11 inch) paper. The command line for generating the svg is shown as a comment on the second line of the program. Note that the thickness of the grid lines is set here as 0.01 inches, which you can change to anything you like.

If you want to change the grid size from 1/4 inch to the more common 5 mm size, just replace the "d=0.25", on the fifth line of the program, with "d=5/25.4". For an A4 paper size (210x297 mm) with 5 mm grid size, the program below will work.

; Creates a linear-linear sheet of graph paper. ; nell gplinlin2.nll START 3 | nellsvg 210 297 mm 0.254 0 > gplinlin.svg w=210; w = width of graph h=297; h = height of graph d=5; d = distance between lines HL : [T(-pi/2) L(w)] M(d); VL : [T(pi/2) L(h)] M(d); START : [T(pi/2) M(d) S(HL,h/d-1)] M(d) S(VL,w/d);

You can get pdf versions of the above mentioned graph paper below:

Here we have changed the default solid lines to dotted lines by
opening up the svg output files in inkscape, selecting the grid, and
choosing from the menu: ```
Object | Fill and Stroke | Stroke
Syle
```

.

## Drawing a convex lens

*March 17, 2020*

A staple of geometric optics is the convex lens. Let's draw a biconvex lens with the Nell language.

A biconvex lens can be drawn as two arcs. From the figure, the distance
from the origin, `o`

,
defined as the point from which the first arc is drawn, to the
center of the lens is:

`rc=r*cos(a)`

The distance from the origin to the point where the second arc is drawn is:

`x=2*rc`

Based on the above, we can write the Nell program shown below.

; Creates a biconvex lens. ; nell biconvex.nll START 1 | nellsvg 13.2 5.6 cm 0.04 1 > biconvex.svg r = 7; r = radius of arc of lens surface a = pi/8; a = angle at drawing origin from x axis to top of lens rc = r*cos(a); rc = distance from drawing origin to center of lens x = 2*rc; x = point on x axis from which 2nd arc is drawn NONLENS : P(0.1,2.8) C(0.05) [M(rc) C(0.05)] [L(2*rc) C(0.05)] [T(a) L(r)] [T(-a) L(r)]; LENS : R(r,r,-a,2*a) M(x) R(r,r,pi-a,2*a); START : S(NONLENS,1) S(LENS,1);

The output is

Note: the 2nd line of the program gives the command for generating the output.
The code labeled `NONLENS`

are points and lines that
are not part of the lens.

## Encircling a circle with circles

*March 14, 2020*

The program `circ3.nll`

in the book shows how to draw a
circle that is completely encircled by circles. Here we want to show
where the formulas for the distance from the center of the inner
circle to the center of an outer circle, as well as the radius of the
outer circles, comes from.

The isosceles triangle shown in the figure can be split into 2
identical right triangles with angles `a/2`

and `b`

. From one of these triangles, we see
that `cos(b)=r/x`

where we define `x=r0+r`

,
giving `r=x*cos(b)`

, which is the radius of the outer
circles. The distance from the center of the inner circle to the
center of an outer circle is just `x`

, which we can express
as

`x=r0+r`

` =r0+x*cos(b)`

Solving this for `x`

gives

`x=r0/(1-cos(b))`

.

The angle `b`

can be written in terms of the number of
circles encircling the inner circle, `n`

, as follows:

`a = 2π/n`

`a + 2b = π`

` => b = (π-a)/2 = (π-2π/n)/2 = π(n-2)/(2n)`

## Circles inscribed and circumscribed on a regular polygon

*March 12, 2020*

The program `circ4.nll`

in the book shows how to
inscribe a circle in a regular `n`

sided polygon. Here we
want to show where the formulas for inscribing and circumscribing
circles come from. If you draw lines from the center of a
regular `n`

sided polygon to each of the vertices, you will
divide the polygon into `n`

equal isosceles triangles. One
of these triangles is shown in the figure below.

```
φ = 2π/n
```

h = radius of inscribed circle

d = radius of circumscribed circle

θ = (π-φ)/2

From these parameters and some simple trigonometry we get

```
h = x*tan(θ)/2 = x/(2*tan(φ/2))
```

d = x/(2*cos(θ)) = x/(2*sin(φ/2))

The following is a Nell program for drawing both an inscribed and
circumscribed circle in a regular `n`

sided polygon.

; Creates a circle inscribed/circumscribed in an n-sided polygon. ; nell inscribed.nll START 10 | nellsvg 2 2 in 0.02 1 > inscribed.svg n = 5; x = 1; a = 2*pi/n; b = (pi-a)/2; h = x/(2*tan(a/2)); d = x/(2*sin(a/2)); T1 : L(x) T(a); START : P(0.5,0.25)~~T(b) M(d) C(d) C(h);~~

The output is

Note: the 2nd line of the program gives the command for generating the output.

Send questions or comments to:

Richard Hollos (richard[AT]exstrom DOT com)

Stefan Hollos (stefan[AT]exstrom DOT com)

Copyright 2020 by Exstrom Laboratories LLC