11.3  Using graphics primitives and directives

This Mathematica notebook supports the corresponding section of M&M.  It's intended to be executed in sequence.  It may include some tests not shown in the book.  It contains code for exercise solutions, but usually little discussion of them.  The version distributed with the book will contain solutions only for odd-numbered exercises.
	Any  Export  commands that produced figures for the book are commented out, so that they won't reference nonexistent folders.  They always duplicate figures rendered just previously by  Show.

Point  primitive and point-size directives

P = Point[{0, 0.2}];
Q = Point[{0.5, 0.5}];
R = Point[{0.5, 0}];
μ = {Q, AbsolutePointSize[28], R};
λ = {AbsolutePointSize[14], P, μ};
figure1 =  Graphics[λ];
Show[figure1, 
        PlotRange -> {{-0.5, 1.5}, {-0.5, 1.5}}];
Export["d:\\M&M\\Chapter11\\11_03\\11_03_01.eps", %];

Show[figure1];

Text  primitive

$TextStyle = "Input";
P = {1, 2};
λ = {Text["ABC", P], PointSize[ .02], 
          Point[P]};
Show[Graphics[λ]];

Line  primitive;  thickness and dashing directives

λ = {{1, 2}, {3, 4}};
Show[Graphics[Line[λ]]];
Show[Graphics[Line[{{1, 2}}]]];
Show[Graphics[Line[{}]]];

P = {0, 0.2};
Q = {0.5, 0.5};
R = {0.5, 0};
μ = {Point[Q], AbsolutePointSize[28], 
          Point[R]};
λ = {AbsolutePointSize[14], 
          Point[P], μ};
AppendTo[λ, {AbsoluteThickness[5], 
          Line[{P, Q, R}]}];
figure2 =  Graphics[λ];
Show[figure2, 
        PlotRange -> {{-0.5, 1.5}, {-0.5, 
              1.5}}];
Export["d:\\M&M\\Chapter11\\11_03\\11_03_02.eps", %];

P = {0, 0};   Q = {1, 0};
λ = {AbsoluteDashing[{4, 8, 16, 8}], AbsoluteThickness[5],  
          Line[{P, Q}]};
Show[Graphics[λ]];
Export["d:\\M&M\\Chapter11\\11_03\\11_03_03.eps", %];

Circle  and  Disk  primitives

Z = {0, 0};
r = 1;
semiaxes = {0.5, r};
θ = 0.5;
𝒞1 = 
        Circle[Z, r, {-θ, θ}];
𝒞2 = 
        Circle[Z, 
          r, {θ, 2  π - θ}];
d = 
        Disk[Z, semiaxes, {θ, 
            2  π - θ}];
λ = {AbsoluteThickness[1], 
          AbsoluteDashing[{2, 
              4}], 𝒞1, 
Dashing[{}], 𝒞2, d};
Show[Graphics[λ],  
        AspectRatio -> Automatic];
Export["d:\\M&M\\Chapter11\\11_03\11_03_04.eps", %];

Show[Graphics[λ]];

Polygon  and  Rectangle  primitives

P = {0, 0.2};
Q = {0.5, 0.5};
R = {0.5, 0};
Show[Graphics[Polygon[{P, Q, R}]]];
Export["d:\\M&M\\Chapter11\\11_03\\11_03_05.eps", %];

κ = {{0, 0}, {5, 0}, {5, 4}, {1, 4}, {1, 2}, {3, 2}, {3, 
            3}, {2, 3}, {2, 1}, {4, 1}, {4, 5}, {0, 
            5}};
λ = {GrayLevel[0.8], 
          Polygon[κ]};
μ = Append[κ, {0, 0}];
ν = {AbsoluteThickness[1], 
          Line[μ]};
Show[Graphics[{λ, ν}], 
        AspectRatio -> Automatic];
Export["d:\\M&M\\Chapter11\\11_03\\11_03_06.eps", %];

Clear[r, x, y, θ];
r[θ_] := 
        2 + 3  Cos[θ + 1]^2;
x[θ_] := 
        r[θ] Cos[θ];
y[θ_] := 
        r[θ] Sin[θ];
ParametricPlot[{x[θ], y[θ]}, {θ, 0, 
          2  π}];

θ[n_] := (n - 1) 
          2  π/200; 
λ = 
        Table[{x[θ[n]], y[θ[n]]}, {n, 
            200}];
pool = {GrayLevel[0.8], 
          Polygon[λ]};
μ = 
        Append[λ, λ[[1]]];
edge = {AbsoluteThickness[1], 
          Line[μ]};
Show[Graphics[{pool, edge}]];
Export["d:\\M&M\\Chapter11\\11_03\\11_03_07.wmf", %];

Exercise 1

Oh = {0, 0};   X = {1, 0};   Y = {0, 1};   Z = {1, 
        1};
Clear[t];
{t, u} = 
      t /. Solve[(((1 - t))^2) + (((1/2))^2) == (1^2), t]

P = {1/2, t};
λ = {Oh, X, Z, Y, Oh, P, Y};
μ = {X, P, Z};
Show[Graphics[{AbsoluteThickness[1], Line[λ], Line[μ]}], 
        AspectRatio -> Automatic];

Exercise 2

P = Point[{0, 0.2}];
Q = Point[{0.5, 0.5}];
R = 
      Point[{0.5, 0}]; λ = {AbsolutePointSize[14], P, Q, 
        AbsolutePointSize[28], R};
figure1a =  Graphics[λ];
Show[figure1a, 
        PlotRange -> {{-0.5, 1.5}, {-0.5, 1.5}}];

P = {0, 0.2};
Q = {0.5, 0.5};
R = {0.5, 0};
μ = {Point[Q], Point[R]};
λ = {Point[P], μ};
AppendTo[λ, {AbsoluteThickness[5], 
          Line[{P, Q, R}]}];
figure2 =  Graphics[λ];
Show[figure2, 
        PlotRange -> {{-0.5, 1.5}, {-0.5, 1.5}}];

Exercise 3

Look at a diagonal:

Clear[r];
{s, r} = 
      r /. Solve[(((4  r + 2  r Sqrt[2]))^2) == (2^2) + (2^2), 
          r]
r = FullSimplify[r]

P = {1, -1};   Q = {1, 1};   R = {-1, 
        1};   S = {-1, -1};
Oh = {0, 0};
LR = {1 - r, -1 + r};   UL = -LR;
UR = {1 - r, 1 - r};   LL = -UR;

λ = Line[{P, Q, R, S, P}];
μ = {Circle[Oh, r], Circle[LR, r], Circle[UR, r], Circle[UL, r], 
          Circle[LL, r]};
Show[Graphics[{AbsoluteThickness[1], λ, μ}], 
        AspectRatio -> Automatic];

Exercise 4

Let the radius of the small circles be  1,  so that the radius of the large ones is  4.  Let  r  be the radius of the middle one.  Let  p  be the distance from the base midpoint  B  to the center  M  of the middle circle.  Looking at two triangles with vertex  M,  right angle at  B,  and second vertices at centers  S  and  L  of small and large circles, you see that  (((r + 1))^2) = (p^2) + 1  and  (4 - ((r))^2) = (p^2) + (2^2).  Put the origin at  B.

Clear[p1, r1, p, r];
{{p1, r1}, {p, r}} = {p, r} /. 
        Solve[{(((r + 1))^2) == (p^2) + 1, (((4 - r))^2) == 
              (p^2) + (2^2)}]

L   = Line[{{-2, 0}, {2, 0}}];
S1 = Circle[{-1, 0}, 1, {0, π}];
S2 = Circle[{  1, 0}, 1, {0, π}];
M   = Circle[{  0, p}, r];
L1 = 
        Circle[{  2, 0}, 
          4, {2  π/3, π}];
L2 = 
        Circle[{-2, 0}, 4, {0, π/3}];
Show[Graphics[{AbsoluteThickness[2], L, S1, S2, M, L1, L2}], 
        AspectRatio -> Automatic];
\(\(Export["d:\M&M\Chapter11\11_03\11_03_08.wmf", %];\)
\)

Exercise 5

S = 
        Disk[{0, 0}, 1, {π/2, 3  π/2}];
T = 
        Disk[{1, 0}, 
          Sqrt[2], {3  π/4, 5  π/4}];
L = 
        Line[{{-1, 0}, {1, 0}, {0, 1}, {0, -1}, {1, 
              0}}];
λ = {S, GrayLevel[1], T, GrayLevel[0], AbsoluteThickness[1], 
          AbsoluteDashing[{4, 4}], L};
Show[Graphics[λ], 
        AspectRatio -> Automatic];
Export["d:\\M&M\\Chapter11\\11_03\\11_03_09.eps", %];

Exercise 6

D1 = Disk[{0, 0}, 1];
cis[θ_] := {Cos[θ], 
          Sin[θ]};
Y = {0, 1};   θ  =  2  π/5;
X = cis[π/2 - θ];       Z = 
      cis[π/2 + θ];
W = cis[π/2 - 2  θ];   V = 
      cis[π/2 + 2  θ];
P = Polygon[{V, X, Z, W, Y}];
r = Sin[π/10]/Sin[7  π/10];
D2 = Disk[{0, 0}, r];
λ = {D1, GrayLevel[1], P, GrayLevel[0.5], 
          D2};
Show[Graphics[λ], 
        AspectRatio -> Automatic];

Exercise 7

Clear[r, x, y, θ];
r[θ_] := 1 + 4  Sin[7  θ];
x[θ_] := 
        r[θ] Cos[θ];
y[θ_] := 
        r[θ] Sin[θ];
ParametricPlot[{x[θ], y[θ]}, {θ, 0, 2  π}, 
        AspectRatio -> Automatic];

θ[n_] := (n - 1) 
          2  π/500; 
λ = 
        Table[{x[θ[n]], y[θ[n]]}, {n, 
            500}];
pool = {GrayLevel[0.8], 
          Polygon[λ]};
μ = 
        Append[λ, λ[[1]]];
edge = {AbsoluteThickness[2], 
          Line[μ]};
Show[Graphics[{pool, edge}], 
        AspectRatio -> Automatic];

Exercise 8

κ = {{0, 0}, {7, 0}, {7, 6}, {3, 2}, {5, 2}, {5, 3}, {3, 
            1}, {6, 1}, {6, 6}};
λ = {GrayLevel[0.8], 
          Polygon[κ]};
μ = Append[κ, {0, 0}];
ν = {AbsoluteThickness[1], 
          Line[μ]};
Show[Graphics[{λ, ν}], 
        AspectRatio -> Automatic];