Interactive Illustrations for Geometric Modelling

implemented 2005 with Mathematica and LiveGraphics3D by Martin Kraus (martin_kraus_germany@yahoo.com)

This notebook contains Mathematica source code producing Graphics3D objects suitable for the Java applet LiveGraphics3D. (In order to interact with these graphics you have to have access to the applet, which is free for non-commercial purposes.) The graphics correspond to figures from the book "Curves and Surfaces for CAGD — A Practical Guide", 5th ed. by Gerald Farin. The goal is to present and interact with these figures in a course on geometric modeling and animation taught in the winter term 2005/2006 at the University of Stuttgart.

Some of the goals in the implementation of interactive versions of these figures are:
— merging of separate static figures in one interactive figure
— intuitive interaction to show dependencies
— consistency of notation
LiveGraphics3D has several limitations; thus, another important goal is to identify their relevance and propose solutions for some of them.

If you have questions about the Mathematica code, LiveGraphics3D, or the implementation of any of the figures, please e-mail martin_kraus_germany @ yahoo.com . If you think that this code implements an incorrect figure from the book, I would also be interested in your description of the error.

Lessons Learned

Graphics3D objects for LiveGraphics3D in general

— always construct graphics in three dimensions (reuse of code, etc.)

parametric Graphics3D objects for LiveGraphics3D

— if a vector-valued variable is used, define an automatic(!) rule to convert it into a list of three components (important for functions which expect vectors (e.g. Cross), even more important for functions that are Listable (e.g. Plus: for a vector-valued symbol "a", the expression "a+{1,0,0}" should not be evaluated to "{1+a, a, a}").
— use Evaluate around arguments of functions with attributes HoldFirst, HoldRest, HoldFirst, etc. (e.g If) 
— define lists independentVariables and dependentVariables that correspond to the parameters of LiveGraphics3D
— remember that dependentVariables are evaluated sequentially; therefore, avoid side effects by introducing new (temporary) variables (e.g. "{ax -> ax / Sqrt[ax*ax+ay*ay+az*az], ay -> ay / Sqrt[ax*ax + ay*ay + az*az], az -> az / Sqrt[ax*ax + ay*ay + az*az]}" will not normalize "{ax, ay, az}". Instead use "{aLength -> Sqrt[ax*ax + ay*ay + az*az], ax -> ax / aLength, ay -> ay / aLength, az -> az / aLength}").
— use "Graphics3D[...] //. Join[independentVariables, dependentVariables]" to produce an object that is displayable in Mathematica (but note that reassignments of independent variables are ignored this way).
— define new variables for the arguments and the results of complex symbolic computations (e.g. solutions of parametrized linear equation systems)

Functions for Preparing Graphics3D Objects

Functions for Writing the Input File

LiveForm[graphics_, animOpts___] := 
            Module[{graphics3d = 
                  Switch[graphics, _ContourGraphics, 
                      Graphics3D[
                        SurfaceGraphics[graphics]], _DensityGraphics, 
                      Graphics3D[
                        SurfaceGraphics[graphics]], _SurfaceGraphics, 
                      Graphics3D[graphics], _, graphics] //. 
                    SequenceForm[x___] :> 
                      StringForm[StringJoin[Table["``", {Length[{x}]}]], 
                        x]}, Switch[
                graphics3d, _List, HoldForm[ShowAnimation][
                  Map[LiveForm, graphics3d], 
                  InputForm[N[Flatten[{animOpts}]]]], _, 
                InputForm[N[graphics3d]]]];

WriteLiveForm[
          filename_, graphics_, animOpts___] := 
        Module[{ps, x}, ps = Unprotect[Real]; 
          Format[x_Real, InputForm] := 
            OutputForm[
              NumberForm[x, 5, 
                NumberFormat -> (If[#3 == "", #1, 
                        SequenceForm[#1, "*^", #3]] &)]]; 
          Protect @@ ps; 
WriteString[filename, 
            ToString[LiveForm[graphics, animOpts], 
              CharacterEncoding -> None]]; 
          Close[filename]; 
ps = Unprotect[Real]; 
          Format[x_Real, InputForm] =. ; Protect @@ ps;];

Functions for Writing the HTML File

WriteHtmlPage[filename_, text_, inputfile_, width_, height_, 
          independentVariables_, dependentVariables_, params_] := 
        Module[{}, 
          WriteString[
            filename, "<HTML>\n<BODY BGCOLOR=#FFFFFF>\n" <> 
              ToString[
                text] <> "<APPLET ARCHIVE=\"live.jar\" CODE=\"Live.class\" \
WIDTH=" <> ToString[width] <> " HEIGHT=" <> 
              ToString[height] <> " ALIGN=LEFT>\n" <> 
              params <> "\n<PARAM NAME=\"INDEPENDENT_VARIABLES\" \
VALUE=\"" <> ToString[
                InputForm[
                  N[independentVariables]]] <> "\">\n<PARAM \
NAME=\"DEPENDENT_VARIABLES\" VALUE=\"" <> 
              ToString[InputForm[N[dependentVariables]]] <> "\">\n
<PARAM NAME=MAGNIFICATION VALUE=1.>\n
<PARAM NAME=INPUT_FILE VALUE=\"" <> 
              inputfile <> "\">\n</APPLET>\n</HTML>"]; 
          Close[filename];];

Global Settings

newTextStyle = {FontFamily -> "Times", 
          FontSize -> 48};

Symbols

Overview

These symbols represent particular variables from the book Gerald Farin, "Curves and Surfaces for CAGD" using StyleForm, StringForm, Subscript, Superscript, and Subsuperscript. The symbols should be used in Text primitives inside Graphics3D objects and can then be converted using toTextPrimitivesRules to Text primitives that are understood by LiveGraphics3D.

Implementation

symbolItalic[x_] := 
        StyleForm[ToString[x], 
          FontSlant -> "Italic"];
symbolBold[x_] := 
        StyleForm[ToString[x], 
          FontWeight -> "Bold"];
symbolRoman[x_] := ToString[x];
rmA := symbolRoman["A"];
rmB := symbolRoman["B"];
rmC := symbolRoman["C"];
rmD := symbolRoman["D"];
rmE := symbolRoman["E"];
rmF := symbolRoman["F"];
rmG := symbolRoman["G"];
rmH := symbolRoman["H"];
rmI := symbolRoman["I"];
rmJ := symbolRoman["J"];
rmK := symbolRoman["K"];
rmM := symbolRoman["M"];
rmN := symbolRoman["N"];
rmO := symbolRoman["O"];
rmX := symbolRoman["X"];
rmY := symbolRoman["Y"];
rmZ := symbolRoman["Z"];
itB := symbolItalic["B"];
itH := symbolItalic["H"];
itU := symbolItalic["U"];
itN := symbolItalic["N"];
ita := symbolItalic["a"];
itb := symbolItalic["b"];
itc := symbolItalic["c"];
itd := symbolItalic["d"];
iti := symbolItalic["i"];
itf := symbolItalic["f"];
itn := symbolItalic["n"];
its := symbolItalic["s"];
itt := symbolItalic["t"];
itu := symbolItalic["u"];
itv := symbolItalic["v"];
itw := symbolItalic["w"];
bfa :=  symbolBold["a"];
bfb :=  symbolBold["b"];
bfc :=  symbolBold["c"];
bfd :=  symbolBold["d"];
bfi :=  symbolBold["i"];
bfl := symbolBold["l"];
bfm := symbolBold["m"];
bfn := symbolBold["n"];
bfp :=  symbolBold["p"];
bfq :=  symbolBold["q"];
bft :=  symbolBold["t"];
bfu :=  symbolBold["u"];
bfv :=  symbolBold["v"];
bfw :=  symbolBold["w"];
bfx :=  symbolBold["x"]
bfxu := Subscript[bfx, itu];
bfxv := Subscript[bfx, itv];
taui[i_] := Subscript["τ", i];
itBin[i_, n_] := 
        Subsuperscript[itB, i, n];
itBinu[i_, n_, u_] := 
        StringForm["``(``)", Subsuperscript[itB, i, n], 
          u];
itHi[i_] := Subscript[itH, i];
itHin[i_, n_] := 
        Subsuperscript[itH, i, n];
itHinu[i_, n_, u_] := 
      StringForm["``(``)", Subsuperscript[itH, i, n], u]; 
    itUin[i_, n_] := Subsuperscript[itU, i, n];
itNin[i_, n_] := 
        Subsuperscript[itN, i, n];
itti[i_] := Subscript[itt, i];
itbi[i_] := Subscript[itb, i];
itui[i_] := Subscript[itu, i];
bfli[i_] := 
        StringForm["``(``)", bfl, i];
bfmi[i_] := Subscript[bfm, i];
bfci[i_] := Subscript[bfc, i];
bfdi[i_] := Subscript[bfd, i];
bfbi[i_] := Subscript[bfb, i];
bfbst[s_, t_] := 
        StringForm["``[``,``]", bfb, s, t];
bfpi[i_] := Subscript[bfp, i];
bfpir[i_, r_] := 
        Subsuperscript[bfp, i, r];
bfbt[t_] := 
        StringForm["``(``)", bfb, t];
bfb1[t1_] := 
        StringForm["``[``]", bfb, t1];
bfb2[t1_, t2_] := 
        StringForm["``[``,``]", bfb, t1, 
          t2];
bfb3[t1_, t2_, t3_] := StringForm["``[``,``,``]", bfb, t1, t2, t3]; 
    bfb3spaced[t1_, t2_, t3_] := 
      StringForm["``[``,``,``]", bfb, t1, t2, 
        t3];
bfbi[i_] := Subscript[bfb, i];
bfbir[i_, r_] := 
        Subsuperscript[bfb, i, r];
bfbirt[i_, r_, t_] := 
        StringForm["``(``)", Subsuperscript[bfb, i, r], 
          t];
bfbir1[i_, r_, t1_] := 
        StringForm["``[``]", Subsuperscript[bfb, i, r], 
          t1];
bfbir2[i_, r_, t1_, t2_] := 
        StringForm["``[``,``]", Subsuperscript[bfb, i, r], t1, 
          t2];
bfbir3[i_, r_, t1_, t2_, t3_] := 
        StringForm["``[``,``,``]", Subsuperscript[bfb, i, r], t1, t2, 
          t3];
symbolseq[x__] := 
        StringForm[StringJoin[Table["``", {Length[List[x]]}]], 
          x];

Rules for (In-)Dependent Variables

Overview

These sets of rules are useful for vectors, in particular if the code for other (in)dependent Variables has to know whether a vector has been modified. 
— defineVector["a"] clears a, ax, ay, az, axOld, ayOld, azOld, aIsNew and defines a={ax, ay, az}
— independentVariablesForVector["a", {x,y,z}] returns {ax->x, ay->y, az->z, axOld->x, ayOld->y, azOld->z}
— dependentVariablesForVectorProlog["a"] returns {aIsNew->(ax != axOld || ay != ayOld || az != azOld)}
— dependentVariablesForVectorEpilog["a"] returns {axOld -> ax, ayOld->ay, azOld -> az} 
— dependentVariablesForReassignmentOfVector["a", expr] returns {ax->If[!aIsNew, ax, expr[[1]]], ay->..., az->...}

Implementation

defineVector[name_String] := 
        Module[{}, 
          ClearAll[name, Evaluate[name <> "x"], 
            Evaluate[name <> "y"], Evaluate[name <> "z"], 
            Evaluate[name <> "xOld"], Evaluate[name <> "yOld"], 
            Evaluate[name <> "zOld"], Evaluate[name <> "IsNew"]]; 
          Evaluate[Symbol[name]] = {Symbol[name <> "x"], 
              Symbol[name <> "y"], 
              Symbol[name <> "z"]}];
defineVector[list_List] := 
        Map[defineVector, list];
independentVariablesForVector[name_String, 
          value_List] := {Symbol[name <> "x"] -> value[[1]], 
          Symbol[name <> "y"] -> value[[2]], 
          Symbol[name <> "z"] -> value[[3]], 
          Symbol[name <> "xOld"] -> value[[1]], 
          Symbol[name <> "yOld"] -> value[[2]], 
          Symbol[name <> "zOld"] -> 
            value[[3]]};
dependentVariablesForVectorProlog[
          name_String] := {Symbol[
              name <> "IsNew"] -> (Symbol[name <> "x"] != 
                  Symbol[name <> "xOld"] || 
                Symbol[name <> "y"] != Symbol[name <> "yOld"] || 
                Symbol[name <> "z"] != 
                  Symbol[name <> "zOld"])};
dependentVariablesForVectorEpilog[
          name_String] := {Symbol[name <> "xOld"] -> 
            Symbol[name <> "x"], 
          Symbol[name <> "yOld"] -> Symbol[name <> "y"], 
          Symbol[name <> "zOld"] -> 
            Symbol[name <> "z"]};
dependentVariablesForReassignmentOfVector[name_String, 
          triggerName_String, expr_] := 
        Module[{namex = Symbol[name <> "x"], 
            namey = Symbol[name <> "y"], 
            namez = Symbol[name <> "z"], 
nameIsNew = 
              Symbol[triggerName <> "IsNew"]}, {namex -> 
              If[Evaluate[! nameIsNew], Evaluate[namex], 
                Evaluate[expr[[1]]]], 
            namey -> 
              If[Evaluate[! nameIsNew], Evaluate[namey], 
                Evaluate[expr[[2]]]], 
            namez -> 
              If[Evaluate[! nameIsNew], Evaluate[namez], 
                Evaluate[expr[[3]]]]}];
dependentVariablesForVector[name_String,  expr_] := 
        Module[{namex = Symbol[name <> "x"], 
            namey = Symbol[name <> "y"], 
            namez = Symbol[name <> "z"]}, {namex -> expr[[1]], 
            namey -> expr[[2]], 
            namez -> expr[[3]]}];

Figures To Do

14.1, 14.7, 15.1, 15.5, 15.6, 16.15, 16.16, 16.19, 17.1, 19.1, 19.2, 19.3, 19.4, 19.6, 22.1, 22.3, 22.6.

Figures for Chapter 1

Figure 1.2 and 1.3, page 3

Input: three 2D points a, b, c

Interaction: 
— if point a is moved, project it to unit sphere around b
— if point c is moved, project it to unit sphere around b
— if point b is moved, move a and c accordingly

Output: 
— the fourth corner d of a parallelogram abcd
— an arc from a to c with tagents ab and bc
— "wodden" frame of parallelogram and strings within frame

defineVector[{"a", "b", "c", "d"}]

independentVariables = 
      Flatten[{independentVariablesForVector["a", {0, 0, 0}], 
          independentVariablesForVector["b", {0, 1, 0}], 
          independentVariablesForVector["c", {1, 1, 0}]}]

\(dependentVariables = 
      Flatten[{dependentVariablesForVectorProlog["a"], 
          dependentVariablesForVectorProlog["b"], 
          dependentVariablesForVectorProlog["c"], 
dependentVariablesForReassignmentOfVector["a", "b", b - {bxOld, byOld, bzOld} + 
              a], 
dependentVariablesForReassignmentOfVector["c", "b", 
            b - {bxOld, byOld, bzOld} + 
              c], 
abLength -> 
            Sqrt[\((a - b)\) . \((a - 
                    b)\)], 
cbLength -> 
            Sqrt[\((c - b)\) . \((c - 
                    b)\)], 
dependentVariablesForReassignmentOfVector["a", "a", \((b + \((a - 
                      b)\)/abLength)\)], 
          dependentVariablesForReassignmentOfVector["c", "c", \((b + \((c - b)\)/
                  cbLength)\)], 
dependentVariablesForVector["d", \((a + c - 
                b)\)], 
dependentVariablesForVectorEpilog["a"], dependentVariablesForVectorEpilog["b"], 
          dependentVariablesForVectorEpilog["c"]}]\)

linePoints = 
      Table[b + (c - b)*(0.9 - 0.8*Sin[i/6*Pi/2]) + (a - 
                b)*(0.9 - 0.8*Cos[i/6*Pi/2]), {i, 0, 
          6}]; 
lineBCs = 
      Table[(0.9 - 0.8*Sin[i/6*Pi/2]), {i, 0, 
          6}]; 
lineBAs = Table[(0.9 - 0.8*Cos[i/6*Pi/2]), {i, 0, 6}];

chap1fig2 := 
      Graphics3D[{{PointSize[0.04], RGBColor[0. , 1, 0. ], 
            Point[a + {0, 0, 0.01}], Point[b + {0, 0, 0.01}], 
            Point[c + {0, 0, 0.01}]}, {PointSize[0.02], GrayLevel[0. ], 
            Point[d], Map[Point, linePoints], 
            Map[Point[b + (c - b)*#] &, lineBCs], 
            Map[Point[b + (c - b)*# + (a - b)] &, lineBCs], 
            Map[Point[b + (a - b)*#] &, lineBAs], 
            Map[Point[b + (a - b)*# + (c - b)] &, 
              lineBAs]}, {Thickness[0.01], Line[{a, b, c, d, a}], 
            Thickness[0.01], Line[linePoints], Thickness[0.0025], 
            Map[Line[{b + (c - b)*#, b + (c - b)*# + (a - b)}] &, 
              lineBCs], 
            Map[Line[{b + (a - b)*#, b + (a - b)*# + (c - b)}] &, 
              lineBAs]}, {Text[rmA, a, {1, 1}], Text[rmB, b, {1, -1}], 
            Text[rmC, c, {-1, -1}]}}, ViewPoint -> {0, 0, 4}, 
        ViewVertical -> {0, 1, 0}, SphericalRegion -> True, 
        PlotRange -> {{-0.1, 1.7}, {-0.7, 1.1}, {-0.1, 
              0.1}}, Boxed -> False, Axes -> False, 
        Ticks -> Automatic, 
        AxesLabel -> {"x", "y", "z"}, 
        TextStyle -> newTextStyle]

Show[
      chap1fig2 //. 
        Join[independentVariables, dependentVariables]]

SetDirectory["/Users/martin/Desktop/mmasources"]

WriteLiveForm["chap1fig2.m", chap1fig2]

WriteHtmlPage["chap1fig2.html", "<FONT SIZE=+2><B>Figures 1.2 and \
1.3</B> [Farin 2002, page 3]</FONT>", "chap1fig2.m", 800, 500, 
      independentVariables,  
      dependentVariables, "<PARAM NAME=BGCOLOR VALUE=#FFFFFF>\n<PARAM NAME=\
\"POINT_EDGE_COLOR\" VALUE=#000000>\n<PARAM NAME=\"MOUSE_DRAG_ACTION\" VALUE=\
\"NONE\">\n"]

Figure 1.5, page 5

Input: three 3D points a, b, c

Interaction: 
— any movement in 3D

Output: 
— the fourth corner d of a parallelogram abcd
— an arc from a to c with tagents ab and bc

defineVector[{"a",  "b",  "c", "d"}]

independentVariables = 
      Flatten[{independentVariablesForVector["a", {0, 0, 0}], 
          independentVariablesForVector["b", {0, 1, 0}], 
          independentVariablesForVector["c", {1, 1, 0}]}]

dependentVariables = 
      Flatten[{
dependentVariablesForVector["d", (a + 
                c - b)]}]

linePoints = 
      Table[b + (c - b)*(1 - Sin[i/32*Pi/2]) + (a - b)*(1 - 
                Cos[i/32*Pi/2]), {i, 0, 32}];

chap1fig5 := 
      Graphics3D[{{PointSize[0.04], RGBColor[0. , 1, 0. ], Point[a], 
            Point[b], Point[c]}, {PointSize[0.02], GrayLevel[0. ], 
            Point[d]}, {Thickness[0.01], Line[{a, b, c}], Thickness[0.01], 
            Line[linePoints], Thickness[0.005], Line[{a, d, c}]}}, 
        ViewPoint -> {0, 0, 4}, ViewVertical -> {0, 1, 0}, 
        SphericalRegion -> True, 
        PlotRange -> {{-0.2, 1.2}, {-0.2, 1.2}, {-0.1, 
              0.1}}, Boxed -> False, Axes -> False, 
        Ticks -> Automatic, 
        AxesLabel -> {"x", "y", "z"}, 
        TextStyle -> newTextStyle]

Show[
      chap1fig5 //. 
        Join[independentVariables, dependentVariables]]

SetDirectory["/Users/martin/Desktop/mmasources"]

WriteLiveForm["chap1fig5.m", chap1fig5]

WriteHtmlPage["chap1fig5.html", "<FONT SIZE=+2><B>Figure 1.5</B> \
[Farin 2002, page 5]</FONT>", "chap1fig5.m", 800, 500, 
      independentVariables,  
      dependentVariables, "<PARAM NAME=BGCOLOR VALUE=#FFFFFF>\n<PARAM NAME=\
\"POINT_EDGE_COLOR\" VALUE=#000000>\n"]

Figure 1.10, page 8

Input: four 3D points o, m, n, b

Interaction: 
— any movement in 3D

Output: 
— the remaining corners y, x, a, c of a parallelepiped
— arcs from o to a, o to n, combination from o to b

\(defineVector[{"o", "m", "n", "b", "x", "y", "a", "c"}]\)

independentVariables = 
      Flatten[{independentVariablesForVector["o", {0, 0, 0}], 
          independentVariablesForVector["m", {0, 0, -1}], 
          independentVariablesForVector["n", {0, 1, -1}], 
          independentVariablesForVector["b", {1, 1, -1}]}]

dependentVariables = 
      Flatten[{
dependentVariablesForVector["x", (o + 
                b - n)], 
          dependentVariablesForVector["y", (o + n - m)], 
          dependentVariablesForVector["a", (o + b - m)], 
          dependentVariablesForVector["c", (m + b - n)]}]

maxI = 12; 
linePointsA = 
      Table[o + (x - o)*(1 - Sqrt[1 - (i/maxI)^2]) + (y - o)*
            i/maxI, {i, 0, maxI}]; 
linePointsN = 
      Table[o + (m - o)*Sqrt[1 - (1 - i/maxI)^2] + (y - o)*
            i/maxI, {i, 0, maxI}]; 
linePointsB = 
      Table[o + (m - o)*Sqrt[1 - (1 - i/maxI)^2] + (y - o)*
            i/maxI + (x - o)*(1 - Sqrt[1 - (i/maxI)^2]), {i, 0, 
          maxI}]; 
linesA = 
      Map[Line, 
        Transpose[{linePointsB, linePointsA}]]; 
linesN = 
      Map[Line, 
        Transpose[{linePointsB,  linePointsN}]]; 
maxI = 48; 
linePointsAFull = 
      Table[o + (x - o)*(1 - Sqrt[1 - (i/maxI)^2]) + (y - o)*
            i/maxI, {i, 0, maxI}]; 
linePointsNFull = 
      Table[o + (m - o)*Sqrt[1 - (1 - i/maxI)^2] + (y - o)*
            i/maxI, {i, 0, maxI}]; 
linePointsBFull = 
      Table[o + (m - o)*Sqrt[1 - (1 - i/maxI)^2] + (y - o)*
            i/maxI + (x - o)*(1 - Sqrt[1 - (i/maxI)^2]), {i, 0, 
          maxI}];

stretchedArc[o_, m_, n_, b_, t_] := 
      o + (m - o)*Sqrt[1 - (1 - t)^2] + (n - m)*
          t + (b - n)*(1 - Sqrt[1 - t^2]);

chap1fig10 := 
      Graphics3D[{{PointSize[0.04], RGBColor[0. , 1, 0. ], Point[o], 
            Point[m], Point[n], Point[b]}, {PointSize[0.02], GrayLevel[0. ], 
            Point[x], Point[y], Point[a], Point[c]}, {Thickness[0.01], 
            Line[linePointsBFull], Thickness[0.005], Line[linePointsAFull], 
            Line[linePointsNFull], Thickness[0.0025], linesA, linesN, 
            Thickness[0.005], Line[{o, y, n}], Line[{m, c, x, o}], 
            Line[{x, a, y}], Line[{a, b, c}], Thickness[0.01], 
            Line[{o, m, n, b}]}, {Text[rmO, o, {1.4, 1.4}], 
            Text[rmY, y, {1.4, 1.4}], Text[rmX, x, {-1.4, 1.4}], 
            Text[rmZ, m, {1.4, 1.4}], Text[rmM, m, {-1.4, -1.4}], 
            Text[rmN, n, {-1.4, 1.4}], 
            Text[rmB, b, {-1.4, -1.4}]}}, 
        ViewPoint -> {-2, 4, -3}, 
        ViewVertical -> {-0.02, 0, -1}, 
        SphericalRegion -> True, 
        PlotRange -> {{-0.2, 1.2}, {-0.2, 1.2}, {-1.2, 
              0.2}}, Boxed -> False, Axes -> False, 
        Ticks -> Automatic, 
        AxesLabel -> {"x", "y", "z"}, 
        TextStyle -> newTextStyle]

Show[
      chap1fig10 //. 
        Join[independentVariables, dependentVariables]]

SetDirectory["/Users/martin/Desktop/mmasources"]

WriteLiveForm["chap1fig10.m", chap1fig10]

WriteHtmlPage["chap1fig10.html", "<FONT SIZE=+2><B>Figure \
1.10</B> [Farin 2002, page 8]</FONT>", "chap1fig10.m", 800, 500, 
      independentVariables,  
      dependentVariables, "<PARAM NAME=BGCOLOR VALUE=#FFFFFF>\n<PARAM NAME=\
\"POINT_EDGE_COLOR\" VALUE=#000000>\n"]

Figure 1.13, page 10

Input: eighteen 3D points p00(=a), p01, p02, p03(=b), p10 (=g), ..., p13(=h), p20(=j), ..., p23(=k), p30 (=c), ..., p33 (=d), e

Interaction: 
— any movement in 3D of the p's
— if e is moved, compute new parameter u from distances to a and b

Output: 
— compute e, f, ee, ff from u
— lost of arcs

\(defineVector[{"p00", "p01", "p02", "p03", "p10", "p11", "p12", "p13", "p20", "p21", "p22", "p23", "p30", "p31", "p32", "p33", "e", "f", "ee", "ff"}]; \)

stretchedArc[o_, m_, n_, b_, u_] := 
      o + (m - o)*Sqrt[1 - (1 - u)^2] + (n - m)*
          u + (b - n)*(1 - Sqrt[1 - u^2]);

\(independentVariables = 
      Flatten[{independentVariablesForVector["p00", {0, 0, 
              0}], 
independentVariablesForVector["p01", {0, 1, 2}], 
independentVariablesForVector["p02", {0, 
              2, 2}], 
independentVariablesForVector["p03", {0, 3, 
              0}], 
independentVariablesForVector["p10", {1, 0, 1}], 
independentVariablesForVector["p11", {1, 
              1, 2}], 
independentVariablesForVector["p12", {1, 2, 
              1}], 
independentVariablesForVector["p13", {1, 3, \(-1\)}], 
independentVariablesForVector["p20", {2, 0, 1}], 
independentVariablesForVector["p21", {2, 
              1, 0}], 
independentVariablesForVector["p22", {2, 2, 
              1}], 
independentVariablesForVector["p23", {2, 3, 0}], 
independentVariablesForVector["p30", {3, 
              0, 0}], 
independentVariablesForVector["p31", {3, 1, \(-2\)}], 
independentVariablesForVector["p32", {3, 2, 
              1}], 
independentVariablesForVector["p33", {3, 3, 0}], independentVariablesForVector["e", {0, 0.6, 0}], 
          u -> 0.1}]\)

\(dependentVariables = 
      Flatten[{dependentVariablesForVectorProlog["e"], 
u -> 
            If[\(! eIsNew\), u, 
              Evaluate[\((\((e - p00)\) . \((p03 - p00)\)/\((p00 - 
                          p03)\) . \((p00 - p03)\))\)]], 
          u -> 
            If[u > 1, 1, 
              If[u < 0. , 0. , 
                u]], 
dependentVariablesForVector["e", 
            stretchedArc[p00, p01, p02, p03, 
              u]], 
dependentVariablesForVector["ee", 
            stretchedArc[p10, p11, p12, p13, 
              u]], 
dependentVariablesForVector["ff", 
            stretchedArc[p20, p21, p22, p23, 
              u]], 
dependentVariablesForVector["f", 
            stretchedArc[p30, p31, p32, p33, 
              u]], 
dependentVariablesForVectorEpilog["e"]}]; \)

maxI = 24; 
linePointsEF = 
      Table[stretchedArc[e, ee, ff, f, i/maxI], {i, 0, 
          maxI}]; 
linePointsP0x = 
      Table[stretchedArc[p00, p01, p02, p03, i/maxI], {i, 0, maxI}]; 
    linePointsP1x = 
      Table[stretchedArc[p10, p11, p12, p13, i/maxI], {i, 0, maxI}]; 
    linePointsP2x = 
      Table[stretchedArc[p20, p21, p22, p23, i/maxI], {i, 0, 
          maxI}]; 
linePointsP3x = 
      Table[stretchedArc[p30, p31, p32, p33, i/maxI], {i, 0, 
          maxI}]; 
linePointsPx0 = 
      Table[stretchedArc[p00, p10, p20, p30, i/maxI], {i, 0, 
          maxI}]; 
linePointsPx3 = 
      Table[stretchedArc[p03, p13, p23, p33, i/maxI], {i, 0, 
          maxI}];

chap1fig13 := 
      Graphics3D[{{PointSize[0.03], RGBColor[0. , 1, 0. ], Point[p00], 
            Point[p01], Point[p02], Point[p03], Point[p10], Point[p11], 
            Point[p12], Point[p13], Point[p20], Point[p21], Point[p22], 
            Point[p23], Point[p30], Point[p31], Point[p32], Point[p33], 
            PointSize[0.04], Point[e]}, {PointSize[0.02], GrayLevel[0. ], 
            Point[ee], Point[ff], Point[f]}, {Thickness[0.01], 
            Line[linePointsEF], Thickness[0.005], Line[linePointsP0x], 
            Line[linePointsP1x], Line[linePointsP2x], Line[linePointsP3x], 
            Line[linePointsPx0], Line[linePointsPx3], Line[{e, ee}], 
            Line[{ee, ff}], Line[{ff, f}], Thickness[0.005], 
            Line[{p00, p01}], Line[{p01, p02}], Line[{p02, p03}], 
            Line[{p10, p11}], Line[{p11, p12}], Line[{p12, p13}], 
            Line[{p20, p21}], Line[{p21, p22}], Line[{p22, p23}], 
            Line[{p30, p31}], Line[{p31, p32}], Line[{p32, p33}], 
            Line[{p00, p10}], Line[{p10, p20}], Line[{p20, p30}], 
            Line[{p01, p11}], Line[{p11, p21}], Line[{p21, p31}], 
            Line[{p02, p12}], Line[{p12, p22}], Line[{p22, p32}], 
            Line[{p03, p13}], Line[{p13, p23}], 
            Line[{p23, p33}]}, {Text[rmA, p00, {1.5, -1.5}], 
            Text[rmB, p03, {1.5, 1.5}], Text[rmC, p30, {-1.5, -1.5}], 
            Text[rmD, p33, {-1.5, 1.5}], Text[rmE, e, {1.5, 1.5}], 
            Text[rmF, f, {-1.5, 1.5}], Text[rmG, p10, {1.5, -1.5}], 
            Text[rmH, p13, {-1.5, 1.5}], Text[rmJ, p20, {1.5, -1.5}], 
            Text[rmK, p23, {-1.5, 1.5}]}}, 
        ViewPoint -> {-1, 2, -5}, 
        ViewVertical -> {0, 0, -1}, SphericalRegion -> True, 
        PlotRange -> {{-0.2, 3.2}, {-0.2, 3.2}, {-2.2, 
              2.2}}, Boxed -> False, Axes -> False, 
        Ticks -> Automatic, 
        AxesLabel -> {"x", "y", "z"}, 
        TextStyle -> newTextStyle]

Show[
      chap1fig13 //. 
        Join[independentVariables, dependentVariables]]

SetDirectory["/Users/martin/Desktop/mmasources"]

WriteLiveForm["chap1fig13.m", chap1fig13]

WriteHtmlPage["chap1fig13.html", "<FONT SIZE=+2><B>Figure \
1.13</B> [Farin 2002, page 10]</FONT>", "chap1fig13.m", 800, 500, 
      independentVariables,  
      dependentVariables, "<PARAM NAME=BGCOLOR VALUE=#FFFFFF>\n<PARAM NAME=\
\"POINT_EDGE_COLOR\" VALUE=#000000>\n"]

Figures for Chapter 2

Figure 2.1, page 14

Input: three 3D points a, b, c

Interaction: 
— any movement in 3D

Output: 
— the fourth corner d of a parallelogram abcd
— arrows and labels for a, b, w (=c-a), v (=b-a)

SetDirectory["/Users/martin/Desktop/mmasources"]

<< Arrow3D`

defineVector[{"a", "b", "c", "d"}]

independentVariables = 
      Flatten[{independentVariablesForVector["a", {0, 0, 0}], 
          independentVariablesForVector["b", {0.5, 0.2, 0}], 
          independentVariablesForVector["c", {0.2, 0.5, 0}]}]

dependentVariables = 
      Flatten[{
dependentVariablesForVector["d", (b + 
                c - a)]}]

SetOptions[Arrow3D,  HeadLength -> 0.1];

chap2fig1 := 
      Graphics3D[{{PointSize[0.04], RGBColor[0. , 1, 0. ], 
            Point[a + {0, 0, 0.01}], Point[b + {0, 0, 0.01}], 
            Point[c + {0, 0, 0.01}]}, {PointSize[0.02], GrayLevel[0. ], 
            Point[d + {0, 0, 0.01}]}, {Thickness[0.01], 
            SurfaceColor[GrayLevel[0. ]], Arrow3D[a, b], Arrow3D[a, c], 
            Arrow3D[b, d], Arrow3D[c, d], Thickness[0.01], 
            Thickness[0.0025]}, {Text[bfa, a, {1.2, 1.2}], 
            Text[bfb, b, {-1.2, 1.2}], 
            Text[bfv, (a + b)/2, {0, 1.2}], 
            Text[bfw, (a + c)/2, {1.5, 0}], 
            Text[bfw, (b + d)/2, {-1.5, 0}], 
            Text[bfv, (c + d)/2, {0, -1.2}]}}, 
        ViewPoint -> {0, 0, 4}, ViewVertical -> {0, 1, 0}, 
        SphericalRegion -> True, 
        PlotRange -> {{-0.1, 1.1}, {-0.1, 1.1}, {-0.1, 
              0.1}}, Boxed -> False, Axes -> False, 
        Ticks -> Automatic, 
        AxesLabel -> {"x", "y", "z"}, 
        TextStyle -> newTextStyle]

Show[
      chap2fig1 //. 
        Join[independentVariables, dependentVariables]]

SetDirectory["/Users/martin/Desktop/mmasources"]

WriteLiveForm["chap2fig1.m", chap2fig1]

WriteHtmlPage["chap2fig1.html", "<FONT SIZE=+2><B>Figure 2.1</B> \
[Farin 2002, page 14]</FONT>", "chap2fig1.m", 800, 500, 
      independentVariables,  
      dependentVariables, "<PARAM NAME=BGCOLOR VALUE=#FFFFFF>\n<PARAM NAME=\
\"MOUSE_DRAG_ACTION\" VALUE=\"NONE\">\n<PARAM NAME=\"POINT_EDGE_COLOR\" \
VALUE=#000000>\n"]

Figure 2.2, page 15

Input: three 3D points p, q, o

Interaction: 
— any movement of p, q, o in 3D

Output: 
— the sum pq of p and q
— the point opq = (p-o)+(q-o)+o
— coordinate system, arrows and labels for p, q, pq, opq

SetDirectory["/Users/martin/Desktop/mmasources"]

<< Arrow3D`

defineVector[{"p", "q", "o", "pq", "opq"}]

independentVariables = 
      Flatten[{independentVariablesForVector["o", {-0.2, 0.2, 0}], 
          independentVariablesForVector["p", {0.3, 0.7, 0}], 
          independentVariablesForVector["q", {0.4, 0.4, 0}]}]

\(dependentVariables = 
      Flatten[{
dependentVariablesForVector["pq", \((p + q)\)], dependentVariablesForVector["opq", \((\((p - o)\) + \((q - 
                    o)\) + o)\)]}]\)

SetOptions[Arrow3D,  HeadLength -> 0.15];

chap2fig2 := 
      Graphics3D[{{PointSize[0.04], RGBColor[0. , 1, 0. ], 
            Point[p + {0, 0, 0.01}], 
            Point[q + {0, 0, 0.01}]}, {PointSize[0.02], GrayLevel[0. ], 
            Point[pq + {0, 0, 0.01}]}, {Thickness[0.01], EdgeForm[], 
            SurfaceColor[GrayLevel[0. ]], Arrow3D[{0, 0, 0}, {1.5, 0, 0}], 
            Arrow3D[{0, 0, 0}, {0, 1.5, 0}], Arrow3D[{0, 0, 0}, p], 
            Arrow3D[{0, 0, 0}, q], Arrow3D[p, pq], 
            Arrow3D[q, pq]}, {Text[bfp, p, {1.5, -1.5}], 
            Text[bfq, q, {-2, 0.2}], 
            Text[symbolBold["p+q"], 
              pq, {-1.2, -1. }]}, {PointSize[0.04], 
            RGBColor[0. , 1, 0. ], 
            Point[o + {0, 0, 0.01}]}, {Thickness[0.01], EdgeForm[], 
            SurfaceColor[GrayLevel[0.6]], GrayLevel[0.6], 
            Arrow3D[o, o + {1.5, 0, 0}], Arrow3D[o, o + {0, 1.5, 0}], 
            Arrow3D[o, p], Arrow3D[o, q], Arrow3D[p, opq], 
            Arrow3D[q, opq]}, {PointSize[0.02], GrayLevel[0.6], 
            Point[opq]}, {GrayLevel[0.6], 
            Text[symbolBold["p+q?"], opq, {-1.2, 1. }]}}, 
        ViewPoint -> {0, 0, 4}, ViewVertical -> {0, 1, 0}, 
        SphericalRegion -> True, 
        PlotRange -> {{-0.3, 1.5}, {-0.1, 1.7}, {-0.1, 
              0.1}}, Boxed -> False, Axes -> False, 
        Ticks -> Automatic, Lighting -> False, 
        AxesLabel -> {"x", "y", "z"}, 
        TextStyle -> newTextStyle]

Show[
      chap2fig2 //. 
        Join[independentVariables, dependentVariables]]

SetDirectory["/Users/martin/Desktop/mmasources"]

WriteLiveForm["chap2fig2.m", Chop[chap2fig2]]

WriteHtmlPage["chap2fig2.html", "<FONT SIZE=+2><B>Figure 2.2</B> \
[Farin 2002, page 15]</FONT>", "chap2fig2.m", 800, 500, 
      independentVariables,  
      dependentVariables, "<PARAM NAME=BGCOLOR VALUE=#FFFFFF>\n<PARAM NAME=\
\"MOUSE_DRAG_ACTION\" VALUE=\"NONE\">\n<PARAM NAME=\"POINT_EDGE_COLOR\" \
VALUE=#000000>\n"]

Figure 2.3, page 16

Input: five 3D points a,b,c,d,e

Interaction: 
— any movement of a,b,c,d,e in 2D

Output: 
— polygon abcde
— edgeless triangles abc, abd, abe, acd, ace, ade, bcd, bce, bde

SetDirectory["/Users/martin/Desktop/mmasources"]

defineVector[{"a", "b", "c", "d", "e"}]

\(independentVariables = 
      Flatten[{independentVariablesForVector["a", {0. , 0, \ 0. }], 
          independentVariablesForVector["b", {0.2, 0.4, 0. }], 
          independentVariablesForVector["c", {0.8, 0.8, 0. }], 
          independentVariablesForVector["d", {0.2, 0.9, 
              0. }], 
independentVariablesForVector["e", {0.9, 0.2, 0. }]}]\)

dependentVariables = Flatten[{}]

chap2fig3 := 
      Graphics3D[{{PointSize[0.04], RGBColor[0. , 1, 0. ], 
            Point[a + {0, 0, 0.1}], Point[b + {0, 0, 0.1}], 
            Point[c + {0, 0, 0.1}], Point[d + {0, 0, 0.1}], 
            Point[e + {0, 0, 0.1}]}, {Thickness[0.01], 
            Line[{a + {0, 0, 0.1}, b + {0, 0, 0.1}, c + {0, 0, 0.1}, 
                d + {0, 0, 0.1}, e + {0, 0, 0.1}}]}, {EdgeForm[], 
            GrayLevel[0.7], Polygon[{a, b, c}], Polygon[{a, b, d}], 
            Polygon[{a, b, e}], Polygon[{a, c, d}], Polygon[{a, c, e}], 
            Polygon[{a, d, e}], Polygon[{b, c, d}], Polygon[{b, c, e}], 
            Polygon[{b, d, e}], Polygon[{c, d, e}]}}, 
        ViewPoint -> {0, 0, 4}, ViewVertical -> {0, 1, 0}, 
        SphericalRegion -> True, 
        PlotRange -> {{-0.2, 1.2}, {-0.2, 1.2}, {-0.1, 
              0.1}}, Boxed -> False, Axes -> False, 
        Ticks -> Automatic, Lighting -> False, 
        AxesLabel -> {"x", "y", "z"}, 
        TextStyle -> newTextStyle]

Show[
      chap2fig3 //. 
        Join[independentVariables, dependentVariables]]

SetDirectory["/Users/martin/Desktop/mmasources"]

WriteLiveForm["chap2fig3.m", chap2fig3]

WriteHtmlPage["chap2fig3.html", "<FONT SIZE=+2><B>Figure 2.3</B> \
[Farin 2002, page 16]</FONT>", "chap2fig3.m", 800, 500, 
      independentVariables,  
      dependentVariables, "<PARAM NAME=BGCOLOR VALUE=#FFFFFF>\n<PARAM NAME=\
\"MOUSE_DRAG_ACTION\" VALUE=\"NONE\">\n<PARAM NAME=\"POINT_EDGE_COLOR\" \
VALUE=#000000>\n"]

Figure 2.4, page 19

Input: three 3D points o,a,b

Interaction: 
— any movement of o,a,b in 2D
— if o is moved, move a and b accordingly

Output: 
— smiley (three circles, arc) 
— transformed smiley
— coordinate systems

SetDirectory["/Users/martin/Desktop/mmasources"]

<< Arrow3D`

defineVector[{"a", "b", "o"}];

independentVariables = 
      Flatten[{independentVariablesForVector["a", {-0.2, 0.2, 0. }], 
          independentVariablesForVector["b", {-0.4, 0.9,  0. }], 
          independentVariablesForVector["o", {-0.6, 0.2, 
              0. }]}]

\(dependentVariables = 
      Flatten[{dependentVariablesForVectorProlog["a"], 
          dependentVariablesForVectorProlog["b"], 
          dependentVariablesForVectorProlog["o"], 
dependentVariablesForReassignmentOfVector["a", "o", o - {oxOld, oyOld, ozOld} + 
              a], 
dependentVariablesForReassignmentOfVector["b", "o", 
            o - {oxOld, oyOld, ozOld} + 
              b], 
dependentVariablesForVectorEpilog["a"], dependentVariablesForVectorEpilog["b"], 
          dependentVariablesForVectorEpilog["o"]}]\)

headcenter = {0.5, 0.5, 0}; headradius = 0.45; 
    lefteyecenter = {0.68, 0.6, 0}; lefteyeradius = 0.12; 
    righteyecenter = {0.32, 0.6, 0}; righteyeradius = 0.12; 
    mouthcenter = {0.5, 0.5, 0}; mouthradius = 0.35;

maxi = 32; 
pointshead = 
      Table[(headcenter + 
            headradius*(Cos[i/maxi*2 Pi]*{1, 0, 0} + 
                  Sin[i/maxi*2  Pi]*{0, 1, 0})), {i, 0, 
          maxi}]; 
pointsheadtransformed = 
      Map[(o + Transpose[{a - o, b - o, {0, 0, 1}}] . #) &, 
        pointshead]; 
pointslefteye = 
      Table[(lefteyecenter + 
            lefteyeradius*(Cos[i/maxi*2 Pi]*{1, 0, 0} + 
                  Sin[i/maxi*2  Pi]*{0, 1, 0})), {i, 0, 
          maxi}]; 
pointslefteyetransformed = 
      Map[(o + Transpose[{a - o, b - o, {0, 0, 1}}] . #) &, 
        pointslefteye]; 
pointsmouth = 
      Table[(mouthcenter + 
            mouthradius*(Cos[i/maxi*2 Pi]*{1, 0, 0} + 
                  Sin[i/maxi*2  Pi]*{0, -1, 0})), {i, 0, 
          maxi/2}]; 
pointsmouthtransformed = 
      Map[(o + Transpose[{a - o, b - o, {0, 0, 1}}] . #) &, 
        pointsmouth]; 
maxi = 2; 
pointsrighteye = 
      Table[(righteyecenter + 
            righteyeradius*(Cos[i/maxi*2 Pi]*{1, 0, 0} + 
                  Sin[i/maxi*2  Pi]*{0, 1, 0})), {i, 0, 
          maxi}]; 
pointsrighteyetransformed = 
      Map[(o + Transpose[{a - o, b - o, {0, 0, 1}}] . #) &, 
        pointsrighteye];

SetOptions[Arrow3D,  HeadLength -> 0.15];

chap2fig4 := 
      Graphics3D[{{PointSize[0.04], RGBColor[0. , 1, 0. ], 
            Point[a + {0, 0, 0.1}], Point[b + {0, 0, 0.1}], 
            Point[o + {0, 0, 0.1}]}, {Thickness[0.01], EdgeForm[], 
            Arrow3D[{0, 0, 0}, {1, 0, 0}], Arrow3D[{0, 0, 0}, {0, 1, 0}], 
            GrayLevel[0.6], EdgeForm[], Arrow3D[{0, 0, 0}, o], Arrow3D[o, a], 
            Arrow3D[o, b]}, {Thickness[0.01], Line[pointshead], 
            Line[pointslefteye], Line[pointsrighteye], 
            Line[pointsmouth]}, {Thickness[0.01], GrayLevel[0.6], 
            Line[pointsheadtransformed], Line[pointslefteyetransformed], 
            Line[pointsrighteyetransformed], 
            Line[pointsmouthtransformed
]}}, 
        ViewPoint -> {0, 0, 4}, ViewVertical -> {0, 1, 0}, 
        SphericalRegion -> True, 
        PlotRange -> {{-1.1, 1.1}, {-0.1, 1.1}, {-0.1, 
              0.1}}, Boxed -> False, Axes -> False, 
        Ticks -> Automatic, Lighting -> False, 
        AxesLabel -> {"x", "y", "z"}, 
        TextStyle -> newTextStyle]

Show[
      chap2fig4 //. 
        Join[independentVariables, dependentVariables]]

SetDirectory["/Users/martin/Desktop/mmasources"]

WriteLiveForm["chap2fig4.m", chap2fig4]

WriteHtmlPage["chap2fig4.html", "<FONT SIZE=+2><B>Figure 2.4</B> \
[Farin 2002, page 19]</FONT>",  "chap2fig4.m", 800, 500, 
      independentVariables,  
      dependentVariables, "<PARAM NAME=BGCOLOR VALUE=#FFFFFF>\n<PARAM NAME=\
\"MOUSE_DRAG_ACTION\" VALUE=\"NONE\">\n<PARAM NAME=\"POINT_EDGE_COLOR\" \
VALUE=#000000>\n"]

Figure 2.5, page 22

Input: seven 3D points a, b, c, d, e, f, g

Interaction: 
— any movement of a, b, c, d, e, f, g  in 2D

Output: 
— center 
— main axes
— norm ellipse

SetDirectory["/Users/martin/Desktop/mmasources"]

<< Arrow3D`

\(defineVector[{"a", "b", "c", "d", "e", "f", "g", "centroid", "eig1", "eig2"}]; \)

independentVariables = 
      Flatten[{independentVariablesForVector["a", 
            2*{Random[] - 0.5, Random[] - 0.5, 0. }], 
          independentVariablesForVector["b", 
            2*{Random[] - 0.5, Random[] - 0.5, 0. }], 
          independentVariablesForVector["c", 
            2*{Random[] - 0.5, Random[] - 0.5, 0. }], 
          independentVariablesForVector["d", 
            2*{Random[] - 0.5, Random[] - 0.5, 0. }], 
          independentVariablesForVector["e", 
            2*{Random[] - 0.5, Random[] - 0.5, 0. }], 
          independentVariablesForVector["f", 
            2*{Random[] - 0.5, Random[] - 0.5, 0. }], 
          independentVariablesForVector["g", 
            2*{Random[] - 0.5, Random[] - 0.5, 0. }]}]

pMatrix = 
      Transpose[{a - centroid, b - centroid, c - centroid, d - centroid, 
          e - centroid, f - centroid, 
          g - centroid}]; 
bMatrix = pMatrix . Transpose[pMatrix]; 
aMatrix = 
      Inverse[{{b11, b12}, {b21, b22}}]; 
iMax = 64; 
ellipsePoints = 
      Table[centroid + Cos[i/iMax*2.  Pi]*eig1 + 
          Sin[i/iMax*2.  Pi]*eig2, {i, 0, iMax}];

\(dependentVariables = 
      Flatten[{dependentVariablesForVector["centroid", \((a + b + c + d + 
                  e + f + g)\)/7], 
          b11 -> bMatrix[\([\)\(1, 1\)\(]\)], 
b12 -> 
            bMatrix[\([\)\(1, 2\)\(]\)], 
b21 -> 
            bMatrix[\([\)\(2, 1\)\(]\)], 
b22 -> 
            bMatrix[\([\)\(2, 2\)\(]\)], 
a11 -> 
            aMatrix[\([\)\(1, 1\)\(]\)], 
a12 -> 
            aMatrix[\([\)\(1, 2\)\(]\)], 
a21 -> 
            aMatrix[\([\)\(2, 1\)\(]\)], 
a22 -> 
            aMatrix[\([\)\(2, 
              2\)\(]\)], 
eigval1 -> \(Eigenvalues[{{a11, 
                    a12}, {a21, 
                    a22}}]\)[\([\)\(1\)\(]\)], 
eigval2 -> \(Eigenvalues[{{a11, a12}, {a21, 
                    a22}}]\)[\([\)\(2\)\(]\)], 
eig1x -> \((\(\(Eigenvectors[{{a11, a12}, {a21, a22}}]\)[\([\)\(1\)\(]\)]/
                    Sqrt[\(Eigenvectors[{{a11, a12}, {a21, 
                                a22}}]\)[\([\)\(1\)\(]\)] . \(Eigenvectors[{{a11, a12}, {a21, a22}}]\)[\([\)\(1\)\(]\)]]\)/
                  Sqrt[eigval1])\)[\([\)\(1\)\(]\)], 
          eig1y -> \((\(\(Eigenvectors[{{a11, a12}, {a21, 
                            a22}}]\)[\([\)\(1\)\(]\)]/
                    Sqrt[\(Eigenvectors[{{a11, a12}, {a21, 
                                a22}}]\)[\([\)\(1\)\(]\)] . \(Eigenvectors[{{a11, a12}, {a21, a22}}]\)[\([\)\(1\)\(]\)]]\)/
                  Sqrt[eigval1])\)[\([\)\(2\)\(]\)], 
eig1z -> 0, 
          eig2x -> \((\(\(Eigenvectors[{{a11, a12}, {a21, 
                            a22}}]\)[\([\)\(2\)\(]\)]/
                    Sqrt[\(Eigenvectors[{{a11, a12}, {a21, 
                                a22}}]\)[\([\)\(2\)\(]\)] . \(Eigenvectors[{{a11, a12}, {a21, a22}}]\)[\([\)\(2\)\(]\)]]\)/
                  Sqrt[eigval2])\)[\([\)\(1\)\(]\)], 
          eig2y -> \((\(\(Eigenvectors[{{a11, a12}, {a21, 
                            a22}}]\)[\([\)\(2\)\(]\)]/
                    Sqrt[\(Eigenvectors[{{a11, a12}, {a21, 
                                a22}}]\)[\([\)\(2\)\(]\)] . \(Eigenvectors[{{a11, a12}, {a21, a22}}]\)[\([\)\(2\)\(]\)]]\)/
                  Sqrt[eigval2])\)[\([\)\(2\)\(]\)], 
eig2z -> 0}]; \)

SetOptions[Arrow3D,  HeadLength -> 0.3];

chap2fig5 := 
      Graphics3D[{{PointSize[0.04], RGBColor[0. , 1, 0. ], 
            Point[a + {0, 0, 0.01}], Point[b + {0, 0, 0.01}], 
            Point[c + {0, 0, 0.01}], Point[d + {0, 0, 0.01}], 
            Point[e + {0, 0, 0.01}], Point[f + {0, 0, 0.01}], 
            Point[g + {0, 0, 0.01}], GrayLevel[0], PointSize[0.02], 
            Point[centroid]}, {Thickness[0.01], EdgeForm[], GrayLevel[0], 
            Arrow3D[centroid, centroid + eig1], 
            Arrow3D[centroid, centroid + eig2]}, {Thickness[0.01], 
            Line[ellipsePoints]}}, ViewPoint -> {0, 0, 4}, 
        ViewVertical -> {0, 1, 0}, SphericalRegion -> True, 
        PlotRange -> {{-2. , 2. }, {-2. , 2. }, {-0.1, 
              0.1}}, Boxed -> False, Axes -> False, 
        Ticks -> Automatic, Lighting -> False, 
        AxesLabel -> {"x", "y", "z"}, 
        TextStyle -> newTextStyle]

SetDirectory["/Users/martin/Desktop/mmasources"]

WriteLiveForm["chap2fig5.m", chap2fig5]

WriteHtmlPage["chap2fig5.html", "<FONT SIZE=+2><B>Figure 2.5</B> \
[Farin 2002, page 22]</FONT>",  "chap2fig5.m", 800, 500, 
      independentVariables,  
      dependentVariables, "<PARAM NAME=BGCOLOR VALUE=#FFFFFF>\n<PARAM NAME=\
\"MOUSE_DRAG_ACTION\" VALUE=\"NONE\">\n<PARAM NAME=\"POINT_EDGE_COLOR\" \
VALUE=#000000>\n"]

Figure 2.6, page 23

Input: three function values f0, f1, f2, one coordinate t1

Interaction: 
— movement of t1 between 0 and 1; arbitrary movement of f0, f1, f2

Output: 
— coordinate system 
— hat functions

SetDirectory["/Users/martin/Desktop/mmasources"]

independentVariables = 
      Flatten[{f0 -> 1/4, f1 -> 3/4, f2 -> 2/4, 
          t1 -> 0.6}]

dependentVariables = 
      Flatten[{t1 -> If[t1 < 0, 0, If[t1 > 1, 1, t1]], 
          sf0 -> Round[f0*40]/10, sf1 -> Round[f1*40]/10, 
          sf2 -> Round[f2*40]/10}]

ytaxis = -0.6;

chap2fig6 := 
      Graphics3D[{{PointSize[0.04], RGBColor[0. , 1, 0. ], 
            Point[{t1, +ytaxis, 0.01}], Point[{0, f0, 0.01}], 
            Point[{t1, f1, 0.01}], Point[{1, f2, 0.01}]}, {Thickness[0.01], 
            GrayLevel[0], Line[{{0, f0, 0}, {t1, f1, 0}, {1, f2, 0}}], 
            Line[{{0, 0.3 + ytaxis, 0}, {t1, +ytaxis, 
                  0}, {1.1, +ytaxis, 0}}], 
            Line[{{0, +ytaxis, 0}, {t1, 0.3 + ytaxis, 
                  0}, {1, +ytaxis, 0}}], 
            Line[{{-0.1, +ytaxis, 0}, {t1, +ytaxis, 0}, {1, 
                  0.3 + ytaxis, 0}}]}, {Thickness[0.005], 
            Line[{{0, +ytaxis, 0}, {0, 0.3 - 0.05 + ytaxis, 0}}], 
            Line[{{t1, +ytaxis, 0}, {t1, 0.05 + ytaxis, 0}}], 
            Line[{{1, +ytaxis, 0}, {1, 0.3 - 0.05 + ytaxis, 0}}], 
            Line[{{-0.1, 0, 0}, {1.1, 0, 0}}], 
            Line[{{0, 0, 0}, {0, f0 - 0.05, 0}}], 
            Line[{{t1, 0, 0}, {t1, f1 - 0.05, 0}}], 
            Line[{{1, 0, 0}, {1, f2 - 0.05, 0}}]}, {Text[
              ita, {0, +ytaxis, 0}, {0, 1.2}], 
            Text[itb, {1, +ytaxis, 0}, {0, 1.2}], 
            Text[itti["1"], {t1, +ytaxis, 0}, {0, 1.2}], 
            Text[itf, {t1/2, (f0 + f1)/2, 0}, {0, -1.5}], 
            Text[sf0, {0, 0, 0}, {-1.2, -1.2}], 
            Text[sf1, {t1, 0, 0}, {-1.2, -1.2}], 
            Text[sf2, {1, 0, 0}, {-1.2, -1.2}], 
            Text[itHi["0"], {0, 0.3 + ytaxis, 0}, {0, -1.2}], 
            Text[itHi["1"], {t1, 0.3 + ytaxis, 0}, {0, -1.2}], 
            Text[itHi["2"], {1, 0.3 + ytaxis, 0}, {0, -1.2}]}}, 
        ViewPoint -> {0, 0, 4}, ViewVertical -> {0, 1, 0}, 
        SphericalRegion -> True, 
        PlotRange -> {{- .1, 1.1}, {ytaxis, 0.8}, {-0.1, 0.1}}, 
        Boxed -> False, Axes -> False, Ticks -> Automatic, 
        Lighting -> False, 
        AxesLabel -> {"x", "y", "z"}, 
        TextStyle -> newTextStyle]

Show[
      chap2fig6 //. 
        Join[independentVariables, dependentVariables]]

SetDirectory["/Users/martin/Desktop/mmasources"]

WriteLiveForm["chap2fig6.m", chap2fig6]

WriteHtmlPage["chap2fig6.html", "<FONT SIZE=+2><B>Figure 2.6</B> \
[Farin 2002, page 23]</FONT>",  "chap2fig6.m", 800, 500, 
      independentVariables,  
      dependentVariables, "<PARAM NAME=BGCOLOR VALUE=#FFFFFF>\n<PARAM NAME=\
\"MOUSE_DRAG_ACTION\" VALUE=\"NONE\">\n<PARAM NAME=\"POINT_EDGE_COLOR\" \
VALUE=#000000>\n"]

Figures for Chapter 3

Figure 3.1, page 26

Input: points a, b, coordinate t

Interaction: 
— free movement of a,b 
— movement of t on x axis between 0 and 1

Output: 
— point x (linear interpolation between a and b with t)
— lines, mapping arrow

SetDirectory["/Users/martin/Desktop/mmasources"]

<< Arrow3D`

defineVector[{"a", "b", "x"}]

independentVariables = 
      Flatten[{independentVariablesForVector["a", {0.2, 0.5, 0}], 
          independentVariablesForVector["b", {1.2, 1.3, 0}], 
          t -> 0.2}]

dependentVariables = 
      Flatten[{t -> If[t < 0, 0, If[t > 1, 1, t]], 
          dependentVariablesForVector["x", 
            a + t*(b - a)]}]

chap3fig1 := 
      Graphics3D[{{PointSize[0.04], RGBColor[0. , 1, 0. ], 
            Point[a + {0, 0, 0.01}], Point[b + {0, 0, 0.01}], 
            Point[{t, 0, 0.01}], GrayLevel[0], 
            Point[x + {0, 0, 0.01}]}, {PointSize[0.02], GrayLevel[0], 
            Point[{0, 0, 0}], Point[{1, 0, 0}]}, {Thickness[0.01], 
            GrayLevel[0], Line[{a, b}]}, {Thickness[0.005], 
            Line[{{0, 0, 0}, {1, 0, 0}}]}, {EdgeForm[], GrayLevel[0.6], 
            Thickness[0.03], 
            Arrow3D[0.8*{0.5, 0.0, 0} + 0.2*(a + b)/2. , 
              0.4*{0.5, 0.0, 0} + 0.6*(a + b)/2. , 
              HeadLength -> 0.2, HeadWidth -> 1]}, {Text[bfa, 
              a, {1.2, 1.2}], Text[bfb, b, {-1.2, -1.2}], 
            Text[bfx, x, {1.2, -1.2}], Text[itt, {t, 0, 0}, {0, 1.5}], 
            Text["0", {0, 0, 0}, {0, 1.5}], 
            Text["1", {1, 0, 0}, {0, 1.5}]}}, 
        ViewPoint -> {0, 0, 4}, ViewVertical -> {0, 1, 0}, 
        SphericalRegion -> True, 
        PlotRange -> {{- .2, 1.3}, {-0.3, 1.4}, {-0.1, 
              0.1}}, Boxed -> False, Axes -> False, 
        Ticks -> Automatic, Lighting -> False, 
        AxesLabel -> {"x", "y", "z"}, 
        TextStyle -> newTextStyle]

Show[
      chap3fig1 //. 
        Join[independentVariables, dependentVariables]]

SetDirectory["/Users/martin/Desktop/mmasources"]

WriteLiveForm["chap3fig1.m", chap3fig1]

WriteHtmlPage["chap3fig1.html", "<FONT SIZE=+2><B>Figure 3.1</B> \
[Farin 2002, page 26]</FONT>",  "chap3fig1.m", 800, 500, 
      independentVariables,  
      dependentVariables, "<PARAM NAME=BGCOLOR VALUE=#FFFFFF>\n<PARAM NAME=\
\"MOUSE_DRAG_ACTION\" VALUE=\"NONE\">\n<PARAM NAME=\"POINT_EDGE_COLOR\" \
VALUE=#000000>\n"]

Figure 3.2, page 27

Input: coordinates d, c, points ld, lc

Interaction: 
— free movement of ld, lc 
— movement of d and c on x axis

Output: 
— lines, arrows, mapping arrow

SetDirectory["/Users/martin/Desktop/mmasources"]

<< Arrow3D`

ClearAll[c, d]

defineVector[{"ld", "lc", "temp1", "temp2"}]

independentVariables = 
      Flatten[{independentVariablesForVector["ld", {0.6, 1. , 0}], 
          independentVariablesForVector["lc", {-0.3, 0.5, 0}], 
          c -> 0, d -> 1, cOld -> 0, 
          dOld -> 1}]

\(dependentVariables = 
      Flatten[{cIsNew -> If[c ≠ cOld, True, False], 
          dIsNew -> 
            If[d ≠ dOld, True, 
              False], 
dependentVariablesForVectorProlog["lc"], dependentVariablesForVectorProlog["ld"], 
          dependentVariablesForVector["temp1", 
            ld + \((lc - ld)\)*\((d - c)\)/\((d - cOld)\)], 
          dependentVariablesForVector["temp2", 
            lc + \((ld - lc)\)*\((c - d)\)/\((c - dOld)\)], 
          dependentVariablesForReassignmentOfVector["lc", "c", 
            temp1], dependentVariablesForReassignmentOfVector["ld", "d", temp2], cOld -> c, dOld -> d, 
          dependentVariablesForVectorEpilog["lc"], 
          dependentVariablesForVectorEpilog["ld"]}]\)

chap3fig2 := 
      Graphics3D[{{PointSize[0.04], RGBColor[0. , 1, 0. ], 
            Point[lc + {0, 0, 0.01}], Point[ld + {0, 0, 0.01}], 
            Point[{c, 0, 0.01}], Point[{d, 0, 0.01}]}, {Thickness[0.01], 
            GrayLevel[0], EdgeForm[], 
            Arrow3D[lc, ld, HeadLength -> 0.2], 
            Arrow3D[{c, 0, 0}, {d, 0, 0}, 
              HeadLength -> 0.2]}, {Thickness[0.005], 
            Line[{{-0.3, 0, 0}, {1.3, 0, 0}}], 
            Line[{lc + 10*(lc - ld)/Sqrt[(lc - ld) . (lc - ld)], 
                ld + 10*(ld - lc)/
                      Sqrt[(lc - ld) . (lc - ld)]}]}, {EdgeForm[], 
            GrayLevel[0.6], Thickness[0.03], 
            Arrow3D[0.8*{0.5, 0.0, 0} + 0.2*(ld + lc)/2. , 
              0.4*{0.5, 0.0, 0} + 0.6*(ld + lc)/2. , 
              HeadLength -> 0.2, HeadWidth -> 1]}, {Text[bfli[itc], 
              lc, {1.2, -1.2}], Text[bfli[itd], ld, {0, -1.2}], 
            Text[bfli[
                StyleForm[OverVector[itv], 
                  ScriptBaselineShifts -> {0.6, 0.9, 0.9, 
                      0.9}]], (lc + ld)/2, {1.1, -1.1}], 
            Text[StyleForm[OverVector[itv], 
                ScriptBaselineShifts -> {0.6, 0.9, 0.9, 
                    0.9}], {(c + d)/2, 0, 0}, {0, 1.5}], 
            Text[itc, {c, 0, 0}, {0, 1.5}], Text[itd, {d, 0, 0}, {0, 1.5}]}}, 
        ViewPoint -> {0, 0, 4}, ViewVertical -> {0, 1, 0}, 
        SphericalRegion -> True, 
        PlotRange -> {{- .5, 1.3}, {-0.3, 1.4}, {-0.1, 
              0.1}}, Boxed -> False, Axes -> False, 
        Ticks -> Automatic, Lighting -> False, 
        AxesLabel -> {"x", "y", "z"}, 
        TextStyle -> newTextStyle]

Show[
      chap3fig2 //. 
        Join[independentVariables, dependentVariables]]

SetDirectory["/Users/martin/Desktop/mmasources"]

WriteLiveForm["chap3fig2.m", chap3fig2]

WriteHtmlPage["chap3fig2.html", "<FONT SIZE=+2><B>Figure 3.2</B> \
[Farin 2002, page 27]</FONT>",  "chap3fig2.m", 800, 500, 
      independentVariables,  
      dependentVariables, "<PARAM NAME=BGCOLOR VALUE=#FFFFFF>\n<PARAM NAME=\
\"MOUSE_DRAG_ACTION\" VALUE=\"NONE\">\n<PARAM NAME=\"POINT_EDGE_COLOR\" \
VALUE=#000000>\n"]

Figure 3.3, page 30

Input: points b0, b1, b2, b3, coordinate t

Interaction: 
— free movement of b0, b1, b2, b3 in 2D
— movement of t on axis between 0 and 1

Output: 
— lines, polynomial interpolation,, mapping arrow

SetDirectory["/Users/martin/Desktop/mmasources"]

<< Arrow3D`

ClearAll[b, t]

defineVector[{"b0", "b1", "b2", "b3", "bt"}]

t0 = 0; t1 = 0.33; t2 = 0.66; t3 = 1;

blag[t_] := 
      b0*(t - t1)*(t - 
              t2)*(t - 
                t3)/((t0 - t1)*(t0 - t2)*(t0 - t3)) + 
        b1*(t - t0)*(t - 
              t2)*(t - 
                t3)/((t1 - t0)*(t1 - t2)*(t1 - t3)) + 
        b2*(t - t0)*(t - 
              t1)*(t - 
                t3)/((t2 - t0)*(t2 - t1)*(t2 - t3)) + 
        b3*(t - t0)*(t - 
              t1)*(t - 
                t2)/((t3 - t0)*(t3 - t1)*(t3 - 
                    t2));

independentVariables = 
      Flatten[{independentVariablesForVector["b0", {-0.2, -0.1, 
              0}], independentVariablesForVector["b1", {0.4, 0.7, 0}], 
          independentVariablesForVector["b2", {0.8, 0.1, 0}], 
          independentVariablesForVector["b3", {0.6, 0.1, 0}]}]

dependentVariables = Flatten[{}]

iMax = 128;

curvpoints = Table[blag[1.2*i/iMax - 0.1], {i, 0, iMax}];

chap3fig3 := 
      Graphics3D[{{PointSize[0.04], RGBColor[0. , 1, 0. ], 
            Point[b0 + {0, 0, 0.01}], Point[b1 + {0, 0, 0.01}], 
            Point[b2 + {0, 0, 0.01}], 
            Point[b3 + {0, 0, 0.01}]}, {Thickness[0.01], GrayLevel[0], 
            Line[curvpoints], Thickness[0.005], 
            Line[{b0, b1, b2, b3}]}, {Thickness[0.01], GrayLevel[0.6], 
            Line[{{-1, 0, -0.01}, {2, 0, -0.01}}]}, {Text[
              bfbi["0"], b0, {-1.1, 1.2}], 
            Text[bfbi["1"], b1, {-1.1, -1.2}], 
            Text[bfbi["2"], b2, {-1.1, -1.2}], 
            Text[bfbi["3"], b3, {1.1, 1.2}], GrayLevel[0.6], 
            Text["line/plane", {2, 0, -0.01}, {1. , -1.1}]}}, 
        ViewPoint -> {0, 0, 4}, ViewVertical -> {0, 1, 0}, 
        SphericalRegion -> True, 
        PlotRange -> {{- .2, 1.2}, {-0.5, 1. }, {-0.1, 
              0.1}}, Boxed -> False, Axes -> False, 
        Ticks -> Automatic, Lighting -> False, 
        AxesLabel -> {"x", "y", "z"}, 
        TextStyle -> newTextStyle]

Show[
      chap3fig3 //. 
        Join[independentVariables, dependentVariables]]

SetDirectory["/Users/martin/Desktop/mmasources"]

WriteLiveForm["chap3fig3.m", chap3fig3]

WriteHtmlPage["chap3fig3.html", "<FONT SIZE=+2><B>Figure 3.3</B> \
[Farin 2002, page 30]</FONT>",  "chap3fig3.m", 800, 500, 
      independentVariables,  
      dependentVariables, "<PARAM NAME=BGCOLOR VALUE=#FFFFFF>\n<PARAM NAME=\
\"MOUSE_DRAG_ACTION\" VALUE=\"NONE\">\n<PARAM NAME=\"POINT_EDGE_COLOR\" \
VALUE=#000000>\n"]

Figure 3.4, page 31

Input: points b0, b1, b2, coordinates s, t

Interaction: 
— free movement of b0, b1, b2
— movement of s and t on axis between 0 and 1

Output: 
— lines, interpolated points, mapping arrow

SetDirectory["/Users/martin/Desktop/mmasources"]

<< Arrow3D`

ClearAll[b, s, t]

\(defineVector[{"b0", "b1", "b2", "bs0", "bs1", "b0t", "b1t", "bst"}]\)

b[s_, 
        t_] := (1 - t)*(1 - s)*
          b0 + ((1 - t)*s + t*(1 - s))*b1 + s*t*b2

independentVariables = 
      Flatten[{independentVariablesForVector["b0", {-0.7, 0.5, 0}], 
          independentVariablesForVector["b1", {0.6, 1.5, 0}], 
          independentVariablesForVector["b2", {1.6, 0.7, 0}], 
          s -> 0.3, t -> 0.6}]

dependentVariables = 
      Flatten[{t -> If[t < 0, 0, If[t > 1, 1, t]], 
          s -> If[s < 0, 0, If[s > 1, 1, s]], 
          dependentVariablesForVector["bs0", b[s, 0]], 
          dependentVariablesForVector["b0t", b[0, t]], 
          dependentVariablesForVector["bs1", b[s, 1]], 
          dependentVariablesForVector["b1t", b[1, t]], 
          dependentVariablesForVector["bst", b[s, t]]}]

ytaxis = -0.4;

chap3fig4 := 
      Graphics3D[{{PointSize[0.04], RGBColor[0. , 1, 0. ], 
            Point[b0 + {0, 0, 0.01}], Point[b1 + {0, 0, 0.01}], 
            Point[b2 + {0, 0, 0.01}], Point[{s, 0, 0.01}], 
            Point[{t, ytaxis, 0.01}], GrayLevel[0], 
            Point[bst + {0, 0, 0.01}], Point[bs0 + {0, 0, 0.01}], 
            Point[b0t + {0, 0, 0.01}], Point[bs1 + {0, 0, 0.01}], 
            Point[b1t + {0, 0, 0.01}]}, {Thickness[0.01], GrayLevel[0], 
            Line[{b0, bs0, b0t, b1, bs1, b1t, b2}], Line[{bs0, bst, bs1}], 
            Line[{b0t, bst, b1t}]}, 
{PointSize[0.02], 
            GrayLevel[0], Point[{0, 0, 0}], Point[{1, 0, 0}], 
            Point[{0, ytaxis, 0}], Point[{1, ytaxis, 0}]}, {Thickness[0.005], 
            GrayLevel[0], Line[{{0, 0, 0}, {1, 0, 0}}], 
            Line[{{0, ytaxis, 0}, {1, ytaxis, 0}}]}, {EdgeForm[], 
            GrayLevel[0.6], Thickness[0.03], 
            Arrow3D[0.8*{0.5, 0.0, 0} + 0.2*bst, 0.4*{0.5, 0.0, 0} + 0.6*bst, 
              HeadLength -> 0.2, HeadWidth -> 1]}, {Text[
              bfbi["0"], b0, {1.2, 1.2}], 
            Text[bfbi["1"], b1, {1.2, -1.2}], 
            Text[bfbi["2"], b2, {-1.2, 1.2}], 
            Text[bfb2[its, itt], bst, {0, 1.5}], 
            Text[bfb2["0", itt], b0t, {1.1, -1.1}], 
            Text[bfb2["1", itt], b1t, {-1.1, -1.1}], 
            Text[bfb2[its, "0"], bs0, {1.1, -1.1}], 
            Text[bfb2[its, "1"], bs1, {-1.1, -1.1}], 
            Text[its, {s, 0, 0}, {0, 1.5}], 
            Text["0", {0, 0, 0}, {0, 1.5}], 
            Text["1", {1, 0, 0}, {0, 1.5}], 
            Text[itt, {t, ytaxis, 0}, {0, 1.5}], 
            Text["0", {0, ytaxis, 0}, {0, 1.5}], 
            Text["1", {1, ytaxis, 0}, {0, 1.5}]}}, 
        ViewPoint -> {0, 0, 4}, ViewVertical -> {0, 1, 0}, 
        SphericalRegion -> True, 
        PlotRange -> {{- .2, 1.2}, {-0.5, 1.7}, {-0.1, 
              0.1}}, Boxed -> False, Axes -> False, 
        Ticks -> Automatic, Lighting -> False, 
        AxesLabel -> {"x", "y", "z"}, 
        TextStyle -> newTextStyle]

Show[
      chap3fig4 //. 
        Join[independentVariables, dependentVariables]]

SetDirectory["/Users/martin/Desktop/mmasources"]

WriteLiveForm["chap3fig4.m", chap3fig4]

WriteHtmlPage["chap3fig4.html", "<FONT SIZE=+2><B>Figure 3.4</B> \
[Farin 2002, page 31]</FONT>",  "chap3fig4.m", 800, 500, 
      independentVariables,  
      dependentVariables, "<PARAM NAME=BGCOLOR VALUE=#FFFFFF>\n<PARAM NAME=\
\"MOUSE_DRAG_ACTION\" VALUE=\"NONE\">\n<PARAM NAME=\"POINT_EDGE_COLOR\" \
VALUE=#000000>\n"]

Figure 3.5, page 35

Input: points a, b, c, p, u  (ux: u, uy: v, uz: w)

Interaction: 
— free movement of a, b, c
— free movement of p, update when u is changed
— movement of ux and uy on axis between 0 and 1: update when p is changed

Output:
— third coordinate uz 
— lines, axes,, mapping arrow

SetDirectory["/Users/martin/Desktop/mmasources"]

<< Arrow3D`

defineVector[{"a", "b", "c", "p", "u"}]

pbar[ux_, uy_, uz_] := 
      ux * a + uy*b + uz*c; 
area[a_List, b_List, c_List] := 
      Det[{{a[[1]], b[[1]], 
            c[[1]]}, {a[[2]], b[[2]], 
            c[[2]]}, {1, 1, 1}}]

independentVariables = 
      Flatten[{independentVariablesForVector["a", {3.2, -1.2, 0}], 
          independentVariablesForVector["b", {2.0, 0.2, 0}], 
          independentVariablesForVector["c", {1.6, -1.2, 0}], 
          independentVariablesForVector["p", {2. , -0.7, 0}], 
          independentVariablesForVector["u", {0.25, 0.25, 
              0.5}]}]

dependentVariables = 
      Flatten[{dependentVariablesForVectorProlog["a"], 
          dependentVariablesForVectorProlog["b"], 
          dependentVariablesForVectorProlog["c"], 
          dependentVariablesForVectorProlog["p"], 
          dependentVariablesForVectorProlog["u"], 
          uz -> If[! uIsNew, uz, 1 - ux - uy], 
          dependentVariablesForReassignmentOfVector["u", "p", {area[
                  p, b, c]/area[a, b, c], area[a, p, c]/area[a, b, c], 
              area[a, b, p]/
                area[a, b, 
                  c]}], 
dependentVariablesForVector["p\
", pbar[ux, uy, 
              uz]], 
dependentVariablesForVectorEpilog["a\
"], dependentVariablesForVectorEpilog["b"], 
          dependentVariablesForVectorEpilog["c"], 
          dependentVariablesForVectorEpilog["p"], 
          dependentVariablesForVectorEpilog["u"]}]

yvaxis = -0.5; ; ywaxis = -1.0;

chap3fig5 := 
      Graphics3D[{{PointSize[0.04], RGBColor[0. , 1, 0. ], 
            Point[a + {0, 0, 0.01}], Point[b + {0, 0, 0.01}], 
            Point[c + {0, 0, 0.01}], Point[p + {0, 0, 0.01}], 
            Point[{ux, 0, 0.01}], Point[{uy, yvaxis, 0.01}], GrayLevel[0], 
            Point[{1. *uz, ywaxis, 0.01}]}, {Thickness[0.01], GrayLevel[0], 
            Line[{a, b, c, a}]}, {Thickness[0.005], GrayLevel[0], 
            Line[{a, p, c}], 
            Line[{b, p}]}, 
{PointSize[0.02], GrayLevel[0], 
            Point[{0, 0, 0}], Point[{1, 0, 0}], Point[{0, yvaxis, 0}], 
            Point[{1, yvaxis, 0}], Point[{0, ywaxis, 0}], 
            Point[{1, ywaxis, 0}]}, {Thickness[0.005], GrayLevel[0], 
            Line[{{0, 0, 0}, {1, 0, 0}}], 
            Line[{{0, yvaxis, 0}, {1, yvaxis, 0}}], 
            Line[{{0, ywaxis, 0}, {1, ywaxis, 0}}]}, {EdgeForm[], 
            GrayLevel[0.6], Thickness[0.03], 
            Arrow3D[0.8*{1. , yvaxis, 0} + 0.2*p, 
              0.5*{1. , yvaxis, 0} + 0.5*p, HeadLength -> 0.2, 
              HeadWidth -> 1]}, {Text[bfa, a, {-1.2, 1.2}], 
            Text[bfb, b, {1.2, -1.2}], Text[bfc, c, {1.2, 1.2}], 
            Text[bfp, p, {-1.2, -1.2}], 
            Text[itu, {ux, 0, 0}, {0, 1.5}], 
            Text["0", {0, 0, 0}, {0, 1.5}], 
            Text["1", {1, 0, 0}, {0, 1.5}], 
            Text[itv, {uy, yvaxis, 0}, {0, 1.5}], 
            Text["0", {0, yvaxis, 0}, {0, 1.5}], 
            Text["1", {1, yvaxis, 0}, {0, 1.5}], 
            Text[itw, {uz, ywaxis, 0}, {0, 1.5}], 
            Text["0", {0, ywaxis, 0}, {0, 1.5}], 
            Text["1", {1, ywaxis, 0}, {0, 1.5}]}}, 
        ViewPoint -> {0, 0, 4}, ViewVertical -> {0, 1, 0}, 
        SphericalRegion -> True, 
        PlotRange -> {{0.2, 3. }, {-1.2, 0.2}, {-0.1, 0.1}}, 
        Boxed -> False, Axes -> False, Ticks -> Automatic, 
        Lighting -> False, 
        AxesLabel -> {"x", "y", "z"}, 
        TextStyle -> newTextStyle]

Show[
      chap3fig5 //. 
        Join[independentVariables, dependentVariables]]

SetDirectory["/Users/martin/Desktop/mmasources"]

WriteLiveForm["chap3fig5.m", chap3fig5]

WriteHtmlPage["chap3fig5.html", "<FONT SIZE=+2><B>variation of \
Figure 3.5</B> [Farin 2002, page 35]</FONT>",  "chap3fig5.m", 800, 
      500, independentVariables,  
      dependentVariables, "<PARAM NAME=BGCOLOR VALUE=#FFFFFF>\n<PARAM NAME=\
\"MOUSE_DRAG_ACTION\" VALUE=\"NONE\">\n<PARAM NAME=\"POINT_EDGE_COLOR\" \
VALUE=#000000>\n"]

Figures for Chapter 4

Figure 4.1, page 44

Input: points b0, b1, b2, coordinates s, t

Interaction: 
— free movement of b0, b1, b2
— movement t on axis between 0 and 1

Output: 
— lines, interpolated points, mapping arrow

SetDirectory["/Users/martin/Desktop/mmasources"]

<< Arrow3D`

ClearAll[b, t]

\(defineVector[{"b0", "b1", "b2", "b01", "b11", "b02"}]\)

b[s_, 
        t_] := (1 - t)*(1 - s)*
          b0 + ((1 - t)*s + t*(1 - s))*b1 + s*t*b2

iMax = 64; 
bpoints = Table[b[i/iMax, i/iMax], {i, 0, iMax}];

independentVariables = 
      Flatten[{independentVariablesForVector["b0", {-0.4, 0.5, 0}], 
          independentVariablesForVector["b1", {0.6, 1.5, 0}], 
          independentVariablesForVector["b2", {1.3, 0.7, 0}], 
          t -> 0.5}]

dependentVariables = 
      Flatten[{t -> If[t < 0, 0, If[t > 1, 1, t]], 
          dependentVariablesForVector["b01", b[0, t]], 
          dependentVariablesForVector["b11", b[t, 1]], 
          dependentVariablesForVector["b02", b[t, t]]}]

chap4fig1 := 
      Graphics3D[{{PointSize[0.04], RGBColor[0. , 1, 0. ], 
            Point[b0 + {0, 0, 0.01}], Point[b1 + {0, 0, 0.01}], 
            Point[b2 + {0, 0, 0.01}], Point[{t, 0, 0.01}], GrayLevel[0], 
            Point[b01 + {0, 0, 0.01}], Point[b11 + {0, 0, 0.01}], 
            Point[b02 + {0, 0, 0.01}]}, {Thickness[0.005], GrayLevel[0], 
            Line[{b0, b01, b1, b11, b2}], 
            Line[{b01, b02, b11}]}, 
{PointSize[0.02], 
            GrayLevel[0], Point[{0, 0, 0}], 
            Point[{1, 0, 0}]}, {Thickness[0.005], GrayLevel[0], 
            Line[{{0, 0, 0}, {1, 0, 0}}]}, {Thickness[0.01], GrayLevel[0], 
            Line[bpoints]}, {EdgeForm[], GrayLevel[0.6], Thickness[0.03], 
            Arrow3D[0.8*{0.5, 0.0, -0.01} + 0.2*b02, 
              0.4*{0.5, 0.0, -0.01} + 0.6*b02, HeadLength -> 0.2, 
              HeadWidth -> 1]}, {Text[bfbi["0"], b0, {1.3, 1.3}], 
            Text[bfbi["1"], b1, {1.3, -1.3}], 
            Text[bfbi["2"], b2, {-1.3, 1.3}], 
            Text[bfbir["0", "1"], b01, {1.3, -1.3}], 
            Text[bfbir["1", "1"], b11, {-1.3, -1.3}], 
            Text[bfbir["0", "2"], b02, {0, 1.3}], 
            Text[itt, {t, 0, 0}, {0, 1.3}], 
            Text["0", {0, 0, 0}, {0, 1.3}], 
            Text["1", {1, 0, 0}, {0, 1.3}]}}, 
        ViewPoint -> {0, 0, 4}, ViewVertical -> {0, 1, 0}, 
        SphericalRegion -> True, 
        PlotRange -> {{- .5, 1.5}, {-0.5, 1.5}, {-0.1, 
              0.1}}, Boxed -> False, Axes -> False, 
        Ticks -> Automatic, Lighting -> False, 
        AxesLabel -> {"x", "y", "z"}, 
        TextStyle -> newTextStyle]

Show[
      chap4fig1 //. 
        Join[independentVariables, dependentVariables]]

SetDirectory["/Users/martin/Desktop/mmasources"]

WriteLiveForm["chap4fig1.m", chap4fig1]

WriteHtmlPage["chap4fig1.html", "<FONT SIZE=+2><B>Figure 4.1</B> \
[Farin 2002, page 44]</FONT>",  "chap4fig1.m", 800, 500, 
      independentVariables,  
      dependentVariables, "<PARAM NAME=BGCOLOR VALUE=#FFFFFF>\n<PARAM NAME=\
\"MOUSE_DRAG_ACTION\" VALUE=\"NONE\">\n<PARAM NAME=\"POINT_EDGE_COLOR\" \
VALUE=#000000>\n"]

Figure 4.2, page 44

Input: points b0, b1, b2, b3, coordinates s, t

Interaction: 
— free movement of b0, b1, b2, b3
— movement t on axis between 0 and 1

Output: 
— lines, interpolated points, mapping arrow

SetDirectory["/Users/martin/Desktop/mmasources"]

<< Arrow3D`

ClearAll[b, t]

defineVector[{"b0", "b1", "b2", "b3", "b01", "b11\
", "b21", "b02", "b12", "b03"}]

bernstein[i_, n_, t_] := 
      Binomial[n, i] t^i (1 - t)^(n - i)

b[t_] := 
      bernstein[0, 3, t]*b0 + bernstein[1, 3, t]*b1 + bernstein[2, 3, t]*b2 + 
        bernstein[3, 3, t]*b3;

iMax = 64; 
bpoints = 
      Table[b[i/iMax], {i, 0 + 0.0000001, iMax + 0.00001}];

independentVariables = 
      Flatten[{independentVariablesForVector["b0", {-0.4, 0.3, 0}], 
          independentVariablesForVector["b1", {0.2, 1.5, 0}], 
          independentVariablesForVector["b2", {1.3, 0.5, 0}], 
          independentVariablesForVector["b3", {1.8, 1.5, 0}], 
          t -> 0.35}]

dependentVariables = 
      Flatten[{t -> If[t < 0, 0, If[t > 1, 1, t]], 
          dependentVariablesForVector["b01", 
            bernstein[0, 1, t]*b0 + bernstein[1, 1, t]*b1], 
          dependentVariablesForVector["b11", 
            bernstein[0, 1, t]*b1 + bernstein[1, 1, t]*b2], 
          dependentVariablesForVector["b21", 
            bernstein[0, 1, t]*b2 + bernstein[1, 1, t]*b3], 
          dependentVariablesForVector["b02", 
            bernstein[0, 1, t]*b01 + bernstein[1, 1, t]*b11], 
          dependentVariablesForVector["b12", 
            bernstein[0, 1, t]*b11 + bernstein[1, 1, t]*b21], 
          dependentVariablesForVector["b03", 
            bernstein[0, 1, t]*b02 + bernstein[1, 1, t]*b12]}]

chap4fig2 := 
      Graphics3D[{{PointSize[0.04], RGBColor[0. , 1, 0. ], 
            Point[b0 + {0, 0, 0.01}], Point[b1 + {0, 0, 0.01}], 
            Point[b2 + {0, 0, 0.01}], Point[b3 + {0, 0, 0.01}], 
            Point[{t, 0, 0.01}], GrayLevel[0], Point[b01 + {0, 0, 0.01}], 
            Point[b11 + {0, 0, 0.01}], Point[b21 + {0, 0, 0.01}], 
            Point[b02 + {0, 0, 0.01}], Point[b12 + {0, 0, 0.01}], 
            Point[b03 + {0, 0, 0.01}]}, {Thickness[0.005], GrayLevel[0], 
            Line[{b0, b01, b1, b11, b2, b21, b3}], 
            Line[{b01, b02, b11, b12, b21}], 
            Line[{b02, b03, b12}]}, 
{PointSize[0.02], 
            GrayLevel[0], Point[{0, 0, 0}], 
            Point[{1, 0, 0}]}, {Thickness[0.005], GrayLevel[0], 
            Line[{{0, 0, 0}, {1, 0, 0}}]}, {Thickness[0.01], GrayLevel[0], 
            Line[bpoints]}, {EdgeForm[], GrayLevel[0.6], Thickness[0.03], 
            Arrow3D[0.8*{0.5, 0.0, -0.01} + 0.2*b03, 
              0.4*{0.5, 0.0, -0.01} + 0.6*b03, HeadLength -> 0.2, 
              HeadWidth -> 1]}, {Text[bfbi["0"], b0, {1.3, 1.3}], 
            Text[bfbi["1"], b1, {1.3, -1.3}], 
            Text[bfbi["2"], b2, {-1.3, 1.3}], 
            Text[bfbi["3"], b3, {-1.3, -1.3}], 
            Text[bfbir["0", "1"], b01, {1.3, -1.3}], 
            Text[bfbir["1", "1"], b11, {-1. , -1.3}], 
            Text[bfbir["2", "1"], b21, {-1.3, 1.3}], 
            Text[bfbir["0", "2"], b02, {-0.5, 1.3}], 
            Text[bfbir["1", "2"], b12, {-1.3, -1.3}], 
            Text[bfbir["0", "3"], b03, {-1.1, 1.3}], 
            Text[itt, {t, 0, 0}, {0, 1.3}], 
            Text["0", {0, 0, 0}, {0, 1.3}], 
            Text["1", {1, 0, 0}, {0, 1.3}]}}, 
        ViewPoint -> {0, 0, 4}, ViewVertical -> {0, 1, 0}, 
        SphericalRegion -> True, 
        PlotRange -> {{- .5, 1.5}, {-0.5, 1.5}, {-0.1, 
              0.1}}, Boxed -> False, Axes -> False, 
        Ticks -> Automatic, Lighting -> False, 
        AxesLabel -> {"x", "y", "z"}, 
        TextStyle -> newTextStyle]

Show[
      chap4fig2 //. 
        Join[independentVariables, dependentVariables]]

SetDirectory["/Users/martin/Desktop/mmasources"]

WriteLiveForm["chap4fig2.m", chap4fig2]

WriteHtmlPage["chap4fig2.html", "<FONT SIZE=+2><B>Figure 4.2</B> \
[Farin 2002, page 46]</FONT>",  "chap4fig2.m", 800, 500, 
      independentVariables,  
      dependentVariables, "<PARAM NAME=BGCOLOR VALUE=#FFFFFF>\n<PARAM NAME=\
\"MOUSE_DRAG_ACTION\" VALUE=\"NONE\">\n<PARAM NAME=\"POINT_EDGE_COLOR\" \
VALUE=#000000>\n"]

Figure 4.4, page 50

Input: points b0, b1, b2, b3,b4, b5, b6, b7

Interaction: 
— free movement of b0, b1, b2, b3, b4, b5, b6, b7

Output: 
— lines, polygon

SetDirectory["/Users/martin/Desktop/mmasources"]

ClearAll[b, t]

\(defineVector[{"b0", "b1", "b2", "b3", "b4", "b5", "b6", "b7"}]\)

bernstein[i_, n_, t_] := 
      Binomial[n, i] t^i (1 - t)^(n - i)

b[t_] := 
      Sum[bernstein[i, 7, t]*Symbol["b" <> ToString[i]], {i, 0, 
          7}];

iMax = 128; 
bpoints = 
      Table[b[i/iMax], {i, 0 + 0.0000001, iMax + 0.00001}];

independentVariables = 
      Flatten[{independentVariablesForVector["b0", {0.4, 0.2, 0}], 
          independentVariablesForVector["b1", {0.1, 0.0, 0}], 
          independentVariablesForVector["b2", {0.0, 0.3, 0}], 
          independentVariablesForVector["b3", {0.1, 0.7, 0}], 
          independentVariablesForVector["b4", {0.5, 0.8, 0}], 
          independentVariablesForVector["b5", {0.6, 0.4, 0}], 
          independentVariablesForVector["b6", {0.7, 0.8, 0}], 
          independentVariablesForVector["b7", {1. , 0.5, 0}]}]

dependentVariables = Flatten[{}]

chap4fig4 := 
      Graphics3D[{{PointSize[0.04], RGBColor[0. , 1, 0. ], 
            Point[b0 + {0, 0, 0.01}], Point[b1 + {0, 0, 0.01}], 
            Point[b2 + {0, 0, 0.01}], Point[b3 + {0, 0, 0.01}], 
            Point[b4 + {0, 0, 0.01}], Point[b5 + {0, 0, 0.01}], 
            Point[b6 + {0, 0, 0.01}], 
            Point[b7 + {0, 0, 0.01}]}, {Thickness[0.01], GrayLevel[0], 
            Line[bpoints]}, {Thickness[0.005], GrayLevel[0], 
            Line[{b0, b1, b2, b3, b4, b5, b6, b7}]}}, 
        ViewPoint -> {0, 0, 4}, ViewVertical -> {0, 1, 0}, 
        SphericalRegion -> True, 
        PlotRange -> {{0, 1. }, {-0. , 1. }, {-0.1, 0.1}}, 
        Boxed -> False, Axes -> False, Ticks -> Automatic, 
        Lighting -> False, 
        AxesLabel -> {"x", "y", "z"}, 
        TextStyle -> newTextStyle]

Show[
      chap4fig4 //. 
        Join[independentVariables, dependentVariables]]

SetDirectory["/Users/martin/Desktop/mmasources"]

WriteLiveForm["chap4fig4.m", chap4fig4]

WriteHtmlPage["chap4fig4.html", "<FONT SIZE=+2><B>Figure 4.4</B> \
[Farin 2002, page 50]</FONT>",  "chap4fig4.m", 800, 500, 
      independentVariables,  
      dependentVariables, "<PARAM NAME=BGCOLOR VALUE=#FFFFFF>\n<PARAM NAME=\
\"MOUSE_DRAG_ACTION\" VALUE=\"NONE\">\n<PARAM NAME=\"POINT_EDGE_COLOR\" \
VALUE=#000000>\n"]

Figure 4.5, page 52

Input: points b0, b1, b2, b3, coordinates a, b

Interaction: 
— free movement of b0, b1, b2, b3
— movement of a and b on axis between 0 and 1

Output: 
— lines, interpolated points, mapping arrow

SetDirectory["/Users/martin/Desktop/mmasources"]

<< Arrow3D`

ClearAll[a, b, r, s, t]

defineVector[{"b0", "b1", "b2", "b3"}]

b[r_, s_, t_] := 
      b0*(1 - r)*(1 - s)*(1 - t) + 
        b1*((1 - r)*(1 - s)*t + (1 - r)*s*(1 - t) + 
              r*(1 - s)*(1 - t)) + 
        b2*((1 - r)*s*t + r*s*(1 - t) + r*(1 - s)*t) + 
        b3*r*s*t

iMax = 64; 
cpoints = 
      Table[b[a + (b - a)*i/iMax, a + (b - a)*i/iMax, 
          a + (b - a)*i/iMax], {i, 0 + 0.0000001, 
          iMax + 0.00001}]; 
iMax = 8; 
apoints = 
      Table[b[Min[a, b]*i/iMax, Min[a, b]*i/iMax, Min[a, b]*i/iMax], {i, 
          0 + 0.0000001, iMax + 0.0001}]; 
bpoints = 
      Table[b[Max[a, b] + (1 - Max[a, b])*i/iMax, 
          Max[a, b] + (1 - Max[a, b])*i/iMax, 
          Max[a, b] + (1 - Max[a, b])*i/iMax], {i, 0 + 0.0000001, 
          iMax + 0.0001}];

independentVariables = 
      Flatten[{independentVariablesForVector["b0", {-0.1, 0.4, 0}], 
          independentVariablesForVector["b1", {0.6, 0.4, 0}], 
          independentVariablesForVector["b2", {0.6, 1.5, 0}], 
          independentVariablesForVector["b3", {1.1, 1.5, 0}], 
          a -> 0.2, b -> 0.8}]

dependentVariables = Flatten[{}]

chap4fig5 := 
      Graphics3D[{{PointSize[0.04], RGBColor[0. , 1, 0. ], 
            Point[b0 + {0, 0, 0.01}], Point[b1 + {0, 0, 0.01}], 
            Point[b2 + {0, 0, 0.01}], Point[b3 + {0, 0, 0.01}], 
            Point[{a, 0, 0.01}], Point[{b, 0, 0.01}], GrayLevel[0], 
            Point[b[a, a, a] + {0, 0, 0.01}], 
            Point[b[a, a, b] + {0, 0, 0.01}], 
            Point[b[a, b, b] + {0, 0, 0.01}], 
            Point[b[b, b, b] + {0, 0, 0.01}]}, {Thickness[0.005], 
            GrayLevel[0], Line[{b0, b1, b2, b3}], 
            Line[{b[a, a, a], b[a, a, b], b[a, b, b], 
                b[b, b, b]}]}, 
{PointSize[0.02], 
            GrayLevel[0], Point[{0, 0, 0}], 
            Point[{1, 0, 0}]}, {Thickness[0.005], GrayLevel[0], 
            Line[{{0, 0, 0}, {1, 0, 0}}]}, {Thickness[0.01], GrayLevel[0], 
            Line[cpoints]}, {PointSize[0.01], Map[Point, apoints], 
            Map[Point, bpoints]}, {Text[
              bfb3spaced["0", "0",  "0"], b0, {1.1, 1.3}], 
            Text[bfb3spaced["0",  "0",  "1"], 
              b1, {-1.1, 1.3}], 
            Text[bfb3spaced["1",  "1",  "0"], 
              b2, {1.1, -1.3}], 
            Text[bfb3spaced["b",  "b",  "b"], 
              b[b, b, b], {-1.1, 1.3}], 
            Text[bfb3spaced["a", "a",  "a"], 
              b[a, a, a], {1.1, -1.3}], 
            Text[bfb3spaced["a",  "a",  "b"], 
              b[a, a, b], {-1.2, 0}], 
            Text[bfb3spaced["a",  "b",  "b"], 
              b[a, b, b], {1.2, 0}], 
            Text[bfb3spaced["1",  "1",  "1"], 
              b3, {-1.1, -1.3}], Text[ita, {a, 0, 0}, {0, 1.5}], 
            Text[itb, {b, 0, 0}, {0, 1.5}], 
            Text["0", {0, 0, 0}, {0, 1.5}], 
            Text["1", {1, 0, 0}, {0, 1.5}]}}, 
        ViewPoint -> {0, 0, 4}, ViewVertical -> {0, 1, 0}, 
        SphericalRegion -> True, 
        PlotRange -> {{- .5, 1.5}, {-0.4, 1.5}, {-0.1, 
              0.1}}, Boxed -> False, Axes -> False, 
        Ticks -> Automatic, Lighting -> False, 
        AxesLabel -> {"x", "y", "z"}, 
        TextStyle -> newTextStyle]

Show[
      chap4fig5 //. 
        Join[independentVariables, dependentVariables]]

SetDirectory["/Users/martin/Desktop/mmasources"]

WriteLiveForm["chap4fig5.m", chap4fig5]

WriteHtmlPage["chap4fig5.html", "<FONT SIZE=+2><B>Figure 4.5</B> \
[Farin 2002, page 52]</FONT>",  "chap4fig5.m", 800, 500, 
      independentVariables,  
      dependentVariables, "<PARAM NAME=BGCOLOR VALUE=#FFFFFF>\n<PARAM NAME=\
\"MOUSE_DRAG_ACTION\" VALUE=\"NONE\">\n<PARAM NAME=\"POINT_EDGE_COLOR\" \
VALUE=#000000>\n"]

Figures for Chapter 5

Figure 5.1, page 59

Input: coordinate t

Interaction: 
— move t at discreet values 1/8(0, 1, 2, 3, 4, 5, 6, 8)

Output: 
— n = t/8
— coordinate system, Bernstein polynomials for n

SetDirectory["/Users/martin/Desktop/mmasources"]

<< Arrow3D`

ClearAll[i, n, b, t]

bernstein[i_, n_, t_] := 
      Binomial[n, i] t^i (1 - t)^(n - i)

defineVector[{}]

iMax = 32; 
bpoints = 
      Table[{i/iMax, 
          bernstein[j, n, (1 - 10^-20) i/iMax + 10^-30], 0}, {j, 
          0, 8}, {i, 0, iMax}];

independentVariables = Flatten[{t -> 3/8. }]

dependentVariables = 
      Flatten[{t -> Round[t*8. ]/8. , 
          t -> If[t > 1, 1, If[t < 0, 0, t]], 
          n -> Round[t*8. ]}]

ytaxis = -0.4;

chap5fig1 := 
      Graphics3D[{{PointSize[0.04], RGBColor[0. , 1, 0. ], 
            Point[{t, ytaxis, 0.01}]}, {Thickness[0.005], GrayLevel[0], 
            Line[{{0, 0, 0}, {1, 0, 0}, {1, 1, 0}, {0, 1, 0}, {0, 0, 
                  0}}]}, 
{PointSize[0.02], GrayLevel[0], 
            Point[{0, 0, 0}], Point[{1, 0, 0}], Point[{0, 1, 0}], 
            Point[{1, 1, 0}], 
            Table[Point[{i/8. , ytaxis, 0}], {i, 0, 8}]}, {Thickness[0.005], 
            GrayLevel[0], 
            Line[{{0, ytaxis, 0}, {1, ytaxis, 0}}]}, {Thickness[0.01], 
            GrayLevel[0], 
            Table[If[i > n, {}, 
                Evaluate[Line[bpoints[[i + 1]]]]], {i, 0, 
                8}]}, {Text[itn, {0, ytaxis, 0}, {2, 0}], 
            Text[itt, {0.5, 0, 0}, {0, 1.5}], 
            Text[itBinu[symbolItalic["i"], itn, 
                symbolItalic["t"]], {0. , 0.5, 0}, {1.1, 0}], 
            dummyIf[n != 
                0, {}, (Text[
                  itBin["0", "0"], {0.5, 1, 0}, {0, 2.0}])], 
            dummyIf[n ≠ 
                1, {}, {Text[
                  itBin["1", "1"], {0.75, 0.7, 0}, {1.1, -1.3}], 
                Text[itBin["0", "1"], {0.25, 0.7, 
                    0}, {-1.1, -1.3}]}], 
            dummyIf[n ≠ 
                2, {}, {Text[
                  itBin["2", "2"], {0.85, 0.7, 0}, {1.1, -1.3}], 
                Text[itBin["0", "2"], {0.15, 0.7, 
                    0}, {-1.1, -1.3}], 
                Text[itBin["1", "2"], {0.5, 0.5, 
                    0}, {0, -1.3}]}], 
            dummyIf[n ≠ 
                3, {}, {Text[
                  itBin["3", "3"], {0.9, 0.7, 0}, {1.1, -1.3}], 
                Text[itBin["0", "3"], {0.1, 0.7, 
                    0}, {-1.1, -1.3}], 
                Text[itBin["1", "3"], {0.35, 0.45, 
                    0}, {0, -1.3}], 
                Text[itBin["2", "3"], {0.65, 0.45, 
                    0}, {0, -1.3}]}], Text["0", {0, 0, 0}, {0, 1.5}], 
            Text["0", {0, 0, 0}, {1.5, 0}], 
            Text["1", {1, 0, 0}, {0, 1.5}], 
            Text["1", {0, 1, 0}, {1.5, 0}], 
            Table[Text[ToString[i], {i/8, ytaxis, 0}, {0, 1.5}], {i, 0, 
                8}]}}, ViewPoint -> {0, 0, 4}, 
        ViewVertical -> {0, 1, 0}, SphericalRegion -> True, 
        PlotRange -> {{- .1, 1.0}, {-0.5, 1.0}, {-0.1, 
              0.1}}, Boxed -> False, Axes -> False, 
        Ticks -> Automatic, Lighting -> False, 
        AxesLabel -> {"x", "y", "z"}, 
        TextStyle -> newTextStyle]

Show[chap5fig1 /. dummyIf -> If //. 
        Join[independentVariables, dependentVariables]]

SetDirectory["/Users/martin/Desktop/mmasources"]

WriteLiveForm["chap5fig1.m", 
      chap5fig1 /. dummyIf -> If]

WriteHtmlPage["chap5fig1.html", "<FONT SIZE=+2><B>Figure 5.1</B> \
[Farin 2002, page 59]</FONT>",  "chap5fig1.m", 800, 500, 
      independentVariables,  
      dependentVariables, "<PARAM NAME=BGCOLOR VALUE=#FFFFFF>\n<PARAM NAME=\
\"MOUSE_DRAG_ACTION\" VALUE=\"NONE\">\n<PARAM NAME=\"POINT_EDGE_COLOR\" \
VALUE=#000000>\n"]

Figure 5.2, page 60

Input: points b0, b1, b2, b3

Interaction: 
— free movement of b0, b1, b2, b3

Output: 
— Bezier curves of intermediate points

SetDirectory["/Users/martin/Desktop/mmasources"]

<< Arrow3D`

ClearAll[b, t]

\(defineVector[{"b0", "b1", "b2", "b3", "b4", "b01", "b11", "b21", "b31", "b02", "b12", "b22", "b03", "b13", "b04"}]\)

bernstein[i_, n_, t_] := 
      Binomial[n, i] t^i (1 - t)^(n - i)

b04t[t_] := 
      bernstein[0, 4, t]*b0 + bernstein[1, 4, t]*b1 + bernstein[2, 4, t]*b2 + 
        bernstein[3, 4, t]*b3 + bernstein[4, 4, t]*b4; 
    b03t[t_] := 
      bernstein[0, 3, t]*b0 + bernstein[1, 3, t]*b1 + bernstein[2, 3, t]*b2 + 
        bernstein[3, 3, t]*b3; 
    b13t[t_] := 
      bernstein[0, 3, t]*b1 + bernstein[1, 3, t]*b2 + bernstein[2, 3, t]*b3 + 
        bernstein[3, 3, t]*b4; 
    b02t[t_] := 
      bernstein[0, 2, t]*b0 + bernstein[1, 2, t]*b1 + 
        bernstein[2, 2, t]*b2; 
b12t[t_] := 
      bernstein[0, 2, t]*b1 + bernstein[1, 2, t]*b2 + 
        bernstein[2, 2, t]*b3; 
b22t[t_] := 
      bernstein[0, 2, t]*b2 + bernstein[1, 2, t]*b3 + 
        bernstein[2, 2, t]*b4; 
b01t[t_] := 
      bernstein[0, 1, t]*b0 + 
        bernstein[1, 1, t]*b1; 
b11t[t_] := 
      bernstein[0, 1, t]*b1 + 
        bernstein[1, 1, t]*b2; 
b21t[t_] := 
      bernstein[0, 1, t]*b2 + 
        bernstein[1, 1, t]*b3; 
b31t[t_] := bernstein[0, 1, t]*b3 + bernstein[1, 1, t]*b4;

iMax = 32; 
bpoints04 = 
      Table[{0, 0, -0.01} + 
          b04t[(1.  - 10. ^-10) i/iMax + 10. ^-20], {i, 0, 
          iMax}]; bpoints03 = 
      Table[{0, 0, -0.02} + 
          b03t[(1.  - 10. ^-10) i/iMax + 10. ^-20], {i, 0, 
          iMax}]; 
bpoints13 = 
      Table[{0, 0, -0.02} + 
          b13t[(1.  - 10. ^-10) i/iMax + 10. ^-20], {i, 0, 
          iMax}]; bpoints02 = 
      Table[{0, 0, -0.03} + 
          b02t[(1.  - 10. ^-10) i/iMax + 10. ^-20], {i, 0, 
          iMax}]; 
bpoints12 = 
      Table[{0, 0, -0.03} + 
          b12t[(1.  - 10. ^-10) i/iMax + 10. ^-20], {i, 0, 
          iMax}]; bpoints22 = 
      Table[{0, 0, -0.03} + 
          b22t[(1.  - 10. ^-10) i/iMax + 10. ^-20], {i, 0, 
          iMax}]; 
bpoints01 = 
      Table[{0, 0, -0.04} + 
          b01t[(1.  - 10. ^-10) i/iMax + 10. ^-20], {i, 0, 
          iMax}]; 
bpoints11 = 
      Table[{0, 0, -0.04} + 
          b11t[(1.  - 10. ^-10) i/iMax + 10. ^-20], {i, 0, 
          iMax}]; 
bpoints21 = 
      Table[{0, 0, -0.04} + 
          b21t[(1.  - 10. ^-10) i/iMax + 10. ^-20], {i, 0, 
          iMax}]; bpoints31 = 
      Table[{0, 0, -0.04} + 
          b31t[(1.  - 10. ^-10) i/iMax + 10. ^-20], {i, 0, 
          iMax}];

independentVariables = 
      Flatten[{independentVariablesForVector["b0", {-0.4, 0.1, 0}], 
          independentVariablesForVector["b1", {0.0, 1.6, 0}], 
          independentVariablesForVector["b2", {1.0, 1.0, 0}], 
          independentVariablesForVector["b3", {1.2, 1.5, 0}], 
          independentVariablesForVector["b4", {2, 0.1, 0}]}]

dependentVariables = Flatten[{}]

chap5fig2 := 
      Graphics3D[{{PointSize[0.04], RGBColor[0. , 1, 0. ], 
            Point[b0 + {0, 0, 0.01}], Point[b1 + {0, 0, 0.01}], 
            Point[b2 + {0, 0, 0.01}], Point[b3 + {0, 0, 0.01}], 
            Point[b4 + {0, 0, 0.01}]}, {Thickness[0.01], GrayLevel[0], 
            Line[bpoints04], Thickness[0.015], GrayLevel[0.4], 
            Line[bpoints03], Line[bpoints13], Thickness[0.02], 
            GrayLevel[0.6], Line[bpoints02], Line[bpoints12], 
            Line[bpoints22], Thickness[0.02], GrayLevel[0.8], 
            Line[bpoints01], Line[bpoints11], Line[bpoints21], 
            Line[bpoints31]}, {Text[bfbi["0"], b0, {1.3, 1.5}], 
            Text[bfbi["1"], b1, {1.3, -1.5}], 
            Text[bfbi["2"], b2, {1.3, 1.5}], 
            Text[bfbi["3"], b3, {-1.3, -1.5}], 
            Text[bfbi["4"], b4, {-1.3, 1.5}]}}, 
        ViewPoint -> {0, 0, 4}, ViewVertical -> {0, 1, 0}, 
        SphericalRegion -> True, 
        PlotRange -> {{- .5, 2.5}, {-0.5, 1.5}, {-0.1, 
              0.1}}, Boxed -> False, Axes -> False, 
        Ticks -> Automatic, Lighting -> False, 
        AxesLabel -> {"x", "y", "z"}, 
        TextStyle -> newTextStyle]

Show[
      chap5fig2 //. 
        Join[independentVariables, dependentVariables]]

SetDirectory["/Users/martin/Desktop/mmasources"]

WriteLiveForm["chap5fig2.m", chap5fig2]

WriteHtmlPage["chap5fig2.html", "<FONT SIZE=+2><B>Figure 5.2</B> \
[Farin 2002, page 60]</FONT>",  "chap5fig2.m", 800, 500, 
      independentVariables,  
      dependentVariables, "<PARAM NAME=BGCOLOR VALUE=#FFFFFF>\n<PARAM NAME=\
\"MOUSE_DRAG_ACTION\" VALUE=\"NONE\">\n<PARAM NAME=\"POINT_EDGE_COLOR\" \
VALUE=#000000>\n"]

Figure 5.3, page 61

Input: points b0, b1, b2, b3, b4

Interaction: 
— free movement of b0, b1, b2, b3, b4

Output: 
— lines, polygon

SetDirectory["/Users/martin/Desktop/mmasources"]

ClearAll[b, t]

defineVector[{"b0", "b1", "b2", "b3", "b4"}]

bernstein[i_, n_, t_] := 
      Binomial[n, i] t^i (1 - t)^(n - i)

b[t_] := 
      Sum[bernstein[i, 4, t]*Symbol["b" <> ToString[i]], {i, 0, 
          4}];

iMax = 128; 
bpoints = 
      Table[{0, 0, 0.01} + b[-1 + 3*i/iMax + 0.0000001], {i, 0, 
          iMax}];

independentVariables = 
      Flatten[{independentVariablesForVector["b0", {0.4, 0.2, 0}], 
          independentVariablesForVector["b1", {0.1, 0.0, 0}], 
          independentVariablesForVector["b2", {0.0, 0.3, 0}], 
          independentVariablesForVector["b3", {0.1, 0.7, 0}], 
          independentVariablesForVector["b4", {0.5, 0.8, 0}]}]

dependentVariables = Flatten[{}]

chap5fig3 := 
      Graphics3D[{{PointSize[0.04], RGBColor[0. , 1, 0. ], 
            Point[b0 + {0, 0, 0.02}], Point[b1 + {0, 0, 0.02}], 
            Point[b2 + {0, 0, 0.02}], Point[b3 + {0, 0, 0.02}], 
            Point[b4 + {0, 0, 0.02}]}, {Thickness[0.01], GrayLevel[0], 
            Line[bpoints]}, {Thickness[0.005], GrayLevel[0], 
            Line[{b0 + {0, 0, 0.01}, b1 + {0, 0, 0.01}, b2 + {0, 0, 0.01}, 
                b3 + {0, 0, 0.01}, b4 + {0, 0, 0.01}}]}, {EdgeForm[], 
            GrayLevel[0.7], Polygon[{b0, b1, b2}], Polygon[{b0, b1, b3}], 
            Polygon[{b0, b1, b4}], Polygon[{b0, b2, b3}], 
            Polygon[{b0, b2, b4}], Polygon[{b0, b3, b4}], 
            Polygon[{b1, b2, b3}], Polygon[{b1, b2, b4}], 
            Polygon[{b1, b3, b4}], Polygon[{b2, b3, b4}]}}, 
        ViewPoint -> {0, 0, 4}, ViewVertical -> {0, 1, 0}, 
        SphericalRegion -> True, 
        PlotRange -> {{0, 1. }, {-0. , 1. }, {-0.1, 0.1}}, 
        Boxed -> False, Axes -> False, Ticks -> Automatic, 
        Lighting -> False, 
        AxesLabel -> {"x", "y", "z"}, 
        TextStyle -> newTextStyle]

Show[
      chap5fig3 //. 
        Join[independentVariables, dependentVariables]]

SetDirectory["/Users/martin/Desktop/mmasources"]

WriteLiveForm["chap5fig3.m", chap5fig3]

WriteHtmlPage["chap5fig3.html", "<FONT SIZE=+2><B>Figure 5.3</B> \
[Farin 2002, page 61]</FONT>",  "chap5fig3.m", 800, 500, 
      independentVariables,  
      dependentVariables, "<PARAM NAME=BGCOLOR VALUE=#FFFFFF>\n<PARAM NAME=\
\"MOUSE_DRAG_ACTION\" VALUE=\"NONE\">\n<PARAM NAME=\"POINT_EDGE_COLOR\" \
VALUE=#000000>\n"]

Figure 5.4, page 62

Input: points a0, a1, a2, a3, b0, b1, b2, b3

Interaction: 
— free movement of a0, a1, a2, a3, b0, b1, b2, b3

Output: 
— averages c0, c1, c2, c3, lines, curves

SetDirectory["/Users/martin/Desktop/mmasources"]

ClearAll[a, c, b, t]

\(defineVector[{"a0", \ "a1", \ "a2", \ "a3", \ "b0", "b1", "b2", "b3", "c0", "c1", "c2", "c3"}]\)

bernstein[i_, n_, t_] := 
      Binomial[n, i] t^i (1 - t)^(n - i)

a[t_] := 
      Sum[bernstein[i, 3, t]*Symbol["a" <> ToString[i]], {i, 0, 3}]; 
    b[t_] := Sum[
        bernstein[i, 3, t]*Symbol["b" <> ToString[i]], {i, 0, 3}]; 
    c[t_] := Sum[
        bernstein[i, 3, t]*Symbol["c" <> ToString[i]], {i, 0, 
          3}];

iMax = 64; 
apoints = Table[{0, 0, 0.005} + a[i/iMax + 0.0000001], {i, 0, iMax}]; 
    bpoints = Table[{0, 0, 0.005} + b[i/iMax + 0.0000001], {i, 0, iMax}]; 
    cpoints = 
      Table[{0, 0, 0.005} + c[i/iMax + 0.0000001], {i, 0, 
          iMax}];

independentVariables = 
      Flatten[{independentVariablesForVector["a0", {0.1, 0.1, 0}], 
          independentVariablesForVector["a1", {0.1, 0.3, 0}], 
          independentVariablesForVector["a2", {0.4, 0.8, 0}], 
          independentVariablesForVector["a3", {0.9, 0.9, 0}], 
          independentVariablesForVector["b0", {0.7, 0.1, 0}], 
          independentVariablesForVector["b1", {0.7, 0.4, 0}], 
          independentVariablesForVector["b2", {0.85, 0.4, 0}], 
          independentVariablesForVector["b3", {0.9, 0.6, 0}]}]

dependentVariables = 
      Flatten[{dependentVariablesForVector["c0", (a0 + b0)/2. ], 
          dependentVariablesForVector["c1", (a1 + b1)/2. ], 
          dependentVariablesForVector["c2", (a2 + b2)/2. ], 
          dependentVariablesForVector["c3", (a3 + b3)/
              2. ]}]

chap5fig4 := 
      Graphics3D[{{PointSize[0.04], RGBColor[0. , 1, 0. ], 
            Point[a0 + {0, 0, 0.01}], Point[a1 + {0, 0, 0.01}], 
            Point[a2 + {0, 0, 0.01}], Point[a3 + {0, 0, 0.01}], 
            Point[b0 + {0, 0, 0.01}], Point[b1 + {0, 0, 0.01}], 
            Point[b2 + {0, 0, 0.01}], Point[b3 + {0, 0, 0.01}], GrayLevel[0], 
            PointSize[0.02], Point[c0 + {0, 0, 0.01}], 
            Point[c1 + {0, 0, 0.01}], Point[c2 + {0, 0, 0.01}], 
            Point[c3 + {0, 0, 0.01}]}, {Thickness[0.01], GrayLevel[0], 
            Line[cpoints], GrayLevel[0.6], Line[apoints], 
            Line[bpoints]}, {Thickness[0.005], GrayLevel[0], 
            Line[{c0 + {0, 0, 0. }, c1 + {0, 0, 0.0}, c2 + {0, 0, 0.0}, 
                c3 + {0, 0, 0.0}}], GrayLevel[0.6], 
            Line[{a0 + {0, 0, 0.0}, a1 + {0, 0, 0.0}, a2 + {0, 0, 0.0}, 
                a3 + {0, 0, 0.0}}], GrayLevel[0.6], 
            Line[{b0 + {0, 0, 0.0}, b1 + {0, 0, 0.0}, b2 + {0, 0, 0.0}, 
                b3 + {0, 0, 0.0}}]}}, ViewPoint -> {0, 0, 4}, 
        ViewVertical -> {0, 1, 0}, SphericalRegion -> True, 
        PlotRange -> {{0, 1. }, {-0. , 1. }, {-0.1, 0.1}}, 
        Boxed -> False, Axes -> False, Ticks -> Automatic, 
        Lighting -> False, 
        AxesLabel -> {"x", "y", "z"}, 
        TextStyle -> newTextStyle]

Show[
      chap5fig4 //. 
        Join[independentVariables, dependentVariables]]

SetDirectory["/Users/martin/Desktop/mmasources"]

WriteLiveForm["chap5fig4.m", chap5fig4]

WriteHtmlPage["chap5fig4.html", "<FONT SIZE=+2><B>Figure 5.4</B> \
[Farin 2002, page 62]</FONT>",  "chap5fig4.m", 800, 500, 
      independentVariables,  
      dependentVariables, "<PARAM NAME=BGCOLOR VALUE=#FFFFFF>\n<PARAM NAME=\
\"MOUSE_DRAG_ACTION\" VALUE=\"NONE\">\n<PARAM NAME=\"POINT_EDGE_COLOR\" \
VALUE=#000000>\n"]

Figure 5.6, page 65

Input: points b0, b1, b2, b3

Interaction: 
— free movement of b0, b1, b2, b3

Output: 
— curve, arrows, derivatives, hodograph

SetDirectory["/Users/martin/Desktop/mmasources"]

<< Arrow3D`

SetOptions[Arrow3D, HeadLength -> 0.2];

ClearAll[b, db, t]

defineVector[{"b0", "b1", "b2", "b3", "db0", "db1\
", "db2", "db3"}]

bernstein[i_, n_, t_] := 
      Binomial[n, i] t^i (1 - t)^(n - i)

b[t_] := 
      Sum[bernstein[i, 3, t]*Symbol["b" <> ToString[i]], {i, 0, 
          3}]; 
db[t_] := 
      Sum[bernstein[i, 2, 
            t]*(Symbol["b" <> ToString[i + 1]] - 
              Symbol["b" <> ToString[i]]), {i, 0, 2}];

iMax = 64; 
bpoints = 
      Table[{0, 0, 0. } + b[i/iMax + 0.0000001], {i, 0, 
          iMax}]; 
dbpoints = 
      Table[{0, 0, 0. } + db[i/iMax + 0.0000001], {i, 0, iMax}];

independentVariables = 
      Flatten[{independentVariablesForVector["b0", {1.4 - 4, -0.5, 
              0}], independentVariablesForVector["b1", {1.6 - 4, 0.6, 
              0}], independentVariablesForVector["b2", {2.6 - 4, 0.7, 
              0}], independentVariablesForVector["b3", {3.  - 
                4, -0.1, 0}]}]

dependentVariables = 
      Flatten[{dependentVariablesForVector["db0", b1 - b0], 
          dependentVariablesForVector["db1", b2 - b1], 
          dependentVariablesForVector["db2", b3 - b2]}]

chap5fig6 := 
      Graphics3D[{{PointSize[0.04], RGBColor[0. , 1, 0. ], 
            Point[b0 + {0, 0, 0.01}], Point[b1 + {0, 0, 0.01}], 
            Point[b2 + {0, 0, 0.01}], Point[b3 + {0, 0, 0.01}], GrayLevel[0], 
            PointSize[0.02], Point[db0 + {0, 0, 0.01}], 
            Point[db1 + {0, 0, 0.01}], Point[db2 + {0, 0, 0.01}], 
            Point[{0, 0, 0.01}]}, {Thickness[0.01], GrayLevel[0], 
            Line[bpoints], GrayLevel[0. ], Line[dbpoints], 
            Line[dbpoints]}, {Thickness[0.005], GrayLevel[0], 
            Line[{db0 + {0, 0, 0.0}, db1 + {0, 0, 0.0}, 
                db2 + {0, 0, 0.0}}]}, {Thickness[0.01], EdgeForm[], 
            GrayLevel[0], Arrow3D[b0, b1], Arrow3D[b1, b2], Arrow3D[b2, b3], 
            Arrow3D[{0, 0, 0}, db0], Arrow3D[{0, 0, 0}, db1], 
            Arrow3D[{0, 0, 0}, db2]}, {Text[bfbi["0"], b0, {1.3, 1.5}], 
            Text[bfbi["1"], b1, {1.3, -1.5}], 
            Text[bfbi["2"], b2, {-1.3, -1.5}], 
            Text[bfbi["3"], b3, {-1.3, 1.5}], 
            Text[Subscript[
                StyleForm["Δb", 
                  FontWeight -> "Bold"], "1"], (b1 + b2)/
                2, {0, -1. }], 
            Text[Subscript[
                StyleForm["Δb", 
                  FontWeight -> "Bold"], "1"], db1, {-1.3, 0}]}}, 
        ViewPoint -> {0, 0, 4}, ViewVertical -> {0, 1, 0}, 
        SphericalRegion -> True, 
        PlotRange -> {{-2, 1}, {-0.8, 0.8}, {-0.1, 0.1}}, 
        Boxed -> False, Axes -> False, Ticks -> Automatic, 
        Lighting -> False, 
        AxesLabel -> {"x", "y", "z"}, 
        TextStyle -> newTextStyle]

Show[
      chap5fig6 //. 
        Join[independentVariables, dependentVariables]]

SetDirectory["/Users/martin/Desktop/mmasources"]

WriteLiveForm["chap5fig6.m", chap5fig6]

WriteHtmlPage["chap5fig6.html", "<FONT SIZE=+2><B>Figure 5.6</B> \
[Farin 2002, page 65]</FONT>",  "chap5fig6.m", 800, 500, 
      independentVariables,  
      dependentVariables, "<PARAM NAME=BGCOLOR VALUE=#FFFFFF>\n<PARAM NAME=\
\"MOUSE_DRAG_ACTION\" VALUE=\"NONE\">\n<PARAM NAME=\"POINT_EDGE_COLOR\" \
VALUE=#000000>\n"]

Figure 5.7, page 67

Input: points b0, b1, b2, b3

Interaction: 
— free movement of b0, b1, b2, b3

Output: 
— curve, arrows, derivatives

SetDirectory["/Users/martin/Desktop/mmasources"]

<< Arrow3D`

SetOptions[Arrow3D, HeadLength -> 0.2];

ClearAll[b, db, t]

\(defineVector[{"b0", "b1", "b2", "b3", "db0", "ddb0"}]\)

bernstein[i_, n_, t_] := 
      Binomial[n, i] t^i (1 - t)^(n - i)

b[t_] := 
      Sum[bernstein[i, 3, t]*Symbol["b" <> ToString[i]], {i, 0, 
          3}];

iMax = 64; 
bpoints = 
      Table[{0, 0, 0. } + b[i/iMax + 0.0000001], {i, 0, iMax}];

independentVariables = 
      Flatten[{independentVariablesForVector["b0", {0.4, -0.2, 0}], 
          independentVariablesForVector["b1", {0.6, 0.6, 0}], 
          independentVariablesForVector["b2", {1.6, 0.7, 0}], 
          independentVariablesForVector["b3", {2. , -0.1, 
              0}]}]

dependentVariables = 
      Flatten[{dependentVariablesForVector["db0", b1 - b0], 
          dependentVariablesForVector["db1", b2 - b1], 
          dependentVariablesForVector["ddb0", db1 - db0]}]

chap5fig7 := 
      Graphics3D[{{PointSize[0.04], RGBColor[0. , 1, 0. ], 
            Point[b0 + {0, 0, 0.01}], Point[b1 + {0, 0, 0.01}], 
            Point[b2 + {0, 0, 0.01}], Point[b3 + {0, 0, 0.01}], GrayLevel[0], 
            PointSize[0.02], 
            Point[b0 + db1 + {0, 0, 0.01}]}, {Thickness[0.01], GrayLevel[0], 
            Line[bpoints]}, {Thickness[0.005], GrayLevel[0. ], 
            Line[{b1, b2, b3}], Thickness[0.005], GrayLevel[0.6], 
            Line[{b0 + {0, 0, -0.01}, b0 + db1 + {0, 0, -0.01}, 
                b2 + {0, 0, -0.01}}]}, {Thickness[0.01], EdgeForm[], 
            GrayLevel[0], Arrow3D[b0, b1], Arrow3D[b0, b0 + ddb0], 
            Arrow3D[b1, b0 + db1]}, {Text[bfbi["0"], b0, {1.4, 0}], 
            Text[bfbi["1"], b1, {1.3, -1.5}], 
            Text[bfbi["2"], b2, {-1.3, -1.5}], 
            Text[bfbi["3"], b3, {-1.3, 1.5}], 
            Text[Subscript[
                StyleForm["Δb", 
                  FontWeight -> "Bold"], "0"], (b0 + b1)/2, {1.4, 
                0. }], Text[
              StringForm["````", 
                Superscript[
                  StyleForm["Δ", 
                    FontWeight -> "Bold"], "2"], 
                Subscript[
                  StyleForm["b", FontWeight -> "Bold"], "0"]], 
              b0 + ddb0/2, {1.2, 1.2}]}}, ViewPoint -> {0, 0, 4}, 
        ViewVertical -> {0, 1, 0}, SphericalRegion -> True, 
        PlotRange -> {{0, 2}, {-1. , 0.8}, {-0.1, 0.1}}, 
        Boxed -> False, Axes -> False, Ticks -> Automatic, 
        Lighting -> False, 
        AxesLabel -> {"x", "y", "z"}, 
        TextStyle -> newTextStyle]

Show[
      chap5fig7 //. 
        Join[independentVariables, dependentVariables]]

SetDirectory["/Users/martin/Desktop/mmasources"]

WriteLiveForm["chap5fig7.m", chap5fig7]

WriteHtmlPage["chap5fig7.html", "<FONT SIZE=+2><B>Figure 5.7</B> \
[Farin 2002, page 67]</FONT>",  "chap5fig7.m", 800, 500, 
      independentVariables,  
      dependentVariables, "<PARAM NAME=BGCOLOR VALUE=#FFFFFF>\n<PARAM NAME=\
\"MOUSE_DRAG_ACTION\" VALUE=\"NONE\">\n<PARAM NAME=\"POINT_EDGE_COLOR\" \
VALUE=#000000>\n"]

Figure 5.8, page 69 (see also Figure 4.5)

Input: points b0, b1, b2, b3, coordinate c

Interaction: 
— free movement of b0, b1, b2, b3
— movement of a and b on axis between 0 and 1

Output: 
— lines, interpolated points, mapping arrow

SetDirectory["/Users/martin/Desktop/mmasources"]

<< Arrow3D`

ClearAll[b, c]

defineVector[{"b0", "b1", "b2", "b3"}]

b[r_, s_, t_] := 
      b0*(1 - r)*(1 - s)*(1 - t) + 
        b1*((1 - r)*(1 - s)*t + (1 - r)*s*(1 - t) + 
              r*(1 - s)*(1 - t)) + 
        b2*((1 - r)*s*t + r*s*(1 - t) + r*(1 - s)*t) + 
        b3*r*s*t

iMax = 64; 
cpoints = 
      Table[b[c*i/iMax, c*i/iMax, c*i/iMax], {i, 0 + 0.0000001, 
          iMax + 0.00001}]; 
iMax = 64; 
bpoints = 
      Table[b[c + (1 - c)*i/iMax, c + (1 - c)*i/iMax, 
          c + (1 - c)*i/iMax], {i, 0 + 0.0000001, 
          iMax + 0.0001}];

independentVariables = 
      Flatten[{independentVariablesForVector["b0", {-0.5, 0.5, 0}], 
          independentVariablesForVector["b1", {0.4, 1.3, 0}], 
          independentVariablesForVector["b2", {1.2, 1.0, 0}], 
          independentVariablesForVector["b3", {1.3, 0.5, 0}], 
          c -> 0.5}]

dependentVariables = Flatten[{}]

chap5fig8 := 
      Graphics3D[{{PointSize[0.04], RGBColor[0. , 1, 0. ], 
            Point[b0 + {0, 0, 0.01}], Point[b1 + {0, 0, 0.01}], 
            Point[b2 + {0, 0, 0.01}], Point[b3 + {0, 0, 0.01}], 
            Point[{c, 0, 0.01}], GrayLevel[0], 
            Point[b[0, 0, c] + {0, 0, 0.01}], 
            Point[b[0, c, c] + {0, 0, 0.01}], 
            Point[b[c, c, c] + {0, 0, 0.01}]}, {Thickness[0.005], 
            GrayLevel[0], Line[{b0, b1, b2, b3}], 
            Line[{b[0, 0, 0], b[0, 0, c], b[0, c, c], 
                b[c, c, c]}]}, 
{PointSize[0.02], 
            GrayLevel[0], Point[{0, 0, 0}], 
            Point[{1, 0, 0}]}, {Thickness[0.01], GrayLevel[0], 
            Line[{{0, 0, 0}, {c, 0, 0}}], Thickness[0.005], 
            Line[{{c, 0, 0}, {1, 0, 0}}]}, {Thickness[0.01], GrayLevel[0], 
            Line[cpoints], Thickness[0.0025], 
            Line[bpoints]}, {PointSize[0.01]}, {EdgeForm[], GrayLevel[0.6], 
            Thickness[0.03], 
            Arrow3D[0.8*{c, 0.0, -0.01} + 0.2*b[c, c, c], 
              0.4*{c, 0.0, -0.01} + 0.6*b[c, c, c], 
              HeadLength -> 0.2, HeadWidth -> 1]}, {Text[
              bfbi["0"], b0, {1.3, 1.5}], 
            Text[bfbi["1"], b1, {1.3, -1.5}], 
            Text[bfbi["2"], b2, {-1.3, -1.5}], 
            Text[bfbi["3"], b3, {-1.3, 1.5}], 
            Text[bfci["1"], b[0, 0, c], {1.3, -1.5}], 
            Text[bfci["2"], b[0, c, c], {0, 1.5}], 
            Text[bfci["3"], b[c, c, c], {-1.3, 1.5}], 
            Text[itc, {c, 0, 0}, {0, 1.5}], 
            Text["0", {0, 0, 0}, {0, 1.5}], 
            Text["1", {1, 0, 0}, {0, 1.5}]}}, 
        ViewPoint -> {0, 0, 4}, ViewVertical -> {0, 1, 0}, 
        SphericalRegion -> True, 
        PlotRange -> {{- .5, 1.5}, {-0.2, 1.2}, {-0.1, 
              0.1}}, Boxed -> False, Axes -> False, 
        Ticks -> Automatic, Lighting -> False, 
        AxesLabel -> {"x", "y", "z"}, 
        TextStyle -> newTextStyle]

Show[
      chap5fig8 //. 
        Join[independentVariables, dependentVariables]]

SetDirectory["/Users/martin/Desktop/mmasources"]

WriteLiveForm["chap5fig8.m", chap5fig8]

WriteHtmlPage["chap5fig8.html", "<FONT SIZE=+2><B>Figure 5.8</B> \
[Farin 2002, page 69]</FONT>",  "chap5fig8.m", 800, 500, 
      independentVariables,  
      dependentVariables, "<PARAM NAME=BGCOLOR VALUE=#FFFFFF>\n<PARAM NAME=\
\"MOUSE_DRAG_ACTION\" VALUE=\"NONE\">\n<PARAM NAME=\"POINT_EDGE_COLOR\" \
VALUE=#000000>\n"]

Figure 5.9, page 70

Input: points b0, b1, b2, b3, b4

Interaction: 
— free movement of b0, b1, b2, b3, b4

Output: 
— lines, polygon, minmax box

SetDirectory["/Users/martin/Desktop/mmasources"]

ClearAll[b, t]

defineVector[{"b0", "b1", "b2", "b3", "b4"}]

bernstein[i_, n_, t_] := 
      Binomial[n, i] t^i (1 - t)^(n - i)

b[t_] := 
      Sum[bernstein[i, 4, t]*Symbol["b" <> ToString[i]], {i, 0, 
          4}];

iMax = 64; 
bpoints = 
      Table[{0, 0, 0.01} + b[i/iMax + 0.0000001], {i, 0, iMax}];

independentVariables = 
      Flatten[{independentVariablesForVector["b0", {0.4, 0.2, 0}], 
          independentVariablesForVector["b1", {0.1, 0.0, 0}], 
          independentVariablesForVector["b2", {0.0, 0.3, 0}], 
          independentVariablesForVector["b3", {0.1, 0.7, 0}], 
          independentVariablesForVector["b4", {0.5, 0.8, 0}]}]

dependentVariables = 
      Flatten[{maxx -> Max[b0x, b1x, b2x, b3x, b4x], 
          maxy -> Max[b0y, b1y, b2y, b3y, b4y], 
          minx -> Min[b0x, b1x, b2x, b3x, b4x], 
          miny -> Min[b0y, b1y, b2y, b3y, b4y]}]

chap5fig9 := 
      Graphics3D[{{PointSize[0.04], RGBColor[0. , 1, 0. ], 
            Point[b0 + {0, 0, 0.02}], Point[b1 + {0, 0, 0.02}], 
            Point[b2 + {0, 0, 0.02}], Point[b3 + {0, 0, 0.02}], 
            Point[b4 + {0, 0, 0.02}]}, {Thickness[0.01], GrayLevel[0], 
            Line[bpoints]}, {Thickness[0.005], GrayLevel[0], 
            Line[{b0 + {0, 0, 0.01}, b1 + {0, 0, 0.01}, b2 + {0, 0, 0.01}, 
                b3 + {0, 0, 0.01}, b4 + {0, 0, 0.01}}]}, {EdgeForm[], 
            GrayLevel[0.7], 
            Polygon[{{minx, miny, 0}, {maxx, miny, 0}, {maxx, maxy, 
                  0}, {minx, maxy, 0}, {minx, miny, 0}}]}}, 
        ViewPoint -> {0, 0, 4}, ViewVertical -> {0, 1, 0}, 
        SphericalRegion -> True, 
        PlotRange -> {{0, 1. }, {-0. , 1. }, {-0.1, 0.1}}, 
        Boxed -> False, Axes -> False, Ticks -> Automatic, 
        Lighting -> False, 
        AxesLabel -> {"x", "y", "z"}, 
        TextStyle -> newTextStyle]

Show[
      chap5fig9 //. 
        Join[independentVariables, dependentVariables]]

SetDirectory["/Users/martin/Desktop/mmasources"]

WriteLiveForm["chap5fig9.m", chap5fig9]

WriteHtmlPage["chap5fig9.html", "<FONT SIZE=+2><B>Figure 5.9</B> \
[Farin 2002, page 70]</FONT>",  "chap5fig9.m", 800, 500, 
      independentVariables,  
      dependentVariables, "<PARAM NAME=BGCOLOR VALUE=#FFFFFF>\n<PARAM NAME=\
\"MOUSE_DRAG_ACTION\" VALUE=\"NONE\">\n<PARAM NAME=\"POINT_EDGE_COLOR\" \
VALUE=#000000>\n"]

Figure 5.12, 5.13, page 72

Input: points b0, b1, b2, b3, b4, b5, b6, coordinates a, b, c

Interaction: 
— free movement of b0, b1, b2, b3, b4, b5, b6
— movement of a, b, c

Output: 
— points, lines, bezier curves, coordinate systems

SetDirectory["/Users/martin/Desktop/mmasources"]

<< Arrow3D`

ClearAll[a, b, c]

\(defineVector[{"b0", "b1", "b2", "b3", \ "b4", \ "b5", \ "b6", "bTY0", "bTY1", "bTY2", "bTY3", "bTY4", "bTY5", "bTY6"}]\)

bernstein[i_, n_, t_] := 
      Binomial[n, i] t^i (1 - t)^(n - i)

bminus[t_] := 
      Sum[bernstein[i, 3, t]*Symbol["b" <> ToString[i]], {i, 0, 
          3}]; 
bplus[t_] := 
      Sum[bernstein[i, 3, t]*Symbol["b" <> ToString[i + 3]], {i, 0, 
          3}]; 
bminusTY[t_] := {a + t*(b - a), bminus[t][[2]], 
        0}; 
bplusTY[t_] := {b + t*(c - b), bplus[t][[2]], 
        0};

iMax = 32; 
bminuspoints = 
      Table[bminus[i/iMax], {i, 0.0000001, 
          iMax + 0.0001}]; 
bpluspoints = 
      Table[bplus[i/iMax], {i, 0.0000001, 
          iMax + 0.0001}]; 
bminusTYpoints = 
      Table[bminusTY[i/iMax], {i, 0.0000001, 
          iMax + 0.0001}]; 
bplusTYpoints = 
      Table[bplusTY[i/iMax], {i, 0.000001, iMax + 0.00001}];

independentVariables = 
      Flatten[{independentVariablesForVector["b0", {0.2, 0.4, 0}], 
          independentVariablesForVector["b1", {0.3, 0.5, 0}], 
          independentVariablesForVector["b2", {0.5, 0.4, 0}], 
          independentVariablesForVector["b3", {0.7, 0.6, 0}], 
          independentVariablesForVector["b4", {1.0, 0.9, 0}], 
          independentVariablesForVector["b5", {0.6, 1.1, 0}], 
          independentVariablesForVector["b6", {0.5, 1.0, 0}], 
          a -> -0.1, b -> -0.5, 
          c -> -1.1}]

dependentVariables = 
      Flatten[{dependentVariablesForVector["bTY0", {a + 0/3 (b - a), 
              b0y, 0}], 
          dependentVariablesForVector["bTY1", {a + 1/3*(b - a), b1y, 
              0}], dependentVariablesForVector["bTY2", {a + 
                2/3*(b - a), b2y, 0}], 
          dependentVariablesForVector["bTY3", {a + 3/3*(b - a), b3y, 
              0}], dependentVariablesForVector["bTY4", {b + 
                1/3*(c - b), b4y, 0}], 
          dependentVariablesForVector["bTY5", {b + 2/3*(c - b), b5y, 
              0}], dependentVariablesForVector["bTY6", {b + 
                3/3*(c - b), b6y, 0}]}]

chap5fig12 := 
      Graphics3D[{{PointSize[0.04], RGBColor[0. , 1, 0. ], 
            Point[b0 + {0, 0, 0.01}], Point[b1 + {0, 0, 0.01}], 
            Point[b2 + {0, 0, 0.01}], Point[b3 + {0, 0, 0.01}], 
            Point[b4 + {0, 0, 0.01}], Point[b5 + {0, 0, 0.01}], 
            Point[b6 + {0, 0, 0.01}], Point[{a, b0y, 0.01}], 
            Point[{b, b3y, 0.01}], Point[{c, b6y, 0.01}], 
            Point[{a, 0, 0.01}], Point[{b, 0, 0.01}], 
            Point[{c, 0, 0.01}]}, {Thickness[0.005], GrayLevel[0], 
            Line[{b0, b1, b2, b3, b4, b5, b6}], 
            Line[{bTY0, bTY1, bTY2, bTY3, bTY4, bTY5, 
                bTY6}]}, 
{PointSize[0.02], GrayLevel[0], 
            Point[{0, 0, 0}], Point[bTY1 + {0, 0, 0.01}], 
            Point[bTY2 + {0, 0, 0.01}], Point[bTY4 + {0, 0, 0.01}], 
            Point[bTY5 + {0, 0, 0.01}]}, {Thickness[0.01], GrayLevel[0], 
            Line[bminuspoints], Line[bpluspoints], Line[bminusTYpoints], 
            Line[bplusTYpoints]}, {PointSize[0.01]}, {EdgeForm[], 
            GrayLevel[0. ], Thickness[0.005], 
            Arrow3D[{0, 0, 0}, {1. , 0, 0}, HeadLength -> 0.1], 
            Arrow3D[{0, 0, 0}, {0, 1.3, 0}, HeadLength -> 0.1], 
            Arrow3D[{0, 0, 0}, {-1.3, 0, 0}, 
              HeadLength -> 0.1]}, {Text[bfbi["0"], b0, {0, 1.5}], 
            Text[bfbi["1"], b1, {0, -1.5}], 
            Text[bfbi["2"], b2, {-1.3, 1.5}], 
            Text[bfbi["3"], b3, {-1.3, 1.5}], 
            Text[bfbi["4"], b4, {-1.3, -1.5}], 
            Text[bfbi["5"], b5, {-1.3, -1.5}], 
            Text[bfbi["6"], b6, {1.3, -1.5}], 
            Text[itc, {c, 0, 0}, {0, 1.5}], Text[itb, {b, 0, 0}, {0, 1.5}], 
            Text[ita, {a, 0, 0}, {0, 1.5}], 
            Text["t", {-1.3, 0, 0}, {1.5, 0}], 
            Text["x", {1. , 0, 0}, {-1.5, 0}], 
            Text["y", {0. , 1.3, 0}, {1.3, 0}]}}, 
        ViewPoint -> {0, 0, 4}, ViewVertical -> {0, 1, 0}, 
        SphericalRegion -> True, 
        PlotRange -> {{-1. , 1. }, {0. , 1. }, {-0.1, 0.1}}, 
        Boxed -> False, Axes -> False, Ticks -> Automatic, 
        Lighting -> False, 
        AxesLabel -> {"x", "y", "z"}, 
        TextStyle -> newTextStyle]

Show[
      chap5fig12 //. 
        Join[independentVariables, dependentVariables]]

SetDirectory["/Users/martin/Desktop/mmasources"]

WriteLiveForm["chap5fig12.m", chap5fig12]

WriteHtmlPage["chap5fig12.html", "<FONT SIZE=+2><B>Figures 5.12 \
and 5.13</B> [Farin 2002, page 72]</FONT>",  "chap5fig12.m", 800, 500, 
      independentVariables,  
      dependentVariables, "<PARAM NAME=BGCOLOR VALUE=#FFFFFF>\n<PARAM NAME=\
\"MOUSE_DRAG_ACTION\" VALUE=\"NONE\">\n<PARAM NAME=\"POINT_EDGE_COLOR\" \
VALUE=#000000>\n"]

Figure 5.14, page 74

Input: points b0, b1, b2, b3, b4, b01

Interaction: 
— free movement of b0, b1, b2, b3, b4
— movement of b01 between b0 and b1 (projection to line b0b1)

Output: 
— computation of t1 from b01
— first polar for t1, lines, polygon

SetDirectory["/Users/martin/Desktop/mmasources"]

ClearAll[b, t, t1]

\(defineVector[{"b0", "b1", "b2", "b3", "b4", "b01", "temp"}]\)

bernstein[i_, n_, t_] := 
      Binomial[n, i] t^i (1 - t)^(n - i)

b[t_] := 
      Sum[bernstein[i, 4, t]*Symbol["b" <> ToString[i]], {i, 0, 
          4}]; 
p1[t_] := 
      Sum[bernstein[i, 3, 
            t]*((1 - t1)*Symbol["b" <> ToString[i]] + 
              t1*Symbol["b" <> ToString[i + 1]]), {i, 0, 
          3}];

iMax = 32; 
bpoints = 
      Table[{0, 0, -0.001} + b[i/iMax + 0.0000001], {i, 0, 
          iMax}]; 
ppoints = 
      Table[{0, 0, -0.001} + p1[i/iMax + 0.0000001], {i, 0, 
          iMax}];

independentVariables = 
      Flatten[{independentVariablesForVector["b0", {0.4, 0. , 0}], 
          independentVariablesForVector["b1", {-0.1, 0.9, 0}], 
          independentVariablesForVector["b2", {1.1, 0.9, 0}], 
          independentVariablesForVector["b3", {0.6, 0.1, 0}], 
          independentVariablesForVector["b4", {0.5, 0.5, 0}], 
          independentVariablesForVector["b01", ({0.4, 0.1, 0} + {0.1, 
                    0.9, 0})/2. ], t1 -> 0.5}]

\(dependentVariables = 
      Flatten[{dependentVariablesForVectorProlog["b01"], 
          dependentVariablesForVector["temp", \((\((b01 - b0)\) . \((b1 - 
                          b0)\))\)/\((\((b1 - b0)\) . \((b1 - 
                          b0)\))\)*\((b1 - b0)\) + 
              b0], 
dependentVariablesForReassignmentOfVector["b01", "b01", 
            temp], 
t1 -> 
            If[\(! b01IsNew\), t1, 
              Evaluate[
                Sign[\((b01 - b0)\) . \((b1 - b0)\)]*
                  Sqrt[\((b01 - b0)\) . \((b01 - b0)\)]/
                    Sqrt[\((b1 - b0)\) . \((b1 - b0)\)]]], 
          dependentVariablesForVector["b01", 
            b0 + \((t1)\)*\((b1 - b0)\)], 
          dependentVariablesForVectorEpilog["b01"]}]\)

chap5fig14 := 
      Graphics3D[{{PointSize[0.04], RGBColor[0. , 1, 0. ], Point[b0], 
            Point[b1], Point[b2], Point[b3], Point[b4], 
            Point[b01]}, {PointSize[0.02], GrayLevel[0], 
            Point[(1 - t1)*b1 + t1*b2], Point[(1 - t1)*b2 + t1*b3], 
            Point[(1 - t1)*b3 + t1*b4]}, {Thickness[0.01], GrayLevel[0], 
            Line[bpoints], Line[ppoints]}, {Thickness[0.005], GrayLevel[0], 
            Line[{b0 - {0, 0, 0.001}, b1 - {0, 0, 0.001}, b2 - {0, 0, 0.001}, 
                b3 - {0, 0, 0.001}, b4 - {0, 0, 0.001}}]}, {Thickness[
              0.0025], GrayLevel[0], 
            Map[Line, Transpose[{bpoints, ppoints}]]}}, 
        ViewPoint -> {0, 0, 4}, ViewVertical -> {0, 1, 0}, 
        SphericalRegion -> True, 
        PlotRange -> {{0, 1. }, {0.1, 0.9}, {-0.1, 0.1}}, 
        Boxed -> False, Axes -> False, Ticks -> Automatic, 
        Lighting -> False, 
        AxesLabel -> {"x", "y", "z"}, 
        TextStyle -> newTextStyle]

Show[
      chap5fig14 //. 
        Join[independentVariables, dependentVariables]]

SetDirectory["/Users/martin/Desktop/mmasources"]

WriteLiveForm["chap5fig14.m", chap5fig14]

WriteHtmlPage["chap5fig14.html", "<FONT SIZE=+2><B>Figure \
5.14</B> [Farin 2002, page 74]</FONT>",  "chap5fig14.m", 800, 500, 
      independentVariables,  
      dependentVariables, "<PARAM NAME=BGCOLOR VALUE=#FFFFFF>\n<PARAM NAME=\
\"POINT_EDGE_COLOR\" VALUE=#000000>\n"]

Figures for Chapter 6

Figure 6.1, page 82

Input: points b0, b1, b2, b3

Interaction: 
— free movement of b0, b1, b2, b3

Output: 
— points b11, b21, b31
— bezier curve, control polygon

SetDirectory["/Users/martin/Desktop/mmasources"]

ClearAll[b, t]

defineVector[{"b0", "b1", "b2", "b3", "b11", "b21\
", "b31"}]

bernstein[i_, n_, t_] := 
      Binomial[n, i] t^i (1 - t)^(n - i)

b[t_] := 
      Sum[bernstein[i, 3, t]*Symbol["b" <> ToString[i]], {i, 0, 
          3}];

iMax = 64; 
bpoints = 
      Table[{0, 0, -0.001} + b[i/iMax + 0.0000001], {i, 0, 
          iMax}];

independentVariables = 
      Flatten[{independentVariablesForVector["b0", {0. , 0.4, 0}], 
          independentVariablesForVector["b1", {1. , 0.0, 0}], 
          independentVariablesForVector["b2", {1. , 1. , 0}], 
          independentVariablesForVector["b3", {0.2, 0. , 0}]}]

dependentVariables = 
      Flatten[{independentVariablesForVector["b11", 
            1/(3 + 1) b0 + (1 - 1/(3 + 1))*b1], 
          independentVariablesForVector["b21", 
            2/(3 + 1) b1 + (1 - 2/(3 + 1))*b2], 
          independentVariablesForVector["b31", 
            3/(3 + 1) b2 + (1 - 3/(3 + 1))*b3]}]

chap6fig1 := 
      Graphics3D[{{PointSize[0.04], RGBColor[0. , 1, 0. ], Point[b0], 
            Point[b1], Point[b2], Point[b3]}, {PointSize[0.02], GrayLevel[0], 
            Point[b11], Point[b21], Point[b31]}, {Thickness[0.01], 
            GrayLevel[0], Line[bpoints]}, {Thickness[0.005], GrayLevel[0], 
            Line[{b0 - {0, 0, 0.001}, b1 - {0, 0, 0.001}, b2 - {0, 0, 0.001}, 
                b3 - {0, 0, 0.001}}], 
            Line[{b11 - {0, 0, 0.001}, b21 - {0, 0, 0.001}, 
                b31 - {0, 0, 0.001}}]}, {Text[bfbi["0"], 
              b0, {1.3, -1.5}], Text[bfbi["1"], b1, {-1.2, 1.5}], 
            Text[bfbi["2"], b2, {-1.2, -1.5}], 
            Text[bfbi["3"], b3, {1.1, 1.5}], 
            Text[bfbir["3", "(1)"], b31, {1.1, -1.1}], 
            Text[bfbir["2", "(1)"], b21, {-1.3, 0}], 
            Text[bfbir["1", "(1)"], b11, {1.1, 1.1}]}}, 
        ViewPoint -> {0, 0, 4}, ViewVertical -> {0, 1, 0}, 
        SphericalRegion -> True, 
        PlotRange -> {{-0.1, 1.1}, {-0.1, 1.1}, {-0.1, 
              0.1}}, Boxed -> False, Axes -> False, 
        Ticks -> Automatic, Lighting -> False, 
        AxesLabel -> {"x", "y", "z"}, 
        TextStyle -> newTextStyle]

Show[
      chap6fig1 //. 
        Join[independentVariables, dependentVariables]]

SetDirectory["/Users/martin/Desktop/mmasources"]

WriteLiveForm["chap6fig1.m", chap6fig1]

WriteHtmlPage["chap6fig1.html", "<FONT SIZE=+2><B>Figure 6.1</B> \
[Farin 2002, page 82]</FONT>",  "chap6fig1.m", 800, 500, 
      independentVariables,  
      dependentVariables, "<PARAM NAME=BGCOLOR VALUE=#FFFFFF>\n<PARAM NAME=\
\"POINT_EDGE_COLOR\" VALUE=#000000>\n"]

Figure 6.3, page 87

Input: three function values f0, f1, f2, f3

Interaction: 
— movement of f0, f1, f2, f3 along y axis

Output: 
— coordinate system 
— lines, curve

SetDirectory["/Users/martin/Desktop/mmasources"]

bernstein[i_, n_, t_] := 
      Binomial[n, i] t^i (1 - t)^(n - i)

b[t_] := 
      Sum[bernstein[i, 3, t]*{i/3, Symbol["f" <> ToString[i]], 0}, {i, 0, 
          3}];

iMax = 64; 
bpoints = 
      Table[{0, 0, -0.001} + b[i/iMax + 0.0000001], {i, 0, 
          iMax}];

independentVariables = 
      Flatten[{f0 -> 0.3, f1 -> 0.2, f2 -> 0.8, 
          f3 -> 0.3}]

dependentVariables = Flatten[{}]

chap6fig3 := 
      Graphics3D[{{PointSize[0.04], RGBColor[0. , 1, 0. ], 
            Point[{0, f0, 0.01}], Point[{1/3, f1, 0.01}], 
            Point[{2/3, f2, 0.01}], Point[{1, f3, 0.01}]}, {Thickness[0.01], 
            GrayLevel[0], Line[bpoints]}, {Thickness[0.005], GrayLevel[0], 
            Line[{{0, f0, 0}, {1/3, f1, 0}, {2/3, f2, 0}, {1, f3, 
                  0}}]}, {Thickness[0.005], 
            Line[{{0, 1, 0}, {0, 0, 0}, {1, 0, 0}, {1, 1, 0}}], 
            Line[{{1/3, 0, 0}, {1/3, 1, 0}}], 
            Line[{{2/3, 0, 0}, {2/3, 1, 0}}]}, {Text[
              itbi["0"], {0, f0, 0}, {1.3, 1.3}], 
            Text[itbi["1"], {1/3, f1, 0}, {1.3, 1.3}], 
            Text[itbi["2"], {2/3, f2, 0}, {-1.3, -1.3}], 
            Text[itbi["3"], {1, f3, 0}, {-1.3, 1.3}], 
            Text["0", {0, 0, 0}, {0, 1.2}], 
            Text["1/3", {1/3, 0, 0}, {0, 1.2}], 
            Text["2/3", {2/3, 0, 0}, {0, 1.2}], 
            Text["1", {1, 0, 0}, {0, 1.2}]}}, 
        ViewPoint -> {0, 0, 4}, ViewVertical -> {0, 1, 0}, 
        SphericalRegion -> True, 
        PlotRange -> {{0. , 1. }, {0. , 1. }, {-0.1, 0.1}}, 
        Boxed -> False, Axes -> False, Ticks -> Automatic, 
        Lighting -> False, 
        AxesLabel -> {"x", "y", "z"}, 
        TextStyle -> newTextStyle]

Show[
      chap6fig3 //. 
        Join[independentVariables, dependentVariables]]

SetDirectory["/Users/martin/Desktop/mmasources"]

WriteLiveForm["chap6fig3.m", chap6fig3]

WriteHtmlPage["chap6fig3.html", "<FONT SIZE=+2><B>Figure 6.3</B> \
[Farin 2002, page 87]</FONT>",  "chap6fig3.m", 800, 500, 
      independentVariables,  
      dependentVariables, "<PARAM NAME=BGCOLOR VALUE=#FFFFFF>\n<PARAM NAME=\
\"MOUSE_DRAG_ACTION\" VALUE=\"NONE\">\n<PARAM NAME=\"POINT_EDGE_COLOR\" \
VALUE=#000000>\n"]

Figure 6.4, page 88

Input: points b0, b1, b2, b3

Interaction: 
— free movement of b0, b1, b2, b3 in 2D

Output: 
— points, crossplot of bezier curves, coordinate systems

SetDirectory["/Users/martin/Desktop/mmasources"]

<< Arrow3D`

ClearAll[a, b, c]

\(defineVector[{"b0", "b1", "b2", "b3", "bTY0", "bTY1", "bTY2", "bTY3", "bTX0", "bTX1", "bTX2", "bTX3"}]\)

bernstein[i_, n_, t_] := 
      Binomial[n, i] t^i (1 - t)^(n - i)

b[t_] := 
      Sum[bernstein[i, 3, t]*Symbol["b" <> ToString[i]], {i, 0, 
          3}]; 
bTY[
        t_] := {-t*0.8 - 
          0.1, b[
            t][[2]], -0.001}; 
bTX[
        t_] := {b[t][[1]], -t*0.8 - 
          0.1, -0.001};

iMax = 32; 
bpoints = 
      Table[b[i/iMax], {i, 0.0000001, 
          iMax + 0.0001}]; 
bTYpoints = 
      Table[bTY[i/iMax], {i, 0.0000001, 
          iMax + 0.0001}]; 
bTXpoints = 
      Table[bTX[i/iMax], {i, 0.0000001, iMax + 0.0001}];

independentVariables = 
      Flatten[{independentVariablesForVector["b0", {0.1, 0.3, 0}], 
          independentVariablesForVector["b1", {0.3, 0.6, 0}], 
          independentVariablesForVector["b2", {0.8, 0.6, 0}], 
          independentVariablesForVector["b3", {0.8, 0.2, 0}]}]

dependentVariables = Flatten[{}];

\(chap6fig4 := 
      Graphics3D[{{PointSize[0.04], RGBColor[0. , 1, 0. ], 
            Point[b0 + {0, 0, 0.01}], Point[b1 + {0, 0, 0.01}], 
            Point[b2 + {0, 0, 0.01}], Point[b3 + {0, 0, 0.01}], 
            PointSize[0.02], Point[{\(-0.1\), b0y, 0.01}], 
            Point[{\(-0.4\), b1y, 0.01}], Point[{\(-0.7\), b2y, 0.01}], 
            Point[{\(-0.9\), b3y, 0.01}], Point[{b0x, \(-0.1\), 0.01}], 
            Point[{b1x, \(-0.4\), 0.01}], Point[{b2x, \(-0.7\), 0.01}], 
            Point[{b3x, \(-0.9\), 0.01}]}, {Thickness[0.005], GrayLevel[0], 
            Line[{b0, b1, b2, b3}], 
            Line[{{\(-0.1\), b0y, \(-0.01\)}, {\(-0.4\), 
                  b1y, \(-0.01\)}, {\(-0.7\), b2y, \(-0.01\)}, {\(-0.9\), 
                  b3y, \(-0.01\)}}], 
            Line[{{b0x, \(-0.1\), \(-0.01\)}, {b1x, \(-0.4\), \(-0.01\)}, {b2x, \(-0.7\), \(-0.01\)}, {b3x, \(-0.9\), \(-0.01\)}}]}, {Thickness[0.01], 
            GrayLevel[0], Line[bpoints], Line[bTYpoints], 
            Line[bTXpoints]}, {PointSize[0.01]}, {EdgeForm[], GrayLevel[0. ], 
            Thickness[0.005], 
            Arrow3D[{0, 0, 0}, {1. , 0, 0}, HeadLength -> 0.1], 
            Arrow3D[{0, 0, 0}, {0, 1. , 0}, HeadLength -> 0.1], 
            Arrow3D[{0, 0, 0}, {\(-1. \), 0, 0}, 
              HeadLength -> 0.1], 
Arrow3D[{0, 0, 
                0}, {0, \(-1. \), 0}, 
              HeadLength -> 0.1]}, {Text["t ", {\(-1. \), 0, 
                0}, {1.5, 0}], Text["t ", {0. , \(-1\), 0}, {1.5, 0}], 
            Text["x", {1. , 0, 0}, {\(-1.5\), 0}], 
            Text["y", {0. , 1. , 0}, {1.5, 0}]}}, 
        ViewPoint -> {0, 0, 4}, ViewVertical -> {0, 1, 0}, 
        SphericalRegion -> True, 
        PlotRange -> {{\(-0.9\),  .9}, {\(- .9\),  .9}, {\(-0.1\), 
              0.1}}, Boxed -> False, Axes -> False, 
        Ticks -> Automatic, Lighting -> False, 
        AxesLabel -> {"x", "y", "z"}, 
        TextStyle -> newTextStyle]\)

Show[
      chap6fig4 //. 
        Join[independentVariables, dependentVariables]]

SetDirectory["/Users/martin/Desktop/mmasources"]

WriteLiveForm["chap6fig4.m", chap6fig4]

WriteHtmlPage["chap6fig4.html", "<FONT SIZE=+2><B>Figure 6.4</B> \
[Farin 2002, page 88]</FONT>",  "chap6fig4.m", 800, 500, 
      independentVariables,  
      dependentVariables, "<PARAM NAME=BGCOLOR VALUE=#FFFFFF>\n<PARAM NAME=\
\"MOUSE_DRAG_ACTION\" VALUE=\"NONE\">\n<PARAM NAME=\"POINT_EDGE_COLOR\" \
VALUE=#000000>\n"]

Figures for Chapter 7

Figure 7.1, page 96

Input: points p0, p1, p2, p3

Interaction: 
— free movement of p0, p1, p2, p3

Output: 
— computation of curves p01, p11, p21, p02, p12, p03

SetDirectory["/Users/martin/Desktop/mmasources"]

ClearAll[b, t, p]

defineVector[{"p0", "p1", "p2", "p3"}]

ts[i_] := i/3. ;

p[t_, i_, 
        1] := (ts[i + 1] - t)/(ts[i + 1] - ts[i]) Symbol["p" <> 
              ToString[i]] + (t - ts[i])/(ts[i + 1] - 
                ts[i]) Symbol["p" <> ToString[i + 1]]

p[t_, i_, r_] := 
      Expand[(ts[i + r] - t)/(ts[i + r] - ts[i]) p[t, i, 
              r - 1] + (t - ts[i])/(ts[i + r] - ts[i]) p[t, i + 1, 
              r - 1]]

iMax = 32; 
ppoints02 = 
      Table[{0, 0, -0.001} + p[i/iMax + 0.0000001, 0, 2], {i, 0, 
          iMax}]; 
ppoints12 = 
      Table[{0, 0, -0.001} + p[i/iMax + 0.0000001, 1, 2], {i, 0, 
          iMax}]; 
ppoints03 = 
      Table[{0, 0, -0.001} + p[i/iMax + 0.0000001, 0, 3], {i, 0, 
          iMax}];

independentVariables = 
      Flatten[{independentVariablesForVector["p0", {0.1, 0.1, 0}], 
          independentVariablesForVector["p1", {0.3, 0.3, 0}], 
          independentVariablesForVector["p2", {0.6, 0.3, 0}], 
          independentVariablesForVector["p3", {0.9, 0.8, 0}]}]

dependentVariables = Flatten[{}]

chap7fig1 := 
      Graphics3D[{{PointSize[0.04], RGBColor[0. , 1, 0. ], Point[p0], 
            Point[p1], Point[p2], Point[p3]}, {PointSize[0.02], 
            GrayLevel[0]}, {Thickness[0.01], GrayLevel[0], 
            Line[ppoints03]}, {Thickness[0.005], GrayLevel[0], 
            Line[ppoints02], 
            Line[ppoints12]}, {Text[bfpi["0"], p0, {1.3, 1.5}], 
            Text[bfpi["1"], p1, {-0.5, -1.7}], 
            Text[bfpi["2"], p2, {0, 1.7}], 
            Text[bfpi["3"], p3, {-1.1, -1.5}], 
            Text[bfpir["0", "2"], Last[ppoints02], {-1.1, 1.5}], 
            Text[bfpir["1", "2"], First[ppoints12], {1.1, -1.5}], 
            Text[bfpir["0", "3"], 
              ppoints03[[Round[iMax*0.9]]], {-1.5, 0}]}}, 
        ViewPoint -> {0, 0, 4}, ViewVertical -> {0, 1, 0}, 
        SphericalRegion -> True, 
        PlotRange -> {{0, 1. }, {0.1, 0.9}, {-0.1, 0.1}}, 
        Boxed -> False, Axes -> False, Ticks -> Automatic, 
        Lighting -> False, 
        AxesLabel -> {"x", "y", "z"}, 
        TextStyle -> newTextStyle]

Show[
      chap7fig1 //. 
        Join[independentVariables, dependentVariables]]

SetDirectory["/Users/martin/Desktop/mmasources"]

WriteLiveForm["chap7fig1.m", chap7fig1]

WriteHtmlPage["chap7fig1.html", "<FONT SIZE=+2><B>Figure 7.1</B> \
[Farin 2002, page 96]</FONT>",  "chap7fig1.m", 800, 500, 
      independentVariables,  
      dependentVariables, "<PARAM NAME=BGCOLOR VALUE=#FFFFFF>\n<PARAM NAME=\
\"POINT_EDGE_COLOR\" VALUE=#000000>\n"]

Figure 7.2, page 97

Input: points p0, p1, p2

Interaction: 
— free movement of b0, b1, b2, b3
— movement of a and b on axis between 0 and 1

Output: 
— lines, interpolated points, mapping arrow

SetDirectory["/Users/martin/Desktop/mmasources"]

<< Arrow3D`

ClearAll[b, c, t, t0, t1, t2, ts, p]

\(defineVector[{"p0", "p1", "p2", "p01", "p02", \ "p11"}]\)

ts[i_] := Symbol["t" <> ToString[i]];

p[t_, i_, 
        1] := (ts[i + 1] - t)/(ts[i + 1] - ts[i]) Symbol["p" <> 
              ToString[i]] + (t - ts[i])/(ts[i + 1] - 
                ts[i]) Symbol["p" <> ToString[i + 1]]

p[t_, i_, r_] := 
      Expand[(ts[i + r] - t)/(ts[i + r] - ts[i]) p[t, i, 
              r - 1] + (t - ts[i])/(ts[i + r] - ts[i]) p[t, i + 1, 
              r - 1]]

iMax = 32; 
ppoints = 
      Table[{0, 0, -0.001} + 
          p[ts[0] + (ts[2] - ts[0]) i/iMax + 0.0000001, 0, 2], {i, 0, 
          iMax}];

independentVariables = 
      Flatten[{independentVariablesForVector["p0", {-0.5, 0.1, 0}], 
          independentVariablesForVector["p1", {-0.05, 1.0, 0}], 
          independentVariablesForVector["p2", {1.5, 0.5, 0}], 
          t -> 0.3, t0 -> 0, t1 -> 0.5, 
          t2 -> 1. }]

dependentVariables = 
      Flatten[{dependentVariablesForVector["p01", p[t, 0, 1]], 
          dependentVariablesForVector["p11", p[t, 1, 1]], 
          dependentVariablesForVector["p02", p[t, 0, 2]]}];

chap7fig2 := 
      Graphics3D[{{PointSize[0.04], RGBColor[0. , 1, 0. ], 
            Point[p0 + {0, 0, 0.01}], Point[p1 + {0, 0, 0.01}], 
            Point[p2 + {0, 0, 0.01}], Point[{t0, 0, 0.01}], 
            Point[{t1, 0, 0.01}], Point[{t2, 0, 0.01}], 
            Point[{t, 0, 0.01}]}, {Thickness[0.005], GrayLevel[0], 
            Line[{p0, p01, p1}], Line[{p1, p11, p2}], Line[{p01, p02, p11}], 
            Line[{{Min[0, t, t0, t1, t2], 0, 0}, {Max[1, t, t0, t1, t2], 0, 
                  0}}]}, 
{PointSize[0.02], GrayLevel[0], 
            Point[p11], Point[p01], Point[p02]}, {Thickness[0.01], 
            GrayLevel[0], Line[ppoints]}, {EdgeForm[], GrayLevel[0.6], 
            Thickness[0.03], 
            Arrow3D[0.8*{t, 0.0, -0.01} + 0.2*p02, 
              0.4*{t, 0.0, -0.01} + 0.6*p02, HeadLength -> 0.2, 
              HeadWidth -> 1]}, {Text[bfpi["0"], p0, {1.3, 1.3}], 
            Text[bfpi["1"], p1, {-1.3, -1.3}], 
            Text[bfpi["2"], p2, {-1.3, 1.3}], 
            Text[bfpir["0", "1"], p01, {-1.3, 0}], 
            Text[bfpir["1", "1"], p11, {1.5, -1.3}], 
            Text[bfpir["0", "2"], p02, {2. , 0}], 
            Text[itti["0"], {t0, 0, 0}, {0, 1.3}], 
            Text[itti["1"], {t1, 0, 0}, {0, 1.3}], 
            Text[itti["2"], {t2, 0, 0}, {0, 1.3}], 
            Text[itt, {t, 0, 0}, {0, 1.3}]}}, ViewPoint -> {0, 0, 4}, 
        ViewVertical -> {0, 1, 0}, SphericalRegion -> True, 
        PlotRange -> {{- .5, 1.5}, {-0.2, 1.2}, {-0.1, 
              0.1}}, Boxed -> False, Axes -> False, 
        Ticks -> Automatic, Lighting -> False, 
        AxesLabel -> {"x", "y", "z"}, 
        TextStyle -> newTextStyle]

Show[
      chap7fig2 //. 
        Join[independentVariables, dependentVariables]]

SetDirectory["/Users/martin/Desktop/mmasources"]

WriteLiveForm["chap7fig2.m", chap7fig2]

WriteHtmlPage["chap7fig2.html", "<FONT SIZE=+2><B>Figure 7.2</B> \
[Farin 2002, page 97]</FONT>",  "chap7fig2.m", 800, 500, 
      independentVariables,  
      dependentVariables, "<PARAM NAME=BGCOLOR VALUE=#FFFFFF>\n<PARAM NAME=\
\"MOUSE_DRAG_ACTION\" VALUE=\"NONE\">\n<PARAM NAME=\"POINT_EDGE_COLOR\" \
VALUE=#000000>\n"]

Figure 7.4, page 103

Input: points p0, p1, pm0, pm1

Interaction: 
— free movement of p0, p1, pm0, pm1
— if p0 is moved, move pm0 by the same vector
— if p1 is moved, move pm1 by the same vector

Output: 
— points p0, p1, arrows from p0 to pm0, p1 to pm1
— bezier control points b1, b2
— bezier curve, control polygon

SetDirectory["/Users/martin/Desktop/mmasources"]

<< Arrow3D`

SetOptions[Arrow3D, HeadLength -> 0.1];

ClearAll[b, t]

defineVector[{"p0", "p1", "pm0", "pm1", "b0", "b1\
", "b2", "b3"}]

bernstein[i_, n_, t_] := 
      Binomial[n, i] t^i (1 - t)^(n - i)

b[t_] := 
      Sum[bernstein[i, 3, t]*Symbol["b" <> ToString[i]], {i, 0, 
          3}];

iMax = 64; 
bpoints = 
      Table[{0, 0, -0.001} + b[i/iMax + 0.0000001], {i, 0, 
          iMax}];

independentVariables = 
      Flatten[{independentVariablesForVector["p0", {1. , 0.8, 0}], 
          independentVariablesForVector["pm0", {0.2, 0.8, 0}], 
          independentVariablesForVector["p1", {0.5, 0.5, 0}], 
          independentVariablesForVector["pm1", {0.1, 0.3, 
              0}]}]

\(dependentVariables = 
      Flatten[{dependentVariablesForVectorProlog["p0"], 
          dependentVariablesForVectorProlog["p1"], 
dependentVariablesForReassignmentOfVector["pm0", "p0", pm0 - {p0xOld, p0yOld, p0zOld} + p0], 
          dependentVariablesForReassignmentOfVector["pm1", "p1", 
            pm1 - {p1xOld, p1yOld, p1zOld} + 
              p1], 
dependentVariablesForVector["b0", 
            p0], dependentVariablesForVector["b1", 
            p0 + \((pm0 - p0)\)/3], 
          dependentVariablesForVector["b2", p1 - \((pm1 - p1)\)/3], 
          dependentVariablesForVector["b3", 
            p1], 
dependentVariablesForVectorEpilog["p0"], dependentVariablesForVectorEpilog["p1"]}]\)

chap7fig4 := 
      Graphics3D[{{PointSize[0.04], RGBColor[0. , 1, 0. ], Point[p0], 
            Point[p1], PointSize[0.04], Point[pm0], 
            Point[pm1]}, {PointSize[0.02], GrayLevel[0], Point[b1], 
            Point[b2]}, {Thickness[0.01], GrayLevel[0], 
            Line[bpoints]}, {Thickness[0.005], GrayLevel[0], 
            Line[{b0 - {0, 0, 0.001}, b1 - {0, 0, 0.001}, b2 - {0, 0, 0.001}, 
                b3 - {0, 0, 0.001}}]}, {Thickness[0.01], GrayLevel[0], 
            EdgeForm[], 
            Arrow3D[p0 + {0, 0, -0.01}, pm0 + {0, 0, -0.01}], 
            Arrow3D[p1 + {0, 0, -0.01}, pm1 + {0, 0, -0.01}]}, {Text[
              bfpi["0"], p0, {-1.3, -1.5}], 
            Text[bfpi["1"], p1, {-1.2, 1.5}], 
            Text[bfmi["0"], (0.4  p0 + 0.6  pm0), {0, -1.5}], 
            Text[bfmi["1"], (0.5  p1 + 0.5  pm1), {-1.1, 1.5}]}}, 
        ViewPoint -> {0, 0, 4}, ViewVertical -> {0, 1, 0}, 
        SphericalRegion -> True, 
        PlotRange -> {{0.1, 0.9}, {0.2, 0.8}, {-0.1, 0.1}}, 
        Boxed -> False, Axes -> False, Ticks -> Automatic, 
        Lighting -> False, 
        AxesLabel -> {"x", "y", "z"}, 
        TextStyle -> newTextStyle]

Show[
      chap7fig4 //. 
        Join[independentVariables, dependentVariables]]

SetDirectory["/Users/martin/Desktop/mmasources"]

WriteLiveForm["chap7fig4.m", chap7fig4]

WriteHtmlPage["chap7fig4.html", "<FONT SIZE=+2><B>variation of \
Figure 7.4</B> [Farin 2002, page 103]</FONT>",  "chap7fig4.m", 800, 
      500, independentVariables,  
      dependentVariables, "<PARAM NAME=BGCOLOR VALUE=#FFFFFF>\n<PARAM NAME=\
\"POINT_EDGE_COLOR\" VALUE=#000000>\n"]

Figure 7.5, page 104

Input: coordinate t

Interaction: 
— move t at discreet values 1/8(3, 5)

Output: 
— n = t/8
— coordinate system, Bernstein polynomials for n

SetDirectory["/Users/martin/Desktop/mmasources"]

<< Arrow3D`

ClearAll[b, t]

bernstein[i_, n_, t_] := 
      N[Binomial[n, i] 
          t^i (1 - t)^(n - i)]; 
hermite[i_, n_, t_] := 
      If[n == 3, 
        Evaluate[
          Which[i == 0, bernstein[0, 3, t] + bernstein[1, 3, t], 
            i == 1, 1/3  bernstein[1, 3, t], 
            i == 2, -1/3 bernstein[2, 3, t], i == 3, 
            bernstein[2, 3, t] + bernstein[3, 3, t], True, 0]], 
        Evaluate[
          Which[i == 0, 
            bernstein[0, 5, t] + bernstein[1, 5, t] + bernstein[2, 5, t], 
            i == 1, 
            1/5 (bernstein[1, 5, t] + 2 bernstein[2, 5, t]), 
            i == 2, 1/20  bernstein[2, 5, t], i == 3, 
            1/20  bernstein[3, 5, t], 
            i == 
              4, -1/5 (2 bernstein[3, 5, t] + bernstein[4, 5, t]), 
            i == 5, 
            bernstein[3, 5, t] + bernstein[4, 5, t] + bernstein[5, 5, t], 
            True, 0]]];

iMax = 32; 
h3points = 
      Table[{i/iMax, hermite[j, 3, (1 - 10^-20) i/iMax + 10^-30], 
          0}, {j, 0, 3}, {i, 0, iMax}]; 
h5points = 
      Table[{i/iMax, hermite[j, 5, (1 - 10^-20) i/iMax + 10^-30], 
          0}, {j, 0, 5}, {i, 0, iMax}];

independentVariables = Flatten[{t -> 3/8. }]

dependentVariables = 
      Flatten[{t -> If[t > 4/8. , 5/8, 3/8], 
          n -> Round[t*8. ]}]

ytaxis = -0.4;

chap7fig5 := 
      Graphics3D[{{PointSize[0.04], RGBColor[0. , 1, 0. ], 
            Point[{t, ytaxis, 0.01}]}, {Thickness[0.005], GrayLevel[0], 
            Line[{{0, 0, 0}, {1, 0, 0}, {1, 1, 0}, {0, 1, 0}, {0, 0, 
                  0}}]}, 
{PointSize[0.02], GrayLevel[0], 
            Point[{0, 0, 0}], Point[{1, 0, 0}], Point[{0, 1, 0}], 
            Point[{1, 1, 0}], 
            Table[Point[{i/8. , ytaxis, 0}], {i, 3, 5, 2}]}, {Thickness[
              0.005], GrayLevel[0], 
            Line[{{0, ytaxis, 0}, {1, ytaxis, 0}}]}, {Thickness[0.01], 
            GrayLevel[0], 
            If[n == 3, 
              Evaluate[
                Table[Line[h3points[[i + 1]]], {i, 0, 3}]], 
              Evaluate[
                Table[Line[h5points[[i + 1]]], {i, 0, 
                    5}]]]}, {Text[itn, {0, ytaxis, 0}, {2, 0}], 
            Text[itt, {0.3, 0, 0}, {0, 1.5}], 
            Text[itHinu[symbolItalic["i"], itn, 
                symbolItalic["t"]], {0. , 0.5, 0}, {1.1, 0}], 
            dummyIf[n ≠ 
                3, {}, {Text[
                  itHin["3", "3"], {1. , 0.8, 0}, {1.5, 1. }], 
                Text[itHin["0", "3"], {0.0, 0.8, 0}, {-1.8, 
                    1. }], Text[
                  itHin["1", "3"], {0.0, 0.2, 
                    0}, {-1.8, -1. }], 
                Text[itHin["2", "3"], {1. , -0.1, 0}, {1.5, 
                    1.3}]}], Text["0", {0, 0, 0}, {0, 1.5}], 
            Text["0", {0, 0, 0}, {1.5, 0}], 
            Text["1", {1, 0, 0}, {0, 1.5}], 
            Text["1", {0, 1, 0}, {1.5, 0}], 
            Table[Text[ToString[i], {i/8, ytaxis, 0}, {0, 1.5}], {i, 3, 5, 
                2}]}}, ViewPoint -> {0, 0, 4}, 
        ViewVertical -> {0, 1, 0}, SphericalRegion -> True, 
        PlotRange -> {{- .1, 1.0}, {-0.5, 1.0}, {-0.1, 
              0.1}}, Boxed -> False, Axes -> False, 
        Ticks -> Automatic, Lighting -> False, 
        AxesLabel -> {"x", "y", "z"}, 
        TextStyle -> newTextStyle]

Show[chap7fig5 /. dummyIf -> If //. 
        Join[independentVariables, dependentVariables]]

SetDirectory["/Users/martin/Desktop/mmasources"]

WriteLiveForm["chap7fig5.m", 
      chap7fig5 /. dummyIf -> If]

WriteHtmlPage["chap7fig5.html", "<FONT SIZE=+2><B>Figure 7.5</B> \
[Farin 2002, page 104]</FONT>",  "chap7fig5.m", 800, 500, 
      independentVariables,  
      dependentVariables, "<PARAM NAME=BGCOLOR VALUE=#FFFFFF>\n<PARAM NAME=\
\"MOUSE_DRAG_ACTION\" VALUE=\"NONE\">\n<PARAM NAME=\"POINT_EDGE_COLOR\" \
VALUE=#000000>\n"]

Figure 7.7, page 109

Input: 10 3D points p0, p1, p2, p3, p4, p5, p6, p7, p8, p9

Interaction: 
— any movement of p's  in 3D

Output: 
—bezier control polygon

SetDirectory["/Users/martin/Desktop/mmasources"]

\(defineVector[{"p0", "p1", "p2", "p3", "p4", "p5", "p6", "p7", "p8", "p9", "b0", "b1", "b2", "b3", "b4", "b5"}]; \)

independentVariables = 
      Flatten[Table[
          independentVariablesForVector["p" <> 
              ToString[i], (0.25 + 0.01  Random[])*{2*Cos[i/10. *2 Pi], 
                Sin[i/10. *2 Pi], 0}], {i, 0, 9}]]

bernstein[i_, n_, t_] := 
      Binomial[n, i] t^i (1 - t)^(n - i);

b[t_] := 
      Sum[bernstein[i, 5, t]*Symbol["b" <> ToString[i]], {i, 0, 
          5}];

iMax = 64; 
bpoints = 
      Table[{0, 0, -0.001} + b[i/iMax + 0.0000001], {i, 0, 
          iMax}];

ts = Table[i/10. , {i, 0, 9}]; 
pMatrix = {p0, p1, p2, p3, p4, p5, p6, p7, p8, 
        p9}; 
mMatrix = 
      Table[bernstein[i, 5, ts[[j + 1]] + 0.0000001], {j, 0, 
          9}, {i, 0, 5}]; 
iMatrix = 
      Inverse[Transpose[mMatrix] . mMatrix] . 
        Transpose[mMatrix];

dependentVariables = 
      Flatten[{dependentVariablesForVector["b0", (iMatrix . 
                  pMatrix)[[1]]], 
          dependentVariablesForVector["b1", (iMatrix . 
                  pMatrix)[[2]]], 
          dependentVariablesForVector["b2", (iMatrix . 
                  pMatrix)[[3]]], 
          dependentVariablesForVector["b3", (iMatrix . 
                  pMatrix)[[4]]], 
          dependentVariablesForVector["b4", (iMatrix . 
                  pMatrix)[[5]]], 
          dependentVariablesForVector["b5", (iMatrix . 
                  pMatrix)[[6]]]}];

SetOptions[Arrow3D,  HeadLength -> 0.3];

chap7fig7 := 
      Graphics3D[{{PointSize[0.04], RGBColor[0. , 1, 0. ], 
            Table[Point[Symbol["p" <> ToString[i]]], {i, 0, 
                9}]}, {GrayLevel[0], PointSize[0.02], Point[b0], Point[b1], 
            Point[b1], Point[b2], Point[b3], Point[b4], 
            Point[b5]}, {Thickness[0.01], GrayLevel[0], 
            Line[bpoints]}, {Thickness[0.005], GrayLevel[0], 
            Line[{b0, b1, b2, b3, b4, b5}]}}, ViewPoint -> {0, 0, 4}, 
        ViewVertical -> {0, 1, 0}, SphericalRegion -> True, 
        PlotRange -> {{-1. , 1. }, {-1. , 1. }, {-0.1, 
              0.1}}, Boxed -> False, Axes -> False, 
        Ticks -> Automatic, Lighting -> False, 
        AxesLabel -> {"x", "y", "z"}, 
        TextStyle -> newTextStyle]

Show[
      chap7fig7 //. 
        Join[independentVariables, dependentVariables]]

SetDirectory["/Users/martin/Desktop/mmasources"]

WriteLiveForm["chap7fig7.m", chap7fig7]

WriteHtmlPage["chap7fig7.html", "<FONT SIZE=+2><B>Figure 7.7</B> \
[Farin 2002, page 109]</FONT>",  "chap7fig7.m", 800, 500, 
      independentVariables,  
      dependentVariables, "<PARAM NAME=BGCOLOR VALUE=#FFFFFF>\n<PARAM NAME=\
\"POINT_EDGE_COLOR\" VALUE=#000000>\n"]

Figure 7.10, page 114

Input: 4 3d points b0, b1, b2, b3, x

Interaction: 
— any movement of b's  in 3D

Output: 
—bezier control polygon

SetDirectory["/Users/martin/Desktop/mmasources"]

ClearAll[b]

\(defineVector[{"b0", "b1", "b2", "b3", "x", "y"}]; \)

independentVariables = 
      Flatten[{independentVariablesForVector["b0", {0, 0.2, 0.0}], 
          independentVariablesForVector["b1", {0.1, 0.8, 0.0}], 
          independentVariablesForVector["b2", {0.5, 0.8, 0.0}], 
          independentVariablesForVector["b3", {1. , 0.6, 0.0}], 
          independentVariablesForVector["y", {0.3, 0.7, 
              0. }]}]

bernstein[i_, n_, t_] := 
      Binomial[n, i] t^i (1 - t)^(n - i);

b[t_] := 
      Sum[bernstein[i, 3, t]*Symbol["b" <> ToString[i]], {i, 0, 
          3}];

iMax = 64; 
bpoints = 
      Table[{0, 0, -0.001} + b[i/iMax + 0.0000001], {i, 0, 
          iMax}];

myt = 0.5; 
aVector = 
      Table[bernstein[i, 3, myt], {i, 1, 2}]; 
zVector = 
      y - b0 bernstein[0, 3, myt] - 
        b3 bernstein[3, 3, myt]; 
bMatrix = {b1, b2}; 
bNewMatrix = 
      bMatrix + (aVector . aVector) 
          Transpose[{aVector}] . {(y - x)}

\(dependentVariables = 
      Flatten[{
dependentVariablesForVectorProlog["y"], 
dependentVariablesForVector["x", {yxOld, yyOld, 
              yzOld}], 
dependentVariablesForReassignmentOfVector["b1", "y", bNewMatrix[\([\)\(1\)\(]\)]], 
dependentVariablesForReassignmentOfVector["b2", "y", bNewMatrix[\([\)\(2\)\(]\)]], 
dependentVariablesForVector["y", 
            b[myt]], 
dependentVariablesForVectorEpilog["y"]}]\)

chap7fig10 := 
      Graphics3D[{{PointSize[0.04], RGBColor[0. , 1, 0. ], Point[b0], 
            Point[b1], Point[b2], Point[b3], Point[y]}, {Thickness[0.01], 
            GrayLevel[0], Line[bpoints]}, {Thickness[0.005], GrayLevel[0], 
            Line[{b0, b1, b2, b3}]}}, ViewPoint -> {0, 0, 4}, 
        ViewVertical -> {0, 1, 0}, SphericalRegion -> True, 
        PlotRange -> {{0. , 0.9}, {0.2, 0.8}, {-0.1, 0.1}}, 
        Boxed -> False, Axes -> False, Ticks -> Automatic, 
        Lighting -> False, 
        AxesLabel -> {"x", "y", "z"}, 
        TextStyle -> newTextStyle]

Show[
      chap7fig10 //. 
        Join[independentVariables, dependentVariables]]

SetDirectory["/Users/martin/Desktop/mmasources"]

WriteLiveForm["chap7fig10.m", chap7fig10]

WriteHtmlPage["chap7fig10.html", "<FONT SIZE=+2><B>Figure \
7.10</B> [Farin 2002, page 114]</FONT>",  "chap7fig10.m", 800, 500, 
      independentVariables,  
      dependentVariables, "<PARAM NAME=BGCOLOR VALUE=#FFFFFF>\n<PARAM NAME=\
\"MOUSE_DRAG_ACTION\" VALUE=\"NONE\">\n<PARAM NAME=\"POINT_EDGE_COLOR\" \
VALUE=#000000>\n"]

Figures for Chapter 8

Figure 8.1, page 122

Input: points b01, b12, b23, coordinates u0, u1, u2, u3, u

Interaction: 
— free movement of b01, b12, b23
— movement of u0, u1, u2, u3, u

Output: 
— lines, interpolated points, mapping arrow

SetDirectory["/Users/martin/Desktop/mmasources"]

<< Arrow3D`

ClearAll[u, t, u0, u1, u2, u3, u4, u5, u6, u7, u8, u9, b, b1, b2, b01, 
      b12, b23]; 
\(defineVector[{"b01", "b12", "b23", "bu1", "buu", "bu2"}]\)

b1[t_] = 
      Together[(u2 - t)/(u2 - u0)*b01 + (t - u0)/(u2 - u0)*
            b12]; 
b2[t_] = 
      Together[(u3 - t)/(u3 - u1)*b12 + (t - u1)/(u3 - u1)*
            b23]; 
b[t_] = 
      Together[(u2 - t)/(u2 - u1)*b1[t] + (t - u1)/(u2 - u1)*
            b2[t]];

iMax = 64; 
bpoints = 
      Table[b[N[u1 + (u2 - u1) i/iMax]] + {0, 0, -0.001}, {i, 0, 
          iMax}];

independentVariables = 
      Flatten[{independentVariablesForVector["b01", {-0.4, 0.7, 0}], 
          independentVariablesForVector["b12", {2. , 2. , 0}], 
          independentVariablesForVector["b23", {3.6, 0.7, 0}], 
          u0 -> 0. , u1 -> 1. , u2 -> 2. , u3 -> 3. , 
          u -> 1.5}]

\(dependentVariables = 
      Flatten[{u3 -> If[u3 < u2, u2, u3], u0 -> If[u0 > u1, u1, u0], 
          u2 -> If[u2 > u3, u3, If[u2 < u, u, u2]], 
          u1 -> If[u1 < u0, u0, If[u1 > u, u, u1]], 
          u -> 
            If[u > u2, u2, 
              If[u < u1, u1, 
                u]], 
dependentVariablesForVector["bu1", b1[u]], dependentVariablesForVector["bu2", b2[u]], 
          dependentVariablesForVector["buu", b[u]]}]\)

\(chap8fig1 := 
      Graphics3D[{{PointSize[0.04], RGBColor[0. , 1, 0. ], Point[b01], 
            Point[b12], Point[b23], Point[{u0, 0, 0}], Point[{u1, 0, 0}], 
            Point[{u2, 0, 0}], Point[{u3, 0, 0}], 
            Point[{u, 0, 0}]}, {Thickness[0.0025], GrayLevel[0], 
            Line[{b01 + {0, 0, \(-0.001\)}, b12 + {0, 0, \(-0.001\)}, 
                b23 + {0, 0, \(-0.001\)}}], 
            Line[{bu1 + {0, 0, \(-0.001\)}, bu2 + {0, \(-0\), 0.001}}], 
            Thickness[0.005], 
            Line[{{u0, 0, \(-0.001\)}, {u3, 0, \(-0.001\)}}], 
            Line[{{u0, \(-0.7\), \(-0.001\)}, {u2, \(-0.7\), \(-0.001\)}}], 
            Line[{{u1, \(-0.8\), \(-0.001\)}, {u3, \(-0.8\), \(-0.001\)}}], 
            Line[{{u1, \(-0.9\), \(-0.001\)}, {u2, \(-0.9\), \(-0.001\)}}]}, 
{GrayLevel[0], PointSize[0.02], Point[bu1], Point[bu2], 
            Point[buu]}, {Thickness[0.01], GrayLevel[0], 
            Line[bpoints]}, {EdgeForm[], GrayLevel[0.6], Thickness[0.03], 
            Arrow3D[0.8*{u, 0.0, \(-0.01\)} + 0.2*buu, 
              0.4*{u, 0.0, \(-0.01\)} + 0.6*buu, HeadLength -> 0.3, 
              HeadWidth -> 1]}, {Text[
              itUin["1", "2"], {u0, \(-0.7\), 0}, {1.2, 
                2. }], 
Text[
              itUin["2", "2"], {u3, \(-0.8\), 0}, {\(-1.2\), 2. }], 
            Text[itUin["1", "1"], {\((u1 + u2)\)/2, \(-0.9\), 0}, {0, 
                2. }], Text[itui["0"], {u0, 0, 0}, {0, 1.5}], 
            Text[itui["1"], {u1, 0, 0}, {0, 1.5}], 
            Text[itui["2"], {u2, 0, 0}, {0, 1.5}], 
            Text[itui["3"], {u3, 0, 0}, {0, 1.5}], 
            Text[itu, {u, 0, 0}, {0, 1.5}], 
            Text[StringForm["````````````", bfb, "[", 
                itui["0"], ",", itui["1"], "]"], 
              b01, {0, 1.5}], 
            Text[StringForm["````````````", bfb, "[", 
                itui["1"], ",", itui["2"], "]"], 
              b12, {0, \(-1.8\)}], 
            Text[StringForm["````````````", bfb, "[", 
                itui["2"], ",", itui["3"], "]"], 
              b23, {0, 1.5}], 
            Text[StringForm["````````````", bfb, "[", itu, ",", 
                itui["1"], "]"], bu1, {1.2, \(-1.1\)}], 
            Text[StringForm["````````````", bfb, "[", itu, ",", 
                itui["2"], "]"], bu2, {\(-1.2\), \(-1.1\)}], 
            Text[StringForm["````````````", bfb, "[", itu, ",", 
                itu, "]"], buu, {0. , 1.9}]}}, 
        ViewPoint -> {0, 0, 4}, ViewVertical -> {0, 1, 0}, 
        SphericalRegion -> True, 
        PlotRange -> {{0.1, 2.9}, {\(-1.4\), 2.3}, {\(-0.1\), 0.1}}, 
        Boxed -> False, Axes -> False, Ticks -> Automatic, 
        Lighting -> False, 
        AxesLabel -> {"x", "y", "z"}, 
        TextStyle -> newTextStyle]\)

Show[
      chap8fig1 //. 
        Join[independentVariables, dependentVariables]]

SetDirectory["/Users/martin/Desktop/mmasources"]

WriteLiveForm["chap8fig1.m", chap8fig1]

WriteHtmlPage["chap8fig1.html", "<FONT SIZE=+2><B>Figure 8.1</B> \
[Farin 2002, page 122]</FONT>",  "chap8fig1.m", 800, 500, 
      independentVariables,  
      dependentVariables, "<PARAM NAME=BGCOLOR VALUE=#FFFFFF>\n<PARAM NAME=\
\"MOUSE_DRAG_ACTION\" VALUE=\"NONE\">\n<PARAM NAME=\"POINT_EDGE_COLOR\" \
VALUE=#000000>\n"]

Figure 8.2, page 125

Input: points b012, b123, b234, b345 coordinates u0, u1, u2, u3, u4, u5, u

Interaction: 
— free movement of b012, b123, b234, b345
— movement of u0, u1, u2, u3, u4, u5, u

Output: 
— lines, interpolated points, mapping arrow

SetDirectory["/Users/martin/Desktop/mmasources"]

<< Arrow3D`

ClearAll[b, b1, b2, b3, b12, b23, b34]; 
\(defineVector[{"b012", "b123", "b234", "b345", "bu12", "bu23", "bu34", "buu2", "buu3", "buuu"}]\)

b12[t_] = 
      Together[(u3 - t)/(u3 - u0)*b012 + (t - u0)/(u3 - u0)*
            b123]; 
b23[t_] = 
      Together[(u4 - t)/(u4 - u1)*b123 + (t - u1)/(u4 - u1)*
            b234]; 
b34[t_] = 
      Together[(u5 - t)/(u5 - u2)*b234 + (t - u2)/(u5 - u2)*
            b345]; 
b2[t_] = 
      Together[(u3 - t)/(u3 - u1)*b12[t] + (t - u1)/(u3 - u1)*
            b23[t]]; 
b3[t_] = 
      Together[(u4 - t)/(u4 - u2)*b23[t] + (t - u2)/(u4 - u2)*
            b34[t]]; 
b[t_] = 
      Together[(u3 - t)/(u3 - u2)*b2[t] + (t - u2)/(u3 - u2)*
            b3[t]];

iMax = 16; 
bpoints = 
      Table[b[N[u2 + (u3 - u2) i/iMax]] + {0, 0, -0.001}, {i, 0, 
          iMax}];

independentVariables = 
      Flatten[{independentVariablesForVector["b012", {-0.4, 1.5, 0}], 
          independentVariablesForVector["b123", {0.5, 3. , 0}], 
          independentVariablesForVector["b234", {4.5, 3. , 0}], 
          independentVariablesForVector["b345", {5.6, 1.5, 0}], 
          u0 -> 0. , u1 -> 1. , u2 -> 2. , u3 -> 3. , 
          u4 -> 4. , u5 -> 5, u -> 2.5}]

dependentVariables = 
      Flatten[{
dependentVariablesForVector["bu12", 
            b12[u]], dependentVariablesForVector["bu23", b23[u]], 
          dependentVariablesForVector["bu34", b34[u]], 
          dependentVariablesForVector["buu2", b2[u]], 
          dependentVariablesForVector["buu3", b3[u]], 
          dependentVariablesForVector["buuu", b[u]]}];

\(chap8fig2 := 
      Graphics3D[{{PointSize[0.04], RGBColor[0. , 1, 0. ], Point[b012], 
            Point[b123], Point[b234], Point[b345], Point[{u0, 0, 0}], 
            Point[{u1, 0, 0}], Point[{u2, 0, 0.001}], Point[{u3, 0, 0.001}], 
            Point[{u4, 0, 0}], Point[{u5, 0, 0}], 
            Point[{u, 0, 0.002}]}, {Thickness[0.005], GrayLevel[0], 
            Line[{b012 + {0, 0, \(-0.001\)}, b123 + {0, 0, \(-0.001\)}, 
                b234 + {0, 0, \(-0.001\)}, b345 + {0, 0, \(-0.001\)}}], 
            Thickness[0.0025], 
            Line[{bu12 + {0, 0, \(-0.001\)}, bu23 + {0, \(-0\), 0.001}, 
                bu34 + {0, \(-0\), 0.001}}], 
            Line[{buu2 + {0, 0, \(-0.001\)}, buu3 + {0, \(-0\), 0.001}}], 
            Thickness[0.005], 
            Line[{{u0, 0, \(-0.001\)}, {u5, 0, \(-0.001\)}}], 
            Line[{{u0, \(-1.1\), \(-0.001\)}, {u3, \(-1.1\), \(-0.001\)}}], 
            Line[{{u1, \(-1.2\), \(-0.001\)}, {u4, \(-1.2\), \(-0.001\)}}], 
            Line[{{u2, \(-1.3\), \(-0.001\)}, {u5, \(-1.3\), \(-0.001\)}}], 
            Line[{{u1, \(-1.4\), \(-0.001\)}, {u3, \(-1.4\), \(-0.001\)}}], 
            Line[{{u2, \(-1.5\), \(-0.001\)}, {u4, \(-1.5\), \(-0.001\)}}], 
            Line[{{u2, \(-1.6\), \(-0.001\)}, {u3, \(-1.6\), \(-0.001\)}}]}, 
{GrayLevel[0], PointSize[0.02], Point[bu12], Point[bu23], 
            Point[bu34], Point[buu2], Point[buu3], 
            Point[buuu]}, {Thickness[0.01], GrayLevel[0], 
            Line[bpoints]}, {EdgeForm[], GrayLevel[0.6], Thickness[0.03], 
            Arrow3D[0.8*{u, 0.0, \(-0.01\)} + 0.2*buuu, 
              0.4*{u, 0.0, \(-0.01\)} + 0.6*buuu, HeadLength -> 0.4, 
              HeadWidth -> 1]}, {Text[
              itUin["1", "3"], {u0, \(-1.1\), 0}, {1.2, 
                2. }], 
Text[
              itUin["2", "3"], {u1, \(-1.2\), 0}, {1.2, 2. }], 
            Text[itUin["3", "3"], {u5, \(-1.3\), 0}, {0, 2. }], 
            Text[itUin["1", "2"], {u1, \(-1.4\), 0}, {\(-1. \), 
                2. }], 
Text[
              itUin["2", "2"], {u4, \(-1.5\), 0}, {0, 2. }], 
            Text[itUin["1", "1"], {\((u2 + u3)\)/2, \(-1.6\), 0}, {0, 
                2. }], Text[itui["0"], {u0, 0, 0}, {0, 1.5}], 
            Text[itui["1"], {u1, 0, 0}, {0, 1.5}], 
            Text[itui["2"], {u2, 0, 0}, {0, 1.5}], 
            Text[itui["3"], {u3, 0, 0}, {0, 1.5}], 
            Text[itui["4"], {u4, 0, 0}, {0, 1.5}], 
            Text[itui["5"], {u5, 0, 0}, {0, 1.5}], 
            Text[itu, {u, 0, 0}, {0, 1.5}], 
            Text[StringForm["````````````````", bfb, "[", 
                itui["0"], ",", itui["1"], ",", 
                itui["2"], "]"], b012, {0, 1.5}], 
            Text[StringForm["````````````````", bfb, "[", 
                itui["1"], ",", itui["2"], ",", 
                itui["3"], "]"], b123, {0, \(-1.8\)}], 
            Text[StringForm["````````````````", bfb, "[", 
                itui["2"], ",", itui["3"], ",", 
                itui["4"], "]"], b234, {0, \(-1.8\)}], 
            Text[StringForm["````````````````", bfb, "[", 
                itui["3"], ",", itui["4"], ",", 
                itui["5"], "]"], b345, {0, 1.5}], 
            Text[StringForm["````````````````", bfb, "[", 
                itu, ",", itui["1"], ",", 
                itui["2"], "]"], bu12, {1.2, 0}], 
            Text[StringForm["````````````````", bfb, "[", 
                itu, ",", itui["3"], ",", 
                itui["4"], "]"], bu34, {\(-1.2\), 0}], 
            Text[StringForm["````````````````", bfb, "[", 
                itu, ",", itu, ",", itu, "]"], 
              buuu, {0. , 1.9}]}}, ViewPoint -> {0, 0, 4}, 
        ViewVertical -> {0, 1, 0}, SphericalRegion -> True, 
        PlotRange -> {{0.1, 4.9}, {\(-2.3\), 3.4}, {\(-0.1\), 0.1}}, 
        Boxed -> False, Axes -> False, Ticks -> Automatic, 
        Lighting -> False, 
        AxesLabel -> {"x", "y", "z"}, 
        TextStyle -> newTextStyle]\)

Show[
      chap8fig2 //. 
        Join[independentVariables, dependentVariables]]

SetDirectory["/Users/martin/Desktop/mmasources"]

WriteLiveForm["chap8fig2.m", chap8fig2]

WriteHtmlPage["chap8fig2.html", "<FONT SIZE=+2><B>Figure 8.2</B> \
[Farin 2002, page 125]</FONT>",  "chap8fig2.m", 800, 500, 
      independentVariables,  
      dependentVariables, "<PARAM NAME=BGCOLOR VALUE=#FFFFFF>\n<PARAM NAME=\
\"MOUSE_DRAG_ACTION\" VALUE=\"NONE\">\n<PARAM NAME=\"POINT_EDGE_COLOR\" \
VALUE=#000000>\n"]

Figure 8.3 n=2, page 128

Input: points b01, b12, b23, b34, b45, b56, b67, b78,  coordinates u0, u1, u2, u3, u4, u5, u6, u7, u8

Interaction: 
— free movement of b01, b12, b23, b34, b45, b56, b67, b78
— movement of u0, u1, u2, u3, u4, u5, u6, u7, u8

Output: 
— lines, interpolated points

SetDirectory["/Users/martin/Desktop/mmasources"]

ClearAll[b, b0, b1, b2, b3, b4, b5, b6, b7, b8, u0, u1, u2, u3, u4, u5, 
      u6, u7, u8, u9]; 
\(defineVector[{"b01", "b12", "b23", "b34", "b45", "b56", "b67", "b78", "b89", "bu1", "bu2", "bu3", "bu4", "bu5", "bu6", "bu7"}]\)

b1[i_, 
        t_] := (Symbol["u" <> ToString[i + 1]] - 
                t)/(Symbol["u" <> ToString[i + 1]] - 
                Symbol["u" <> ToString[i - 1]])*
          Symbol["b" <> ToString[i - 1] <> 
              ToString[i]] + (t - 
                Symbol["u" <> ToString[i - 1]])/(Symbol["u" <> 
                    ToString[i + 1]] - Symbol["u" <> ToString[i - 1]])*
          Symbol["b" <> ToString[i] <> 
              ToString[i + 1]]; 
b0[i_, 
        t_] := (Symbol["u" <> ToString[i + 1]] - 
                t)/(Symbol["u" <> ToString[i + 1]] - 
                Symbol["u" <> ToString[i]])*
          b1[i, t] + (t - 
                Symbol["u" <> ToString[i]])/(Symbol["u" <> 
                    ToString[i + 1]] - Symbol["u" <> ToString[i]])*
          b1[i + 1, t];

iMax = 16; 
bpoints = 
      Table[b0[j, 
            N[Symbol["u" <> 
                    ToString[j]] + (i/
                      iMax)*(Symbol["u" <> ToString[j + 1]] - 
                      Symbol["u" <> ToString[j]])]] + {0, 
            0, -0.001}, {j, 1, 6}, {i, 0, iMax}];

independentVariables = 
      Flatten[{independentVariablesForVector["b01", {-0.4, 0.3, 0}], 
          independentVariablesForVector["b12", {-0.5, 0.5, 0}], 
          independentVariablesForVector["b23", {0.4, 0.9, 0}], 
          independentVariablesForVector["b34", {0.4, 0.4, 0}], 
          independentVariablesForVector["b45", {0.6, 0.4, 0}], 
          independentVariablesForVector["b56", {0.6, 0.9, 0}], 
          independentVariablesForVector["b67", {1.3, 0.7, 0}], 
          independentVariablesForVector["b78", {1.5, 0.3, 0}], 
          u0 -> -0.4, u1 -> -0.2, u2 -> -0.0, 
          u3 -> 0.2, u4 -> 0.4, u5 -> 0.6, u6 -> 0.8, 
          u7 -> 1.0, u8 -> 1.2}]

dependentVariables = 
      Flatten[{
dependentVariablesForVector["bu1", 
            b0[1, u1]], dependentVariablesForVector["bu2", b0[2, u2]], 
          dependentVariablesForVector["bu3", b0[3, u3]], 
          dependentVariablesForVector["bu4", b0[4, u4]], 
          dependentVariablesForVector["bu5", b0[5, u5]], 
          dependentVariablesForVector["bu6", b0[6, u6]], 
          dependentVariablesForVector["bu7", b0[6, u7]]}]

chap8fig3 := 
      Graphics3D[{{PointSize[0.04], RGBColor[0. , 1, 0. ], Point[b01], 
            Point[b12], Point[b23], Point[b34], Point[b45], Point[b56], 
            Point[b67], Point[b78], Point[{u0, 0, 0}], Point[{u1, 0, 0}], 
            Point[{u2, 0, 0}], Point[{u3, 0, 0}], Point[{u4, 0, 0}], 
            Point[{u5, 0, 0}], Point[{u6, 0, 0}], Point[{u7, 0, 0}], 
            Point[{u8, 0, 0}]}, {Thickness[0.0025], GrayLevel[0], 
            Line[{b01 + {0, 0, -0.001}, b12 + {0, 0, -0.001}, 
                b23 + {0, 0, -0.001}, b34 + {0, 0, -0.001}, 
                b45 + {0, 0, -0.001}, b56 + {0, 0, -0.001}, 
                b67 + {0, 0, -0.001}, 
                b78 + {0, 0, -0.001}}]}, 
{GrayLevel[
              0], PointSize[0.02], Point[bu1 + {0, 0, -0.001}], 
            Point[bu2 + {0, 0, -0.001}], Point[bu3 + {0, 0, -0.001}], 
            Point[bu4 + {0, 0, -0.001}], Point[bu5 + {0, 0, -0.001}], 
            Point[bu6 + {0, 0, -0.001}], 
            Point[bu7 + {0, 0, -0.001}]}, {Thickness[0.005], 
            GrayLevel[0], 
            Line[{{Min[u0, u1, u2, u3, u4, u5, u6, u7, u8], 
                  0, -0.001}, {Max[u0, u1, u2, u3, u4, u5, u6, u7, u8], 
                  0, -0.001}}]}, {Thickness[0.01], GrayLevel[0], 
            Line[bpoints[[1]]], Line[bpoints[[2]]], 
            Line[bpoints[[3]]], Line[bpoints[[4]]], 
            Line[bpoints[[5]]], 
            Line[bpoints[[6]]]}, {Text[
              itui["0"], {u0, 0, 0}, {0, 1.5}], 
            Text[itui["1"], {u1, 0, 0}, {0, 1.5}], 
            Text[itui["2"], {u2, 0, 0}, {0, 1.5}], 
            Text[itui["3"], {u3, 0, 0}, {0, 1.5}], 
            Text[itui["4"], {u4, 0, 0}, {0, 1.5}], 
            Text[itui["5"], {u5, 0, 0}, {0, 1.5}], 
            Text[itui["6"], {u6, 0, 0}, {0, 1.5}], 
            Text[itui["7"], {u7, 0, 0}, {0, 1.5}], 
            Text[itui["8"], {u8, 0, 0}, {0, 1.5}]}}, 
        ViewPoint -> {0, 0, 4}, ViewVertical -> {0, 1, 0}, 
        SphericalRegion -> True, 
        PlotRange -> {{-0.2, 1.2}, {-0.2, 0.9}, {-0.1, 
              0.1}}, Boxed -> False, Axes -> False, 
        Ticks -> Automatic, Lighting -> False, 
        AxesLabel -> {"x", "y", "z"}, 
        TextStyle -> newTextStyle]

Show[
      chap8fig3 //. 
        Join[independentVariables, dependentVariables]]

SetDirectory["/Users/martin/Desktop/mmasources"]

WriteLiveForm["chap8fig3.m", chap8fig3]

WriteHtmlPage["chap8fig3.html", "<FONT SIZE=+2><B>Figure 8.3, \
<I>n</I> = 2</B> [Farin 2002, page 128]</FONT>",  "chap8fig3.m", 800, 
      500, independentVariables,  
      dependentVariables, "<PARAM NAME=BGCOLOR VALUE=#FFFFFF>\n<PARAM NAME=\
\"MOUSE_DRAG_ACTION\" VALUE=\"NONE\">\n<PARAM NAME=\"POINT_EDGE_COLOR\" \
VALUE=#000000>\n"]

Figure 8.3 n=3, page 128

Input: points b012, b123, b234, b345, b456, b567, b678, b789, coordinates u0, u1, u2, u3, u4, u5, u6, u7, u8, u9

Interaction: 
— free movement of b012, b123, b234, b345, b456, b567, b678, b789
— movement of u0, u1, u2, u3, u4, u5, u6, u7, u8, u9

Output: 
— lines, interpolated points

SetDirectory["/Users/martin/Desktop/mmasources"]

ClearAll[b, b0, b1, b2, b3, b4, b5, b6, b7, b8, u0, u1, u2, u3, u4, u5, 
      u6, u7, u8, u9]; 
\(defineVector[{"b012", "b123", "b234", "b345", "b456", "b567", "b678", "b789", "bu1", "bu2", "bu3", "bu4", "bu5", "bu6", "bu7", "bu8"}]\)

b2[i_, 
        t_] := (Symbol["u" <> ToString[i + 2]] - 
                t)/(Symbol["u" <> ToString[i + 2]] - 
                Symbol["u" <> ToString[i - 1]])*
          Symbol["b" <> ToString[i - 1] <> ToString[i] <> 
              ToString[i + 1]] + (t - 
                Symbol["u" <> ToString[i - 1]])/(Symbol["u" <> 
                    ToString[i + 2]] - Symbol["u" <> ToString[i - 1]])*
          Symbol["b" <> ToString[i] <> ToString[i + 1] <> 
              ToString[i + 2]]; 
    b1[i_, t_] := (Symbol["u" <> ToString[i + 1]] - 
                t)/(Symbol["u" <> ToString[i + 1]] - 
                Symbol["u" <> ToString[i - 1]])*
          b2[i - 1, 
            t] + (t - 
                Symbol["u" <> ToString[i - 1]])/(Symbol["u" <> 
                    ToString[i + 1]] - Symbol["u" <> ToString[i - 1]])*
          b2[i, t]; 
b0[i_, 
        t_] := (Symbol["u" <> ToString[i + 1]] - 
                t)/(Symbol["u" <> ToString[i + 1]] - 
                Symbol["u" <> ToString[i]])*
          b1[i, t] + (t - 
                Symbol["u" <> ToString[i]])/(Symbol["u" <> 
                    ToString[i + 1]] - Symbol["u" <> ToString[i]])*
          b1[i + 1, t];

iMax = 16; 
bpoints = 
      Table[b0[j, 
            N[Symbol["u" <> 
                    ToString[j]] + (i/
                      iMax)*(Symbol["u" <> ToString[j + 1]] - 
                      Symbol["u" <> ToString[j]])]] + {0, 
            0, -0.001}, {j, 2, 7}, {i, 0, iMax}];

independentVariables = 
      Flatten[{independentVariablesForVector["b012", {-0.4, 0.3, 0}], 
          independentVariablesForVector["b123", {-0.5, 0.5, 0}], 
          independentVariablesForVector["b234", {0.4, 0.9, 0}], 
          independentVariablesForVector["b345", {0.4, 0.4, 0}], 
          independentVariablesForVector["b456", {0.6, 0.4, 0}], 
          independentVariablesForVector["b567", {0.6, 0.9, 0}], 
          independentVariablesForVector["b678", {1.3, 0.7, 0}], 
          independentVariablesForVector["b789", {1.5, 0.3, 0}], 
          u0 -> -0.6, u1 -> -0.4, u2 -> -0.2, 
          u3 -> 0. , u4 -> 0.2, u5 -> 0.4, u6 -> 0.6, 
          u7 -> 0.8, u8 -> 1.0, u9 -> 1.2}]

dependentVariables = 
      Flatten[{
dependentVariablesForVector["bu2", 
            b0[2, u2]], dependentVariablesForVector["bu3", b0[3, u3]], 
          dependentVariablesForVector["bu4", b0[4, u4]], 
          dependentVariablesForVector["bu5", b0[5, u5]], 
          dependentVariablesForVector["bu6", b0[6, u6]], 
          dependentVariablesForVector["bu7", b0[6, u7]]}];

chap8fig3b := 
      Graphics3D[{{PointSize[0.04], RGBColor[0. , 1, 0. ], Point[b012], 
            Point[b123], Point[b234], Point[b345], Point[b456], Point[b567], 
            Point[b678], Point[b789], Point[{u0, 0, 0}], Point[{u1, 0, 0}], 
            Point[{u2, 0, 0}], Point[{u3, 0, 0}], Point[{u4, 0, 0}], 
            Point[{u5, 0, 0}], Point[{u6, 0, 0}], Point[{u7, 0, 0}], 
            Point[{u8, 0, 0}], Point[{u9, 0, 0}]}, {Thickness[0.0025], 
            GrayLevel[0], 
            Line[{b012 + {0, 0, -0.001}, b123 + {0, 0, -0.001}, 
                b234 + {0, 0, -0.001}, b345 + {0, 0, -0.001}, 
                b456 + {0, 0, -0.001}, b567 + {0, 0, -0.001}, 
                b678 + {0, 0, -0.001}, 
                b789 + {0, 0, -0.001}}]}, 
{GrayLevel[
              0], PointSize[0.02], Point[bu2 + {0, 0, -0.001}], 
            Point[bu3 + {0, 0, -0.001}], Point[bu4 + {0, 0, -0.001}], 
            Point[bu5 + {0, 0, -0.001}], Point[bu6 + {0, 0, -0.001}], 
            Point[bu7 + {0, 0, -0.001}]}, {Thickness[0.005], 
            GrayLevel[0], 
            Line[{{Min[u0, u1, u2, u3, u4, u5, u6, u7, u8, u9], 
                  0, -0.001}, {Max[u0, u1, u2, u3, u4, u5, u6, u7, u8, 
                    u9], 0, -0.001}}]}, {Thickness[0.01], GrayLevel[0], 
            Line[bpoints[[1]]], Line[bpoints[[2]]], 
            Line[bpoints[[3]]], Line[bpoints[[4]]], 
            Line[bpoints[[5]]]}, {Text[
              itui["0"], {u0, 0, 0}, {0, 1.5}], 
            Text[itui["1"], {u1, 0, 0}, {0, 1.5}], 
            Text[itui["2"], {u2, 0, 0}, {0, 1.5}], 
            Text[itui["3"], {u3, 0, 0}, {0, 1.5}], 
            Text[itui["4"], {u4, 0, 0}, {0, 1.5}], 
            Text[itui["5"], {u5, 0, 0}, {0, 1.5}], 
            Text[itui["6"], {u6, 0, 0}, {0, 1.5}], 
            Text[itui["7"], {u7, 0, 0}, {0, 1.5}], 
            Text[itui["8"], {u8, 0, 0}, {0, 1.5}], 
            Text[itui["9"], {u9, 0, 0}, {0, 1.5}]}}, 
        ViewPoint -> {0, 0, 4}, ViewVertical -> {0, 1, 0}, 
        SphericalRegion -> True, 
        PlotRange -> {{-0.2, 1.2}, {-0.2, 0.9}, {-0.1, 
              0.1}}, Boxed -> False, Axes -> False, 
        Ticks -> Automatic, Lighting -> False, 
        AxesLabel -> {"x", "y", "z"}, 
        TextStyle -> newTextStyle]

Show[
      chap8fig3b //. 
        Join[independentVariables, dependentVariables]]

SetDirectory["/Users/martin/Desktop/mmasources"]

WriteLiveForm["chap8fig3b.m", chap8fig3b]

WriteHtmlPage["chap8fig3b.html", "<FONT SIZE=+2><B>Figure 8.3, \
<I>n</I> = 3</B> [Farin 2002, page 128]</FONT>",  "chap8fig3b.m", 800, 
      500, independentVariables,  
      dependentVariables, "<PARAM NAME=BGCOLOR VALUE=#FFFFFF>\n<PARAM NAME=\
\"MOUSE_DRAG_ACTION\" VALUE=\"NONE\">\n<PARAM NAME=\"POINT_EDGE_COLOR\" \
VALUE=#000000>\n"]

Figure 8.3 n=3, monomial evaluation, page 128

Input: points b012, b123, b234, b345, b456, b567, b678, b789, coordinates u0, u1, u2, u3, u4, u5, u6, u7, u8, u9

Interaction: 
— free movement of b012, b123, b234, b345, b456, b567, b678, b789
— movement of u0, u1, u2, u3, u4, u5, u6, u7, u8, u9

Output: 
— lines, interpolated points

SetDirectory["/Users/martin/Desktop/mmasources"]

ClearAll[b, b0, b1, b2, b3, b4, b5, b6, b7, b8, u0, u1, u2, u3, u4, u5, 
      u6, u7, u8, u9]; 
\(defineVector[{"b012", "b123", "b234", "b345", "b456", "b567", "b678", "b789", "bu1", "bu2", "bu3", "bu4", "bu5", "bu6", "bu7", "bu8"}]\)

b2[i_, t_] := 
      Together[(Symbol["u" <> ToString[i + 2]] - 
                  t)/(Symbol["u" <> ToString[i + 2]] - 
                  Symbol["u" <> ToString[i - 1]])*
            Symbol["b" <> ToString[i - 1] <> ToString[i] <> 
                ToString[i + 1]] + (t - 
                  Symbol["u" <> ToString[i - 1]])/(Symbol["u" <> 
                      ToString[i + 2]] - 
                  Symbol["u" <> ToString[i - 1]])*
            Symbol["b" <> ToString[i] <> ToString[i + 1] <> 
                ToString[i + 2]]]; 
    b1[i_, t_] := 
      Together[(Symbol["u" <> ToString[i + 1]] - 
                  t)/(Symbol["u" <> ToString[i + 1]] - 
                  Symbol["u" <> ToString[i - 1]])*
            b2[i - 1, 
              t] + (t - 
                  Symbol["u" <> ToString[i - 1]])/(Symbol["u" <> 
                      ToString[i + 1]] - 
                  Symbol["u" <> ToString[i - 1]])*
            b2[i, t]]; 
b0[i_, t_] := 
      Together[(Symbol["u" <> ToString[i + 1]] - 
                  t)/(Symbol["u" <> ToString[i + 1]] - 
                  Symbol["u" <> ToString[i]])*
            b1[i, t] + (t - 
                  Symbol["u" <> ToString[i]])/(Symbol["u" <> 
                      ToString[i + 1]] - Symbol["u" <> ToString[i]])*
            b1[i + 1, t]];

iMax = 16; 
bpoints = 
      Table[b0[j, 
            N[Symbol["u" <> 
                    ToString[j]] + (i/
                      iMax)*(Symbol["u" <> ToString[j + 1]] - 
                      Symbol["u" <> ToString[j]])]] + {0, 
            0, -0.001}, {j, 2, 7}, {i, 0, iMax}];

independentVariables = 
      Flatten[{independentVariablesForVector["b012", {-0.4, 0.3, 0}], 
          independentVariablesForVector["b123", {-0.5, 0.5, 0}], 
          independentVariablesForVector["b234", {0.4, 0.9, 0}], 
          independentVariablesForVector["b345", {0.4, 0.4, 0}], 
          independentVariablesForVector["b456", {0.6, 0.4, 0}], 
          independentVariablesForVector["b567", {0.6, 0.9, 0}], 
          independentVariablesForVector["b678", {1.3, 0.7, 0}], 
          independentVariablesForVector["b789", {1.5, 0.3, 0}], 
          u0 -> -0.6, u1 -> -0.4, u2 -> -0.2, 
          u3 -> 0. , u4 -> 0.2, u5 -> 0.4, u6 -> 0.6, 
          u7 -> 0.8, u8 -> 1.0, u9 -> 1.2}]

dependentVariables = 
      Flatten[{
dependentVariablesForVector["bu2", 
            b0[2, u2]], dependentVariablesForVector["bu3", b0[3, u3]], 
          dependentVariablesForVector["bu4", b0[4, u4]], 
          dependentVariablesForVector["bu5", b0[5, u5]], 
          dependentVariablesForVector["bu6", b0[6, u6]], 
          dependentVariablesForVector["bu7", b0[6, u7]]}];

chap8fig3c := 
      Graphics3D[{{PointSize[0.04], RGBColor[0. , 1, 0. ], Point[b012], 
            Point[b123], Point[b234], Point[b345], Point[b456], Point[b567], 
            Point[b678], Point[b789], Point[{u0, 0, 0}], Point[{u1, 0, 0}], 
            Point[{u2, 0, 0}], Point[{u3, 0, 0}], Point[{u4, 0, 0}], 
            Point[{u5, 0, 0}], Point[{u6, 0, 0}], Point[{u7, 0, 0}], 
            Point[{u8, 0, 0}], Point[{u9, 0, 0}]}, {Thickness[0.0025], 
            GrayLevel[0], 
            Line[{b012 + {0, 0, -0.001}, b123 + {0, 0, -0.001}, 
                b234 + {0, 0, -0.001}, b345 + {0, 0, -0.001}, 
                b456 + {0, 0, -0.001}, b567 + {0, 0, -0.001}, 
                b678 + {0, 0, -0.001}, 
                b789 + {0, 0, -0.001}}]}, 
{GrayLevel[
              0], PointSize[0.02], Point[bu2 + {0, 0, -0.001}], 
            Point[bu3 + {0, 0, -0.001}], Point[bu4 + {0, 0, -0.001}], 
            Point[bu5 + {0, 0, -0.001}], Point[bu6 + {0, 0, -0.001}], 
            Point[bu7 + {0, 0, -0.001}]}, {Thickness[0.005], 
            GrayLevel[0], 
            Line[{{Min[u0, u1, u2, u3, u4, u5, u6, u7, u8, u9], 
                  0, -0.001}, {Max[u0, u1, u2, u3, u4, u5, u6, u7, u8, 
                    u9], 0, -0.001}}]}, {Thickness[0.01], GrayLevel[0], 
            Line[bpoints[[1]]], Line[bpoints[[2]]], 
            Line[bpoints[[3]]], Line[bpoints[[4]]], 
            Line[bpoints[[5]]]}, {Text[
              itui[" 0"], {u0, 0, 0}, {0, 1.5}], 
            Text[itui["1"], {u1, 0, 0}, {0, 1.5}], 
            Text[itui["2"], {u2, 0, 0}, {0, 1.5}], 
            Text[itui["3"], {u3, 0, 0}, {0, 1.5}], 
            Text[itui["4"], {u4, 0, 0}, {0, 1.5}], 
            Text[itui["5"], {u5, 0, 0}, {0, 1.5}], 
            Text[itui["6"], {u6, 0, 0}, {0, 1.5}], 
            Text[itui["7"], {u7, 0, 0}, {0, 1.5}], 
            Text[itui["8"], {u8, 0, 0}, {0, 1.5}], 
            Text[itui["9"], {u9, 0, 0}, {0, 1.5}]}}, 
        ViewPoint -> {0, 0, 4}, ViewVertical -> {0, 1, 0}, 
        SphericalRegion -> True, 
        PlotRange -> {{-0.2, 1.2}, {-0.2, 0.9}, {-0.1, 
              0.1}}, Boxed -> False, Axes -> False, 
        Ticks -> Automatic, Lighting -> False, 
        AxesLabel -> {"x", "y", "z"}, 
        TextStyle -> newTextStyle]

Show[
      chap8fig3c //. 
        Join[independentVariables, dependentVariables]]

SetDirectory["/Users/martin/Desktop/mmasources"]

WriteLiveForm["chap8fig3c.m", chap8fig3c]

WriteHtmlPage["chap8fig3c.html", "<FONT SIZE=+2><B>Figure 8.3, \
<I>n</I> = 3 (evaluation with common denominators)</B> [Farin 2002, page \
128]</FONT>",  "chap8fig3c.m", 800, 500, independentVariables,  
      dependentVariables, "<PARAM NAME=BGCOLOR VALUE=#FFFFFF>\n<PARAM NAME=\
\"MOUSE_DRAG_ACTION\" VALUE=\"NONE\">\n<PARAM NAME=\"POINT_EDGE_COLOR\" \
VALUE=#000000>\n"]

Figure 8.4, page 129

Input: points b012, b123, b234, b345, b456, b567, b678, b789, coordinates u0, u1, u2, u3, u4, u5, u6, u7, u8, u9

Interaction: 
— free movement of b012, b123, b234, b345, b456, b567, b678, b789
— movement of u0, u1, u2, u3, u4, u5, u6, u7, u8, u9

Output: 
— Bezier points for segment between u4 and u5
— lines, interpolated points

SetDirectory["/Users/martin/Desktop/mmasources"]

ClearAll[b, b0, b1, b2, b3, b4, b5, b6, b7, b8, u0, u1, u2, u3, u4, u5, 
      u6, u7, u8, u9]; 
\(defineVector[{"b0123", "b123", "b234", "b345", "b456", "b567", "b678", "b789", "bu1", "bu2", "bu3", "bu4", "bu5", "bu6", "bu7", "bu8", "b445", "b455"}]\)

b2[i_, 
        t_] := (Symbol["u" <> ToString[i + 2]] - 
                t)/(Symbol["u" <> ToString[i + 2]] - 
                Symbol["u" <> ToString[i - 1]])*
          Symbol["b" <> ToString[i - 1] <> ToString[i] <> 
              ToString[i + 1]] + (t - 
                Symbol["u" <> ToString[i - 1]])/(Symbol["u" <> 
                    ToString[i + 2]] - Symbol["u" <> ToString[i - 1]])*
          Symbol["b" <> ToString[i] <> ToString[i + 1] <> 
              ToString[i + 2]]; 
    b1[i_, t_] := (Symbol["u" <> ToString[i + 1]] - 
                t)/(Symbol["u" <> ToString[i + 1]] - 
                Symbol["u" <> ToString[i - 1]])*
          b2[i - 1, 
            t] + (t - 
                Symbol["u" <> ToString[i - 1]])/(Symbol["u" <> 
                    ToString[i + 1]] - Symbol["u" <> ToString[i - 1]])*
          b2[i, t]; 
b0[i_, 
        t_] := (Symbol["u" <> ToString[i + 1]] - 
                t)/(Symbol["u" <> ToString[i + 1]] - 
                Symbol["u" <> ToString[i]])*
          b1[i, t] + (t - 
                Symbol["u" <> ToString[i]])/(Symbol["u" <> 
                    ToString[i + 1]] - Symbol["u" <> ToString[i]])*
          b1[i + 1, t];

iMax = 8; 
bpoints = 
      Table[b0[j, 
            N[Symbol["u" <> 
                    ToString[j]] + (i/
                      iMax)*(Symbol["u" <> ToString[j + 1]] - 
                      Symbol["u" <> ToString[j]])]] + {0, 
            0, -0.001}, {j, 2, 7}, {i, 0, iMax}];

independentVariables = 
      Flatten[{independentVariablesForVector["b012", {-0.4, 0.3, 0}], 
          independentVariablesForVector["b123", {-0.5, 0.5, 0}], 
          independentVariablesForVector["b234", {0.4, 0.9, 0}], 
          independentVariablesForVector["b345", {0.3, 0.4, 0}], 
          independentVariablesForVector["b456", {0.7, 0.4, 0}], 
          independentVariablesForVector["b567", {0.6, 0.9, 0}], 
          independentVariablesForVector["b678", {1.3, 0.7, 0}], 
          independentVariablesForVector["b789", {1.5, 0.3, 0}], 
          u0 -> -0.6, u1 -> -0.4, u2 -> -0.2, 
          u3 -> 0. , u4 -> 0.2, u5 -> 0.4, u6 -> 0.6, 
          u7 -> 0.8, u8 -> 1.0, u9 -> 1.2}]

dependentVariables = 
      Flatten[{
dependentVariablesForVector["bu2", 
            b0[2, u2]], dependentVariablesForVector["bu3", b0[3, u3]], 
          dependentVariablesForVector["bu4", b0[4, u4]], 
          dependentVariablesForVector["bu5", b0[5, u5]], 
          dependentVariablesForVector["bu6", b0[6, u6]], 
          dependentVariablesForVector["bu7", b0[6, u7]], 
          dependentVariablesForVector["b445", b2[4, u4]], 
          dependentVariablesForVector["b455", b2[4, u5]]}];

chap8fig4 := 
      Graphics3D[{{PointSize[0.04], RGBColor[0. , 1, 0. ], Point[b012], 
            Point[b123], Point[b234], Point[b345], Point[b456], Point[b567], 
            Point[b678], Point[b789], Point[{u0, 0, 0}], Point[{u1, 0, 0}], 
            Point[{u2, 0, 0}], Point[{u3, 0, 0}], Point[{u4, 0, 0}], 
            Point[{u5, 0, 0}], Point[{u6, 0, 0}], Point[{u7, 0, 0}], 
            Point[{u8, 0, 0}], Point[{u9, 0, 0}]}, {Thickness[0.0025], 
            GrayLevel[0], 
            Line[{bu4 + {0, 0, -0.001}, b445 + {0, 0, -0.001}}], 
            Line[{b455 + {0, 0, -0.001}, bu5 + {0, 0, -0.001}}], 
            Line[{b012 + {0, 0, -0.001}, b123 + {0, 0, -0.001}, 
                b234 + {0, 0, -0.001}, b345 + {0, 0, -0.001}, 
                b456 + {0, 0, -0.001}, b567 + {0, 0, -0.001}, 
                b678 + {0, 0, -0.001}, 
                b789 + {0, 0, -0.001}}]}, 
{GrayLevel[
              0.6], PointSize[0.02], Point[bu2 + {0, 0, -0.0005}], 
            Point[bu3 + {0, 0, -0.0005}], GrayLevel[0. ], 
            Point[bu4 + {0, 0, -0.0005}], 
            Point[b445 + {0, 0, -0.0005}], 
            Point[b455 + {0, 0, -0.0005}], 
            Point[bu5 + {0, 0, -0.0005}], GrayLevel[0.6], 
            Point[bu6 + {0, 0, -0.0005}], 
            Point[bu7 + {0, 0, -0.0005}]}, {Thickness[0.0025], 
            GrayLevel[0], 
            Line[{{Min[u0, u1, u2, u3, u4, u5, u6, u7, u8, u9], 
                  0, -0.001}, {Max[u0, u1, u2, u3, u4, u5, u6, u7, u8, 
                    u9], 0, -0.001}}], Thickness[0.01], 
            Line[{{u4, 0, -0.001}, {u5, 0, -0.001}}]}, {Thickness[
              0.01], GrayLevel[0.6], Line[bpoints[[1]]], 
            Line[bpoints[[2]]], GrayLevel[0. ], 
            Line[bpoints[[3]]], GrayLevel[0.6], 
            Line[bpoints[[4]]], 
            Line[bpoints[[5]]]}, {Text[
              itui["0"], {u0, 0, 0}, {0, 1.5}], 
            Text[itui["1"], {u1, 0, 0}, {0, 1.5}], 
            Text[itui["2"], {u2, 0, 0}, {0, 1.5}], 
            Text[itui["3"], {u3, 0, 0}, {0, 1.5}], 
            Text[itui["4"], {u4, 0, 0}, {0, 1.5}], 
            Text[itui["5"], {u5, 0, 0}, {0, 1.5}], 
            Text[itui["6"], {u6, 0, 0}, {0, 1.5}], 
            Text[itui["7"], {u7, 0, 0}, {0, 1.5}], 
            Text[itui["8"], {u8, 0, 0}, {0, 1.5}], 
            Text[itui["9"], {u9, 0, 0}, {0, 1.5}]}}, 
        ViewPoint -> {0, 0, 4}, ViewVertical -> {0, 1, 0}, 
        SphericalRegion -> True, 
        PlotRange -> {{-0.2, 1.2}, {-0.2, 0.9}, {-0.1, 
              0.1}}, Boxed -> False, Axes -> False, 
        Ticks -> Automatic, Lighting -> False, 
        AxesLabel -> {"x", "y", "z"}, 
        TextStyle -> newTextStyle]

Show[
      chap8fig4 //. 
        Join[independentVariables, dependentVariables]]

SetDirectory["/Users/martin/Desktop/mmasources"]

WriteLiveForm["chap8fig4.m", chap8fig4]

WriteHtmlPage["chap8fig4.html", "<FONT SIZE=+2><B>Figure 8.4</B> \
[Farin 2002, page 129]</FONT>",  "chap8fig4.m", 800, 500, 
      independentVariables,  
      dependentVariables, "<PARAM NAME=BGCOLOR VALUE=#FFFFFF>\n<PARAM NAME=\
\"MOUSE_DRAG_ACTION\" VALUE=\"NONE\">\n<PARAM NAME=\"POINT_EDGE_COLOR\" \
VALUE=#000000>\n"]

Figure 8.5, page 129

Input: points b012, b123, b234, b345, b456, b567, b678, b789, coordinates u0, u1, u2, u3, u4, u5, u6, u7, u8, u9

Interaction: 
— free movement of b012, b123, b234, b345, b456, b567, b678, b789
— movement of u0, u1, u2, u3, u4, u5, u6, u7, u8, u9

Output: 
— lines, interpolated points

SetDirectory["/Users/martin/Desktop/mmasources"]

ClearAll[b, b0, b1, b2, b3, b4, b5, b6, b7, b8, u0, u1, u2, u3, u4, u5, 
      u6, u7, u8, u9]; 
\(defineVector[{"b0123", "b123", "b234", "b345", "b456", "b567", "b678", "b789", "bu1", "bu2", "bu3", "bu4", "bu5", "bu6", "bu7", "bu8"}]\)

b2[i_, 
        t_] := (Symbol["u" <> ToString[i + 2]] - 
                t)/(Symbol["u" <> ToString[i + 2]] - 
                Symbol["u" <> ToString[i - 1]])*
          Symbol["b" <> ToString[i - 1] <> ToString[i] <> 
              ToString[i + 1]] + (t - 
                Symbol["u" <> ToString[i - 1]])/(Symbol["u" <> 
                    ToString[i + 2]] - Symbol["u" <> ToString[i - 1]])*
          Symbol["b" <> ToString[i] <> ToString[i + 1] <> 
              ToString[i + 2]]; 
    b1[i_, t_] := (Symbol["u" <> ToString[i + 1]] - 
                t)/(Symbol["u" <> ToString[i + 1]] - 
                Symbol["u" <> ToString[i - 1]])*
          b2[i - 1, 
            t] + (t - 
                Symbol["u" <> ToString[i - 1]])/(Symbol["u" <> 
                    ToString[i + 1]] - Symbol["u" <> ToString[i - 1]])*
          b2[i, t]; 
b0[i_, 
        t_] := (Symbol["u" <> ToString[i + 1]] - 
                t)/(Symbol["u" <> ToString[i + 1]] - 
                Symbol["u" <> ToString[i]])*
          b1[i, t] + (t - 
                Symbol["u" <> ToString[i]])/(Symbol["u" <> 
                    ToString[i + 1]] - Symbol["u" <> ToString[i]])*
          b1[i + 1, t];

iMax = 16; 
bpoints = 
      Table[b0[j, 
            N[Symbol["u" <> 
                    ToString[j]] + (-0.5 + 
                      2*i/iMax)*(Symbol["u" <> ToString[j + 1]] - 
                      Symbol["u" <> ToString[j]])]] + {0, 
            0, -0.001}, {j, 2, 7}, {i, 0, iMax}];

independentVariables = 
      Flatten[{independentVariablesForVector["b012", {-0.4, 0.3, 0}], 
          independentVariablesForVector["b123", {-0.5, 0.5, 0}], 
          independentVariablesForVector["b234", {0.4, 0.9, 0}], 
          independentVariablesForVector["b345", {0.4, 0.4, 0}], 
          independentVariablesForVector["b456", {0.6, 0.4, 0}], 
          independentVariablesForVector["b567", {0.6, 0.9, 0}], 
          independentVariablesForVector["b678", {1.3, 0.7, 0}], 
          independentVariablesForVector["b789", {1.5, 0.3, 0}], 
          u0 -> -0.6, u1 -> -0.4, u2 -> -0.2, 
          u3 -> 0. , u4 -> 0.2, u5 -> 0.4, u6 -> 0.6, 
          u7 -> 0.8, u8 -> 1.0, u9 -> 1.2}]

dependentVariables = 
      Flatten[{
dependentVariablesForVector["bu2", 
            b0[2, u2]], dependentVariablesForVector["bu3", b0[3, u3]], 
          dependentVariablesForVector["bu4", b0[4, u4]], 
          dependentVariablesForVector["bu5", b0[5, u5]], 
          dependentVariablesForVector["bu6", b0[6, u6]], 
          dependentVariablesForVector["bu7", b0[6, u7]]}];

chap8fig5 := 
      Graphics3D[{{PointSize[0.04], RGBColor[0. , 1, 0. ], Point[b012], 
            Point[b123], Point[b234], Point[b345], Point[b456], Point[b567], 
            Point[b678], Point[b789], Point[{u0, 0, 0}], Point[{u1, 0, 0}], 
            Point[{u2, 0, 0}], Point[{u3, 0, 0}], Point[{u4, 0, 0}], 
            Point[{u5, 0, 0}], Point[{u6, 0, 0}], Point[{u7, 0, 0}], 
            Point[{u8, 0, 0}], Point[{u9, 0, 0}]}, {Thickness[0.0025], 
            GrayLevel[0], 
            Line[{b012 + {0, 0, -0.001}, b123 + {0, 0, -0.001}, 
                b234 + {0, 0, -0.001}, b345 + {0, 0, -0.001}, 
                b456 + {0, 0, -0.001}, b567 + {0, 0, -0.001}, 
                b678 + {0, 0, -0.001}, 
                b789 + {0, 0, -0.001}}]}, 
{GrayLevel[
              0], PointSize[0.02], Point[bu2 + {0, 0, -0.0005}], 
            Point[bu3 + {0, 0, -0.0005}], 
            Point[bu4 + {0, 0, -0.0005}], 
            Point[bu5 + {0, 0, -0.0005}], 
            Point[bu6 + {0, 0, -0.0005}], 
            Point[bu7 + {0, 0, -0.0005}]}, {Thickness[0.005], 
            GrayLevel[0], 
            Line[{{Min[u0, u1, u2, u3, u4, u5, u6, u7, u8, u9], 
                  0, -0.001}, {Max[u0, u1, u2, u3, u4, u5, u6, u7, u8, 
                    u9], 0, -0.001}}]}, {Thickness[0.01], GrayLevel[0], 
            Line[bpoints[[1]]], Line[bpoints[[3]]], 
            Line[bpoints[[5]]], GrayLevel[0.6], 
            Line[bpoints[[2]]], 
            Line[bpoints[[4]]]}, {Text[
              itui["0"], {u0, 0, 0}, {0, 1.5}], 
            Text[itui["1"], {u1, 0, 0}, {0, 1.5}], 
            Text[itui["2"], {u2, 0, 0}, {0, 1.5}], 
            Text[itui["3"], {u3, 0, 0}, {0, 1.5}], 
            Text[itui["4"], {u4, 0, 0}, {0, 1.5}], 
            Text[itui["5"], {u5, 0, 0}, {0, 1.5}], 
            Text[itui["6"], {u6, 0, 0}, {0, 1.5}], 
            Text[itui["7"], {u7, 0, 0}, {0, 1.5}], 
            Text[itui["8"], {u8, 0, 0}, {0, 1.5}], 
            Text[itui["9"], {u9, 0, 0}, {0, 1.5}]}}, 
        ViewPoint -> {0, 0, 4}, ViewVertical -> {0, 1, 0}, 
        SphericalRegion -> True, 
        PlotRange -> {{-0.2, 1.2}, {-0.2, 0.9}, {-0.1, 
              0.1}}, Boxed -> False, Axes -> False, 
        Ticks -> Automatic, Lighting -> False, 
        AxesLabel -> {"x", "y", "z"}, 
        TextStyle -> newTextStyle]

Show[
      chap8fig5 //. 
        Join[independentVariables, dependentVariables]]

SetDirectory["/Users/martin/Desktop/mmasources"]

WriteLiveForm["chap8fig5.m", chap8fig5]

WriteHtmlPage["chap8fig5.html", "<FONT SIZE=+2><B>Figure 8.5</B> \
[Farin 2002, page 129]</FONT>",  "chap8fig5.m", 800, 500, 
      independentVariables,  
      dependentVariables, "<PARAM NAME=BGCOLOR VALUE=#FFFFFF>\n<PARAM NAME=\
\"MOUSE_DRAG_ACTION\" VALUE=\"NONE\">\n<PARAM NAME=\"POINT_EDGE_COLOR\" \
VALUE=#000000>\n"]

Figure 8.6, page 130

Input: points b012, b123, b234, b345, b456, b567, b678, b789, coordinates u0, u1, u2, u3, u4, u5, u6, u7, u8, u9

Interaction: 
— free movement of b012, b123, b234, b345, b456, b567, b678, b789
— movement of u0, u1, u2, u3, u4, u5, u6, u7, u8, u9

Output: 
— convex hull for segment between u4 and u5
— lines, interpolated points

SetDirectory["/Users/martin/Desktop/mmasources"]

ClearAll[b, b0, b1, b2, b3, b4, b5, b6, b7, b8, u0, u1, u2, u3, u4, u5, 
      u6, u7, u8, u9]; 
\(defineVector[{"b0123", "b123", "b234", "b345", "b456", "b567", "b678", "b789", "bu1", "bu2", "bu3", "bu4", "bu5", "bu6", "bu7", "bu8", "b445", "b455"}]\)

b2[i_, 
        t_] := (Symbol["u" <> ToString[i + 2]] - 
                t)/(Symbol["u" <> ToString[i + 2]] - 
                Symbol["u" <> ToString[i - 1]])*
          Symbol["b" <> ToString[i - 1] <> ToString[i] <> 
              ToString[i + 1]] + (t - 
                Symbol["u" <> ToString[i - 1]])/(Symbol["u" <> 
                    ToString[i + 2]] - Symbol["u" <> ToString[i - 1]])*
          Symbol["b" <> ToString[i] <> ToString[i + 1] <> 
              ToString[i + 2]]; 
    b1[i_, t_] := (Symbol["u" <> ToString[i + 1]] - 
                t)/(Symbol["u" <> ToString[i + 1]] - 
                Symbol["u" <> ToString[i - 1]])*
          b2[i - 1, 
            t] + (t - 
                Symbol["u" <> ToString[i - 1]])/(Symbol["u" <> 
                    ToString[i + 1]] - Symbol["u" <> ToString[i - 1]])*
          b2[i, t]; 
b0[i_, 
        t_] := (Symbol["u" <> ToString[i + 1]] - 
                t)/(Symbol["u" <> ToString[i + 1]] - 
                Symbol["u" <> ToString[i]])*
          b1[i, t] + (t - 
                Symbol["u" <> ToString[i]])/(Symbol["u" <> 
                    ToString[i + 1]] - Symbol["u" <> ToString[i]])*
          b1[i + 1, t];

iMax = 8; 
bpoints = 
      Table[b0[j, 
            N[Symbol["u" <> 
                    ToString[j]] + (i/
                      iMax)*(Symbol["u" <> ToString[j + 1]] - 
                      Symbol["u" <> ToString[j]])]] + {0, 
            0, -0.001}, {j, 2, 7}, {i, 0, iMax}];

independentVariables = 
      Flatten[{independentVariablesForVector["b012", {-0.4, 0.3, 0}], 
          independentVariablesForVector["b123", {-0.5, 0.5, 0}], 
          independentVariablesForVector["b234", {0.4, 0.9, 0}], 
          independentVariablesForVector["b345", {0.3, 0.4, 0}], 
          independentVariablesForVector["b456", {0.7, 0.4, 0}], 
          independentVariablesForVector["b567", {0.6, 0.9, 0}], 
          independentVariablesForVector["b678", {1.3, 0.7, 0}], 
          independentVariablesForVector["b789", {1.5, 0.3, 0}], 
          u0 -> -0.6, u1 -> -0.4, u2 -> -0.2, 
          u3 -> 0. , u4 -> 0.2, u5 -> 0.4, u6 -> 0.6, 
          u7 -> 0.8, u8 -> 1.0, u9 -> 1.2}]

dependentVariables = 
      Flatten[{
dependentVariablesForVector["bu2", 
            b0[2, u2]], dependentVariablesForVector["bu3", b0[3, u3]], 
          dependentVariablesForVector["bu4", b0[4, u4]], 
          dependentVariablesForVector["bu5", b0[5, u5]], 
          dependentVariablesForVector["bu6", b0[6, u6]], 
          dependentVariablesForVector["bu7", b0[6, u7]], 
          dependentVariablesForVector["b445", b2[4, u4]], 
          dependentVariablesForVector["b455", b2[4, u5]]}];

chap8fig6 := 
      Graphics3D[{{PointSize[0.04], RGBColor[0. , 1, 0. ], Point[b012], 
            Point[b123], Point[b234], Point[b345], Point[b456], Point[b567], 
            Point[b678], Point[b789], Point[{u0, 0, 0}], Point[{u1, 0, 0}], 
            Point[{u2, 0, 0}], Point[{u3, 0, 0}], Point[{u4, 0, 0}], 
            Point[{u5, 0, 0}], Point[{u6, 0, 0}], Point[{u7, 0, 0}], 
            Point[{u8, 0, 0}], Point[{u9, 0, 0}]}, {Thickness[0.0025], 
            GrayLevel[0], 
            Line[{b012 + {0, 0, -0.001}, b123 + {0, 0, -0.001}, 
                b234 + {0, 0, -0.001}, b345 + {0, 0, -0.001}, 
                b456 + {0, 0, -0.001}, b567 + {0, 0, -0.001}, 
                b678 + {0, 0, -0.001}, 
                b789 + {0, 0, -0.001}}]}, 
{GrayLevel[
              0. ], PointSize[0.02], Point[bu2 + {0, 0, -0.0005}], 
            Point[bu3 + {0, 0, -0.0005}], GrayLevel[0. ], 
            Point[bu4 + {0, 0, -0.0005}], 
            Point[bu5 + {0, 0, -0.0005}], GrayLevel[0. ], 
            Point[bu6 + {0, 0, -0.0005}], 
            Point[bu7 + {0, 0, -0.0005}]}, {GrayLevel[0.7], EdgeForm[], 
            Polygon[{b234 + {0, 0, -0.001}, b345 + {0, 0, -0.001}, 
                b456 + {0, 0, -0.001}}], 
            Polygon[{b345 + {0, 0, -0.001}, b456 + {0, 0, -0.001}, 
                b567 + {0, 0, -0.001}}], 
            Polygon[{b234 + {0, 0, -0.001}, b345 + {0, 0, -0.001}, 
                b567 + {0, 0, -0.001}}], 
            Polygon[{b234 + {0, 0, -0.001}, b456 + {0, 0, -0.001}, 
                b567 + {0, 0, -0.001}}]}, {Thickness[0.0025], 
            GrayLevel[0], 
            Line[{{Min[u0, u1, u2, u3, u4, u5, u6, u7, u8, u9], 
                  0, -0.001}, {Max[u0, u1, u2, u3, u4, u5, u6, u7, u8, 
                    u9], 0, -0.001}}], Thickness[0.01], 
            Line[{{u4, 0, -0.001}, {u5, 0, -0.001}}]}, {Thickness[
              0.0025], GrayLevel[0], Line[bpoints[[1]]], 
            Line[bpoints[[2]]], Thickness[0.01], 
            Line[bpoints[[3]]], Thickness[0.0025], 
            Line[bpoints[[4]]], 
            Line[bpoints[[5]]]}, {Text[
              itui["0"], {u0, 0, 0}, {0, 1.5}], 
            Text[itui["1"], {u1, 0, 0}, {0, 1.5}], 
            Text[itui["2"], {u2, 0, 0}, {0, 1.5}], 
            Text[itui["3"], {u3, 0, 0}, {0, 1.5}], 
            Text[itui["4"], {u4, 0, 0}, {0, 1.5}], 
            Text[itui["5"], {u5, 0, 0}, {0, 1.5}], 
            Text[itui["6"], {u6, 0, 0}, {0, 1.5}], 
            Text[itui["7"], {u7, 0, 0}, {0, 1.5}], 
            Text[itui["8"], {u8, 0, 0}, {0, 1.5}], 
            Text[itui["9"], {u9, 0, 0}, {0, 1.5}]}}, 
        ViewPoint -> {0, 0, 4}, ViewVertical -> {0, 1, 0}, 
        SphericalRegion -> True, 
        PlotRange -> {{-0.2, 1.2}, {-0.2, 0.9}, {-0.1, 
              0.1}}, Boxed -> False, Axes -> False, 
        Ticks -> Automatic, Lighting -> False, 
        AxesLabel -> {"x", "y", "z"}, 
        TextStyle -> newTextStyle]

Show[
      chap8fig6 //. 
        Join[independentVariables, dependentVariables]]

SetDirectory["/Users/martin/Desktop/mmasources"]

WriteLiveForm["chap8fig6.m", chap8fig6]

WriteHtmlPage["chap8fig6.html", "<FONT SIZE=+2><B>Figure 8.6</B> \
[Farin 2002, page 130]</FONT>",  "chap8fig6.m", 800, 500, 
      independentVariables,  
      dependentVariables, "<PARAM NAME=BGCOLOR VALUE=#FFFFFF>\n<PARAM NAME=\
\"MOUSE_DRAG_ACTION\" VALUE=\"NONE\">\n<PARAM NAME=\"POINT_EDGE_COLOR\" \
VALUE=#000000>\n"]

Figure 8.8, page 131

Input: points b01, b12, b23, coordinates u0, u1, u2, u3, u

Interaction: 
— free movement of b01, b12, b23
— movement of u0, u1, u2, u3, u

Output: 
— lines, interpolated points,

SetDirectory["/Users/martin/Desktop/mmasources"]

<< Arrow3D`

ClearAll[b, b1, b2, b01, b12, b23]; 
\(defineVector[{"b01", "b12", "b23", "bu1", "buu", "bu2", "b11", "b22"}]\)

b1[t_] = (u2 - t)/(u2 - u0)*b01 + (t - u0)/(u2 - u0)*
          b12; 
b2[t_] = (u3 - t)/(u3 - u1)*b12 + (t - u1)/(u3 - u1)*
          b23; 
b[t_] = (u2 - t)/(u2 - u1)*b1[t] + (t - u1)/(u2 - u1)*
          b2[t];

iMax = 64; 
bpoints = 
      Table[b[N[u1 + (u2 - u1) i/iMax]] + {0, 0, -0.001}, {i, 0, 
          iMax}];

independentVariables = 
      Flatten[{independentVariablesForVector["b01", {-0.2, 1.0, 0}], 
          independentVariablesForVector["b12", {2. , 2.2, 0}], 
          independentVariablesForVector["b23", {3.2, 0.9, 0}], 
          u0 -> 0. , u1 -> 1. , u2 -> 2. , u3 -> 3. , 
          u -> 1.5}]

\(dependentVariables = 
      Flatten[{u3 -> If[u3 < u2, u2, u3], u0 -> If[u0 > u1, u1, u0], 
          u2 -> If[u2 > u3, u3, If[u2 < u, u, u2]], 
          u1 -> If[u1 < u0, u0, If[u1 > u, u, u1]], 
          u -> 
            If[u > u2, u2, 
              If[u < u1, u1, 
                u]], 
dependentVariablesForVector["bu1", b1[u]], dependentVariablesForVector["bu2", b2[u]], 
          dependentVariablesForVector["buu", b[u]], 
          dependentVariablesForVector["b11", b[u1]], 
          dependentVariablesForVector["b22", b[u2]]}]; \)

chap8fig8 := 
      Graphics3D[{{PointSize[0.04], RGBColor[0. , 1, 0. ], Point[b01], 
            Point[b12], Point[b23], Point[{u0, 0, 0}], Point[{u1, 0, 0}], 
            Point[{u2, 0, 0}], Point[{u3, 0, 0}], 
            Point[{u, 0, 0}]}, {Thickness[0.0025], GrayLevel[0], 
            Line[{b01 + {0, 0, -0.001}, b12 + {0, 0, -0.001}, 
                b23 + {0, 0, -0.001}}], 
            Line[{bu1 + {0, 0, -0.001}, bu2 + {0, -0, 0.001}}], 
            Thickness[0.005], 
            Line[{{u0, 0, -0.001}, {u3, 0, -0.001}}], 
            Thickness[0.01], 
            Line[{{u1, 0, -0.001}, {u2, 
                  0, -0.001}}]}, 
{GrayLevel[0], 
            PointSize[0.03], Point[bu1], Point[bu2], PointSize[0.02], 
            Point[buu], Point[b11], Point[b22]}, {Thickness[0.01], 
            GrayLevel[0], 
            Line[bpoints]}, {Text[itui["0"], {u0, 0, 0}, {0, 1.5}], 
            Text[itui["1"], {u1, 0, 0}, {0, 1.5}], 
            Text[itui["2"], {u2, 0, 0}, {0, 1.5}], 
            Text[itui["3"], {u3, 0, 0}, {0, 1.5}], 
            Text[OverHat[itu], {u, 0, 0}, {0, 1.5}], 
            Text[StringForm["````````````", bfb, "[", 
                itui["0"], ",", itui["1"], "]"], 
              b01, {0, 1.5}], 
            Text[StringForm["````````````", bfb, "[", 
                itui["2"], ",", itui["3"], "]"], 
              b23, {0, 1.5}], 
            Text[StringForm["````````````", bfb, "[", 
                itui["1"], ",", OverHat[itu], "]"], 
              bu1, {1.2, -1.1}], 
            Text[StringForm["````````````", bfb, "[", 
                OverHat[itu], ",", itui["2"], "]"], 
              bu2, {-1.2, -1.1}]}}, ViewPoint -> {0, 0, 4}, 
        ViewVertical -> {0, 1, 0}, SphericalRegion -> True, 
        PlotRange -> {{0.1, 2.9}, {-1.1, 2.1}, {-0.1, 0.1}}, 
        Boxed -> False, Axes -> False, Ticks -> Automatic, 
        Lighting -> False, 
        AxesLabel -> {"x", "y", "z"}, 
        TextStyle -> newTextStyle]

Show[
      chap8fig8 //. 
        Join[independentVariables, dependentVariables]]

SetDirectory["/Users/martin/Desktop/mmasources"]

WriteLiveForm["chap8fig8.m", chap8fig8]

WriteHtmlPage["chap8fig8.html", "<FONT SIZE=+2><B>Figure 8.8</B> \
[Farin 2002, page 131]</FONT>",  "chap8fig8.m", 800, 500, 
      independentVariables,  
      dependentVariables, "<PARAM NAME=BGCOLOR VALUE=#FFFFFF>\n<PARAM NAME=\
\"MOUSE_DRAG_ACTION\" VALUE=\"NONE\">\n<PARAM NAME=\"POINT_EDGE_COLOR\" \
VALUE=#000000>\n"]

Figure 8.9, page 132

Input: coordinate t

Interaction: 
— move t at discreet values 1/6(0, 1, 2, 3, 4, 5, 6)

Output: 
— n = t/8
— coordinate system, Bernstein polynomials for n

SetDirectory["/Users/martin/Desktop/mmasources"]

ClearAll[b, t, d, d0, d1, d2, d3]

defineVector[{"d0", "d1", "d2", "d3"}]

d[i_, 0] := 
      Symbol["d" <> ToString[Mod[i, 4]]]; 
d[i_, n_] := 
      If[EvenQ[i], 
        0.75* d[Floor[i/2], n - 1] + 0.25* d[Floor[i/2] + 1, n - 1], 
        0.25*d[Floor[i/2], n - 1] + 
          0.75* d[Floor[i/2] + 1, n - 1]];

dpoints = 
      Expand[Table[
          d[i, j] + {0, 0, -0.001}, {j, 0, 6}, {i, 0, 
            2^j*4}]];

dpoints2 = 
      Expand[Table[
          d[i, j] + {0, 0, -0.002}, {j, 0, 6}, {i, 0, 
            2^j*4}]];

independentVariables = 
      Flatten[{t -> 0/6. , 
          independentVariablesForVector["d0", {0, 0, 0}], 
          independentVariablesForVector["d1", {1, 0, 0}], 
          independentVariablesForVector["d2", {1, 1, 0}], 
          independentVariablesForVector["d3", {0, 1, 0}]}]

dependentVariables = 
      Flatten[{t -> Round[t*6. ]/6. , 
          t -> If[t > 1, 1, If[t < 0, 0, t]], 
          n -> Round[t*6. ]}]

ytaxis = -0.4;

\(chap8fig9 := 
      Graphics3D[{{PointSize[0.04], RGBColor[0. , 1, 0. ], 
            Point[{t, ytaxis, 0.01}], Point[d0], Point[d1], Point[d2], 
            Point[d3]}, {Thickness[0.01], PointSize[0.02], GrayLevel[0], 
            dummyIf[n == 1, {Line[dpoints[\([\)\(2\)\(]\)]], 
                Map[Point, dpoints[\([\)\(2\)\(]\)]], Thickness[0.005], 
                GrayLevel[0.6], Line[dpoints2[\([\)\(1\)\(]\)]]}, 
              dummyIf[n == 2, {Line[dpoints[\([\)\(3\)\(]\)]], 
                  Map[Point, dpoints[\([\)\(3\)\(]\)]], Thickness[0.005], 
                  GrayLevel[0.6], Line[dpoints2[\([\)\(2\)\(]\)]]}, 
                dummyIf[
                  n == 3, {Line[dpoints[\([\)\(4\)\(]\)]], 
                    Map[Point, dpoints[\([\)\(4\)\(]\)]], Thickness[0.005], 
                    GrayLevel[0.6], Line[dpoints2[\([\)\(3\)\(]\)]]}, 
                  dummyIf[
                    n == 4, {Line[dpoints[\([\)\(5\)\(]\)]], 
                      Map[Point, dpoints[\([\)\(5\)\(]\)]], Thickness[0.005], 
                      GrayLevel[0.6], Line[dpoints2[\([\)\(4\)\(]\)]]}, 
                    dummyIf[
                      n == 5, {Line[dpoints[\([\)\(6\)\(]\)]], 
                        Map[Point, dpoints[\([\)\(6\)\(]\)]], 
                        Thickness[0.005], GrayLevel[0.6], 
                        Line[dpoints2[\([\)\(5\)\(]\)]]}, 
                      dummyIf[
                        n == 6, {Line[dpoints[\([\)\(7\)\(]\)]], 
                          Map[Point, dpoints[\([\)\(7\)\(]\)]], 
                          Thickness[0.005]}, {Line[dpoints[\([\)\(1\)\(]\)]], 
                          Map[Point, 
                            dpoints[\([\)\(1\)\(]\)]]}]]]]]]}, 
{PointSize[0.02], GrayLevel[0], 
            Table[Point[{i/6. , ytaxis, 0}], {i, 0, 6}]}, {Thickness[0.005], 
            GrayLevel[0], 
            Line[{{0, ytaxis, 0}, {1, ytaxis, 0}}]}, {Thickness[0.01], 
            GrayLevel[0], Text[itn, {\(-1\)/6. , ytaxis, 0}, {0, 0}], 
            Table[Text[ToString[i], {i/6, ytaxis, 0}, {0, 1.5}], {i, 0, 
                6}]}}, ViewPoint -> {0, 0, 4}, 
        ViewVertical -> {0, 1, 0}, SphericalRegion -> True, 
        PlotRange -> {{\(- .1\), 1.0}, {\(-0.5\), 1.0}, {\(-0.1\), 
              0.1}}, Boxed -> False, Axes -> False, 
        Ticks -> Automatic, Lighting -> False, 
        AxesLabel -> {"x", "y", "z"}, 
        TextStyle -> newTextStyle]\)

Show[chap8fig9 /. dummyIf -> If //. 
        Join[independentVariables, dependentVariables]]

SetDirectory["/Users/martin/Desktop/mmasources"]

WriteLiveForm["chap8fig9.m", 
      chap8fig9 /. dummyIf -> If]

WriteHtmlPage["chap8fig9.html", "<FONT SIZE=+2><B>Figure 8.9</B> \
[Farin 2002, page 132]</FONT>",  "chap8fig9.m", 800, 500, 
      independentVariables,  
      dependentVariables, "<PARAM NAME=BGCOLOR VALUE=#FFFFFF>\n<PARAM NAME=\
\"MOUSE_DRAG_ACTION\" VALUE=\"NONE\">\n<PARAM NAME=\"POINT_EDGE_COLOR\" \
VALUE=#000000>\n"]

Figure 8.10, page 135

Input: coordinates d0, d1, d2, d3, d4, d5, coordinates u0, u1, u2, u3, u4, u5, u6, u7

Interaction: 
— movement of u0, u1, u2, u3, u4, u5, u6, u7
— movement of d0, d1, d2, d3, d4, d5, d6, d7

Output: 
— points b012, b123, b234, b345, b456, b567
— lines, interpolated points

SetDirectory["/Users/martin/Desktop/mmasources"]

ClearAll[b, b0, b1, b2, b3, b4, b5, b6, b7, b8, u0, u1, u2, u3, u4, u5, 
      u6, u7, d0, d1, d2, d3, d4, d5]; 
\(defineVector[{"b012", "b123", "b234", "b345", "b456", "b567", "bu1", "bu2", "bu3", "bu4", "bu5", "bu6"}]\)

b2[i_, 
        t_] := (Symbol["u" <> ToString[i + 2]] - 
                t)/(Symbol["u" <> ToString[i + 2]] - 
                Symbol["u" <> ToString[i - 1]])*
          Symbol["b" <> ToString[i - 1] <> ToString[i] <> 
              ToString[i + 1]] + (t - 
                Symbol["u" <> ToString[i - 1]])/(Symbol["u" <> 
                    ToString[i + 2]] - Symbol["u" <> ToString[i - 1]])*
          Symbol["b" <> ToString[i] <> ToString[i + 1] <> 
              ToString[i + 2]]; 
    b1[i_, t_] := (Symbol["u" <> ToString[i + 1]] - 
                t)/(Symbol["u" <> ToString[i + 1]] - 
                Symbol["u" <> ToString[i - 1]])*
          b2[i - 1, 
            t] + (t - 
                Symbol["u" <> ToString[i - 1]])/(Symbol["u" <> 
                    ToString[i + 1]] - Symbol["u" <> ToString[i - 1]])*
          b2[i, t]; 
b0[i_, 
        t_] := (Symbol["u" <> ToString[i + 1]] - 
                t)/(Symbol["u" <> ToString[i + 1]] - 
                Symbol["u" <> ToString[i]])*
          b1[i, t] + (t - 
                Symbol["u" <> ToString[i]])/(Symbol["u" <> 
                    ToString[i + 1]] - Symbol["u" <> ToString[i]])*
          b1[i + 1, t];

iMax = 16; 
bpoints = 
      Table[b0[j, 
            N[Symbol["u" <> 
                    ToString[j]] + (i/
                      iMax)*(Symbol["u" <> ToString[j + 1]] - 
                      Symbol["u" <> ToString[j]])]] + {0, 
            0, -0.001}, {j, 2, 5}, {i, 0, iMax}];

independentVariables = 
      Flatten[{d0 -> 0.6, d1 -> 0.9, d2 -> 0.9, 
          d3 -> 0.5, d4 -> 0.5, d5 -> 0.6, u0 -> 0. , 
          u1 -> 0. , u2 -> 0. , u3 -> 0.25, u4 -> 0.75, 
          u5 -> 1. , u6 -> 1. , u7 -> 1. }]

dependentVariables = 
      Flatten[{xi0 -> (u0 + u1 + u2)/3, 
          xi1 -> (u1 + u2 + u3)/3, xi2 -> (u2 + u3 + u4)/3, 
          xi3 -> (u3 + u4 + u5)/3, xi4 -> (u4 + u5 + u6)/3, 
          xi5 -> (u5 + u6 + u7)/3, 
          dependentVariablesForVector["b012", {xi0, d0, 0}], 
          dependentVariablesForVector["b123", {xi1, d1, 0}], 
          dependentVariablesForVector["b234", {xi2, d2, 0}], 
          dependentVariablesForVector["b345", {xi3, d3, 0}], 
          dependentVariablesForVector["b456", {xi4, d4, 0}], 
          dependentVariablesForVector["b567", {xi5, d5, 
              0}], 
dependentVariablesForVector["bu2", 
            b0[2, u2]], dependentVariablesForVector["bu3", b0[3, u3]], 
          dependentVariablesForVector["bu4", b0[4, u4]], 
          dependentVariablesForVector["bu5", b0[4, u5]]}];

xiaxis = 0.1;

chap8fig10 := 
      Graphics3D[{{PointSize[0.04], RGBColor[0. , 1, 0. ], 
            Point[{xi0, d0, 0}], Point[{xi1, d1, 0}], Point[{xi2, d2, 0}], 
            Point[{xi3, d3, 0}], Point[{xi4, d4, 0}], Point[{xi5, d5, 0}], 
            Point[{u0, 0, 0}], Point[{u1, 0, 0}], Point[{u2, 0, 0}], 
            Point[{u3, 0, 0}], Point[{u4, 0, 0}], Point[{u5, 0, 0}], 
            Point[{u6, 0, 0}], Point[{u7, 0, 0}]}, {Thickness[0.005], 
            GrayLevel[0], 
            Line[{b012 + {0, 0, -0.001}, b123 + {0, 0, -0.001}, 
                b234 + {0, 0, -0.001}, b345 + {0, 0, -0.001}, 
                b456 + {0, 0, -0.001}, 
                b567 + {0, 0, -0.001}}]}, 
{GrayLevel[
              0.0], PointSize[0.02], GrayLevel[0.0], 
            Point[bu2 + {0, 0, -0.001}], Point[bu3 + {0, 0, -0.001}], 
            Point[bu4 + {0, 0, -0.001}], Point[bu5 + {0, 0, -0.001}], 
            Point[{xi0, xiaxis, 0. }], Point[{xi1, xiaxis, 0. }], 
            Point[{xi2, xiaxis, 0. }], Point[{xi3, xiaxis, 0. }], 
            Point[{xi4, xiaxis, 0. }], 
            Point[{xi5, xiaxis, 0. }]}, {Thickness[0.005], GrayLevel[0], 
            Line[{{Min[xi0, xi1, xi2, xi3, xi4, xi5], 
                  xiaxis, -0.001}, {Max[xi0, xi1, xi2, xi3, xi4, xi5], 
                  xiaxis, -0.001}}], 
            Line[{{Min[u0, u1, u2, u3, u4, u5, u6, u7], 
                  0, -0.001}, {Max[u0, u1, u2, u3, u4, u5, u6, u7], 
                  0, -0.001}}]}, {Thickness[0.01], GrayLevel[0], 
            Line[bpoints[[1]]], Line[bpoints[[2]]], 
            Line[bpoints[[3]]]}, {Text[
              bfdi["0"], {xi0, d0, 0}, {1.5, 0}], 
            Text[bfdi["5"], {xi5, d5, 0}, {-1.7, 0}], 
            Text[Subscript["ξ", "0"], {xi0, xiaxis, 
                0}, {0, -1.8}], 
            Text[Subscript["ξ", "1"], {xi1, xiaxis, 
                0}, {0, -1.8}], 
            Text[Subscript["ξ", "2"], {xi2, xiaxis, 
                0}, {0, -1.8}], 
            Text[Subscript["ξ", "3"], {xi3, xiaxis, 
                0}, {0, -1.8}], 
            Text[Subscript["ξ", "4"], {xi4, xiaxis, 
                0}, {0, -1.8}], 
            Text[Subscript["ξ", "5"], {xi5, xiaxis, 
                0}, {0, -1.8}], 
            Text[itui["0"], {u0, 0, 0}, {0, 1.5}], 
            Text[itui["1"], {u1, 0, 0}, {0, 1.5}], 
            Text[itui["2"], {u2, 0, 0}, {0, 1.5}], 
            Text[itui["3"], {u3, 0, 0}, {0, 1.5}], 
            Text[itui["4"], {u4, 0, 0}, {0, 1.5}], 
            Text[itui["5"], {u5, 0, 0}, {0, 1.5}], 
            Text[itui["6"], {u6, 0, 0}, {0, 1.5}], 
            Text[itui["7"], {u7, 0, 0}, {0, 1.5}]}}, 
        ViewPoint -> {0, 0, 4}, ViewVertical -> {0, 1, 0}, 
        SphericalRegion -> True, 
        PlotRange -> {{0.1, 0.9}, {-0.2, 0.9}, {-0.1, 0.1}}, 
        Boxed -> False, Axes -> False, Ticks -> Automatic, 
        Lighting -> False, 
        AxesLabel -> {"x", "y", "z"}, 
        TextStyle -> newTextStyle]

Show[
      chap8fig10 //. 
        Join[independentVariables, dependentVariables]]

SetDirectory["/Users/martin/Desktop/mmasources"]

WriteLiveForm["chap8fig10.m", chap8fig10]

WriteHtmlPage["chap8fig10.html", "<FONT SIZE=+2><B>Figure \
8.10</B> [Farin 2002, page 135]</FONT>",  "chap8fig10.m", 800, 500, 
      independentVariables,  
      dependentVariables, "<PARAM NAME=BGCOLOR VALUE=#FFFFFF>\n<PARAM NAME=\
\"MOUSE_DRAG_ACTION\" VALUE=\"NONE\">\n<PARAM NAME=\"POINT_EDGE_COLOR\" \
VALUE=#000000>\n"]

Figures 8.11, 8.12, 8.13, pages 136 and 137

Input: points b012, b123, b234, b345, b456, b567, b678, coordinates u0, u1, u2, u3, u4, u5, u6, u7, u8

Interaction: 
— free movement of b012, b123, b234, b345, b456, b567, b678
— movement of u0, u1, u2, u3, u4, u5, u6, u7, u8

Output: 
— lines, interpolated points

SetDirectory["/Users/martin/Desktop/mmasources"]

ClearAll[b, b0, b1, b2, b3, b4, b5, b6, b7, u0, u1, u2, u3, u4, u5, u6, 
      u7, u8]; 
\(defineVector[{"b012", "b123", "b234", "b345", "b456", "b567", "b678", "bu1", "bu2", "bu3", "bu4", "bu5", "bu6", "bu7"}]\)

b2[i_, 
        t_] := (Symbol["u" <> ToString[i + 2]] - 
                t)/(Symbol["u" <> ToString[i + 2]] - 
                Symbol["u" <> ToString[i - 1]])*
          Symbol["b" <> ToString[i - 1] <> ToString[i] <> 
              ToString[i + 1]] + (t - 
                Symbol["u" <> ToString[i - 1]])/(Symbol["u" <> 
                    ToString[i + 2]] - Symbol["u" <> ToString[i - 1]])*
          Symbol["b" <> ToString[i] <> ToString[i + 1] <> 
              ToString[i + 2]]; 
    b1[i_, t_] := (Symbol["u" <> ToString[i + 1]] - 
                t)/(Symbol["u" <> ToString[i + 1]] - 
                Symbol["u" <> ToString[i - 1]])*
          b2[i - 1, 
            t] + (t - 
                Symbol["u" <> ToString[i - 1]])/(Symbol["u" <> 
                    ToString[i + 1]] - Symbol["u" <> ToString[i - 1]])*
          b2[i, t]; 
b0[i_, 
        t_] := (Symbol["u" <> ToString[i + 1]] - 
                t)/(Symbol["u" <> ToString[i + 1]] - 
                Symbol["u" <> ToString[i]])*
          b1[i, t] + (t - 
                Symbol["u" <> ToString[i]])/(Symbol["u" <> 
                    ToString[i + 1]] - Symbol["u" <> ToString[i]])*
          b1[i + 1, t];

iMax = 16; 
bpoints = 
      Table[b0[j, 
            N[Symbol["u" <> 
                    ToString[j]] + (i/
                      iMax)*(Symbol["u" <> ToString[j + 1]] - 
                      Symbol["u" <> ToString[j]])]] + {0, 
            0, -0.001}, {j, 2, 6}, {i, 0, iMax}];

independentVariables = 
      Flatten[{independentVariablesForVector["b012", {0.2, 0.3, 0}], 
          independentVariablesForVector["b123", {0.1, 0.6, 0}], 
          independentVariablesForVector["b234", {0.3, 0.9, 0}], 
          independentVariablesForVector["b345", {0.7, 0.9, 0}], 
          independentVariablesForVector["b456", {0.9, 0.5, 0}], 
          independentVariablesForVector["b567", {0.6, 0.3, 0}], 
          independentVariablesForVector["b678", {0.3, 0.6, 0}], 
          u0 -> -0. , u1 -> -0. , u2 -> -0. , 
          u3 -> 0.499, u4 -> 0.5, u5 -> 0.501, u6 -> 1. , 
          u7 -> 1. , u8 -> 1.0}]

dependentVariables = 
      Flatten[{
dependentVariablesForVector["bu2", 
            b0[2, u2]], dependentVariablesForVector["bu3", b0[3, u3]], 
          dependentVariablesForVector["bu4", b0[4, u4]], 
          dependentVariablesForVector["bu5", b0[5, u5]], 
          dependentVariablesForVector["bu6", b0[6, u6]]}];

chap8fig13 := 
      Graphics3D[{{PointSize[0.04], RGBColor[0. , 1, 0. ], Point[b012], 
            Point[b123], Point[b234], Point[b345], Point[b456], Point[b567], 
            Point[b678], Point[{u0, 0, 0}], Point[{u1, 0, 0}], 
            Point[{u2, 0, 0}], Point[{u3, 0, 0}], Point[{u4, 0, 0}], 
            Point[{u5, 0, 0}], Point[{u6, 0, 0}], Point[{u7, 0, 0}], 
            Point[{u8, 0, 0}]}, {Thickness[0.005], GrayLevel[0], 
            Line[{b012 + {0, 0, -0.001}, b123 + {0, 0, -0.001}, 
                b234 + {0, 0, -0.001}, b345 + {0, 0, -0.001}, 
                b456 + {0, 0, -0.001}, b567 + {0, 0, -0.001}, 
                b678 + {0, 0, -0.001}}]}, 
{GrayLevel[
              0], PointSize[0.02], Point[bu2 + {0, 0, -0.001}], 
            Point[bu3 + {0, 0, -0.001}], Point[bu4 + {0, 0, -0.001}], 
            Point[bu5 + {0, 0, -0.001}], 
            Point[bu6 + {0, 0, -0.001}]}, {Thickness[0.005], 
            GrayLevel[0], 
            Line[{{Min[u0, u1, u2, u3, u4, u5, u6, u7, u8], 
                  0, -0.001}, {Max[u0, u1, u2, u3, u4, u5, u6, u7, u8], 
                  0, -0.001}}]}, {Thickness[0.01], GrayLevel[0], 
            Line[bpoints[[1]]], Line[bpoints[[2]]], 
            Line[bpoints[[3]]], 
            Line[bpoints[[4]]]}, {Text[
              StringForm["````````````````", bfb, "[", 
                itui["0"], ",", itui["1"], ",", 
                itui["2"], "]"], b012, {1.1, 1.5}], 
            Text[StringForm["````````````````", bfb, "[", 
                itui["1"], ",", itui["2"], ",", 
                itui["3"], "]"], b123, {1.1, 0}], 
            Text[StringForm["````````````````", bfb, "[", 
                itui["2"], ",", itui["3"], ",", 
                itui["4"], "]"], b234, {1.1, -1.5}], 
            Text[StringForm["````````````````", bfb, "[", 
                itui["3"], ",", itui["4"], ",", 
                itui["5"], "]"], b345, {-1.1, -1.5}], 
            Text[StringForm["````````````````", bfb, "[", 
                itui["4"], ",", itui["5"], ",", 
                itui["6"], "]"], b456, {-1.1, -1.5}], 
            Text[
              StringForm["````````````````", bfb, "[", 
                itui["5"], ",", itui["6"], ",", 
                itui["7"], "]"], b567, {-1.1, 1.5}], 
            Text[itui[" 0"], {u0, 0, 0}, {0, 1.5}], 
            Text[itui[" 1"], {u1, 0, 0}, {0, 1.5}], 
            Text[itui[" 2"], {u2, 0, 0}, {0, 1.5}], 
            Text[itui[" 3"], {u3, 0, 0}, {0, 1.5}], 
            Text[itui[" 4"], {u4, 0, 0}, {0, 1.5}], 
            Text[itui[" 5"], {u5, 0, 0}, {0, 1.5}], 
            Text[itui[" 6"], {u6, 0, 0}, {0, 1.5}], 
            Text[itui[" 7"], {u7, 0, 0}, {0, 1.5}], 
            Text[itui[" 8"], {u8, 0, 0}, {0, 1.5}]}}, 
        ViewPoint -> {0, 0, 4}, ViewVertical -> {0, 1, 0}, 
        SphericalRegion -> True, 
        PlotRange -> {{-0.2, 1.2}, {-0.2, 0.9}, {-0.1, 
              0.1}}, Boxed -> False, Axes -> False, 
        Ticks -> Automatic, Lighting -> False, 
        AxesLabel -> {"x", "y", "z"}, 
        TextStyle -> newTextStyle]

Show[
      chap8fig13 //. 
        Join[independentVariables, dependentVariables]]

SetDirectory["/Users/martin/Desktop/mmasources"]

WriteLiveForm["chap8fig13.m", chap8fig13]

WriteHtmlPage["chap8fig13.html", "<FONT SIZE=+2><B>Figure \
8.13</B> [Farin 2002, page 137]</FONT>",  "chap8fig13.m", 800, 500, 
      independentVariables,  
      dependentVariables, "<PARAM NAME=BGCOLOR VALUE=#FFFFFF>\n<PARAM NAME=\
\"MOUSE_DRAG_ACTION\" VALUE=\"NONE\">\n<PARAM NAME=\"POINT_EDGE_COLOR\" \
VALUE=#000000>\n"]

Figures 8.14, 8.15, 8.16, pages 138 and 139

Input: points b0,b1,b2,b3, (c0=b3), c1, c2, c3, u0, u1, u2

Interaction: 
— free movement of b0, b1, b2, b3, c1, c2, c3
— movement of u0, u1, u2

Output: 
— two cubic Bezier curves, lines, interpolated points

SetDirectory["/Users/martin/Desktop/mmasources"]

ClearAll[b0, b1, b2, b3, c0, c1, c2, c3, u0, u1, u2]

\(defineVector[{"b0", "b1", "b2", "b3", "c0", "c1", "c2", "c3", "b012", "c012"}]\)

b[r_, s_, t_] := 
      b0*(1 - r)*(1 - s)*(1 - t) + 
        b1*((1 - r)*(1 - s)*t + (1 - r)*s*(1 - t) + 
              r*(1 - s)*(1 - t)) + 
        b2*((1 - r)*s*t + r*s*(1 - t) + r*(1 - s)*t) + 
        b3*r*s*t; 
c[r_, s_, t_] := 
      c0*(1 - r)*(1 - s)*(1 - t) + 
        c1*((1 - r)*(1 - s)*t + (1 - r)*s*(1 - t) + 
              r*(1 - s)*(1 - t)) + 
        c2*((1 - r)*s*t + r*s*(1 - t) + r*(1 - s)*t) + 
        c3*r*s*t

iMax = 32; 
bpoints = 
      Table[b[(0.00005 + 0.9999*i/iMax), (0.00005 + 
                0.9999*i/iMax), (0.00005 + 0.9999*i/iMax)] + {0, 
            0, -0.001}, {i, 0, iMax}]; 
cpoints = 
      Table[c[(0.00005 + 0.9999*i/iMax) + {0, 
                0, -0.001}, (0.00005 + 0.9999*i/iMax), (0.00005 + 
                0.9999*i/iMax)] + {0, 0, -0.001}, {i, 0, 
          iMax}];

independentVariables = 
      Flatten[{independentVariablesForVector["b0", {-0.1, 0.4, 0}], 
          independentVariablesForVector["b1", {0.2, 1. , 0}], 
          independentVariablesForVector["b2", {0.6, 1. , 0}], 
          independentVariablesForVector["b3", {0.8, 0.8, 0}], 
          independentVariablesForVector["c0", {0.8, 0.8, 0}], 
          independentVariablesForVector["c1", {1.0, 0.6, 0}], 
          independentVariablesForVector["c2", {1.0, 0.2, 0}], 
          independentVariablesForVector["c3", {0.5, 0.4, 0}], 
          u0 -> 0. , u1 -> 0.5, u2 -> 1. }]

dependentVariables = 
      Flatten[{
dependentVariablesForVector["b012", 
            b[0, 1, (u2 - u0)/(u1 - u0)]], 
          dependentVariablesForVector["c012", 
            c[(u0 - u1)/(u2 - u1), 0, 1]]}];

chap8fig15 := 
      Graphics3D[{{PointSize[0.04], RGBColor[0. , 1, 0. ], Point[b0], 
            Point[b1], Point[b2], Point[b3], Point[c0], Point[c1], Point[c2], 
            Point[c3], Point[{u0, 0, 0}], Point[{u1, 0, 0}], 
            Point[{u2, 0, 0}]}, {Thickness[0.005], GrayLevel[0], 
            Line[{b0 + {0, 0, -0.001}, b1 + {0, 0, -0.001}, 
                b2 + {0, 0, -0.001}, b3 + {0, 0, -0.001}}], 
            Line[{c0 + {0, 0, -0.001}, c1 + {0, 0, -0.001}, 
                c2 + {0, 0, -0.001}, c3 + {0, 0, -0.001}}]}, 
          Line[{b2 + {0, 0, -0.001}, b012 + {0, 0, -0.001}}], 
          Line[{c1 + {0, 0, -0.001}, 
              c012 + {0, 0, -0.001}}], 
{GrayLevel[0], 
            PointSize[0.02], Point[b012 + {0, 0, -0.001}], 
            Point[c012 + {0, 0, -0.001}]}, {Thickness[0.005], 
            GrayLevel[0], 
            Line[{{Min[u0, u1, u2], 0, -0.001}, {Max[u0, u1, u2], 
                  0, -0.001}}]}, {Thickness[0.01], GrayLevel[0], 
            Line[bpoints], 
            Line[cpoints]}, {Text[bfbi["0"], b0, {1.1, 1.5}], 
            Text[bfbi["1"], b1, {1.2, -1.6}], 
            Text[bfbi["2"], b2, {-1.2, -1.6}], 
            Text[bfbi["3"], b3, {1.1, 1.5}], 
            Text[bfci["0"], c0, {-1.1, -1.5}], 
            Text[bfci["1"], c1, {-1.8, 0}], 
            Text[bfci["2"], c2, {-1.8, 0}], 
            Text[bfci["3"], c3, {1.1, 1.5}], 
Text[
              StringForm["````````````````", bfb, "[", 
                itui["0"], ",", itui["1"], ",", 
                itui["2"], "]"], b012, {-1.1, -1.5}], 
            Text[StringForm["````````````````", bfc, "[", 
                itui["0"], ",", itui["1"], ",", 
                itui["2"], "]"], c012, {-1.1, 1.5}], 
            Text[StringForm["3× ``", itui["0"]], {u0, 0, 
                0}, {0, 1.5}], 
            Text[StringForm["3× ``", itui["1"]], {u1, 0, 
                0}, {0, 1.5}], 
            Text[StringForm["3× ``", itui["2"]], {u2, 0, 
                0}, {0, 1.5}]}}, ViewPoint -> {0, 0, 4}, 
        ViewVertical -> {0, 1, 0}, SphericalRegion -> True, 
        PlotRange -> {{0.1, 1.2}, {-0.1, 1.2}, {-0.1, 0.1}}, 
        Boxed -> False, Axes -> False, Ticks -> Automatic, 
        Lighting -> False, 
        AxesLabel -> {"x", "y", "z"}, 
        TextStyle -> newTextStyle]

Show[
      chap8fig15 //. 
        Join[independentVariables, dependentVariables]]

SetDirectory["/Users/martin/Desktop/mmasources"]

WriteLiveForm["chap8fig15.m", chap8fig15]

WriteHtmlPage["chap8fig15.html", "<FONT SIZE=+2><B>Figure \
8.15</B> [Farin 2002, page 139]</FONT>",  "chap8fig15.m", 800, 500, 
      independentVariables,  
      dependentVariables, "<PARAM NAME=BGCOLOR VALUE=#FFFFFF>\n<PARAM NAME=\
\"MOUSE_DRAG_ACTION\" VALUE=\"NONE\">\n<PARAM NAME=\"POINT_EDGE_COLOR\" \
VALUE=#000000>\n"]

Figure 8.17, page 141

Input: coordinates u0, u1, u2, u3, u4, u5, u6, u7, u8, u9

Interaction: 
— movement of u0, u1, u2, u3, u4, u5, u6, u7, u8, u9

Output: 
— B-spline functions Nin

SetDirectory["/Users/martin/Desktop/mmasources"]

ClearAll[b, b0, b1, b2, b3, b4, b5, b6, b7, b8, u0, u1, u2, u3, u4, u5, 
      u6, u7, u8, u9, u, splineN];

u[i_] := Symbol["u" <> ToString[i]]

splineN[s_, i_, 0, k_] := 
      If[i ≤ 0 || i > k, 0, 
        If[s <= u[i - 1] || s ≥ u[i], 0, 
          1]]; 
splineN[s_, i_, n_, k_] := 
      Module[{}, 
        If[i < 0 || i > k - n + 1, 0, 
          If[i == 0, (u[i + n] - s)/(u[i + n] - u[i]) 
              splineN[s, i + 1, n - 1, k], 
            If[i + n ≥ 
                k, (s - u[i - 1])/(u[i + n - 1] - u[i - 1]) 
                splineN[s, i, n - 1, 
                  k], (s - u[i - 1])/(u[i + n - 1] - u[i - 1]) 
                  splineN[s, i, n - 1, 
                    k] + (u[i + n] - s)/(u[i + n] - u[i]) 
                  splineN[s, i + 1, n - 1, k]]]]]

iMax = 32; 
bpoints = 
      Table[{i/iMax, 
          0.5 splineN[0.000 + 1.  i/iMax, j, 3, 9], -0.001}, {j, 0, 
          7}, {i, 0, iMax}];

independentVariables = 
      Flatten[{u0 -> -0.0001, u1 -> -0.0002, 
          u2 -> -0.0003, u3 -> 0.2, u4 -> 0.45, 
          u5 -> 0.6, u6 -> 0.8, u7 -> 1.0001, 
          u8 -> 1.0002, u9 -> 1.0003}]

dependentVariables = Flatten[{}];

chap8fig17 := 
      Graphics3D[{{PointSize[0.04], RGBColor[0. , 1, 0. ], Point[{u0, 0, 0}], 
            Point[{u1, 0, 0}], Point[{u2, 0, 0}], Point[{u3, 0, 0}], 
            Point[{u4, 0, 0}], Point[{u5, 0, 0}], Point[{u6, 0, 0}], 
            Point[{u7, 0, 0}], Point[{u8, 0, 0}], 
            Point[{u9, 0, 0}]}, 
{Thickness[0.005], 
            GrayLevel[0], Line[{{0, 0.5, -0.001}, {0, 0, -0.001}}], 
            Line[{{1, 0, -0.001}, {1, 0.5, -0.001}}], 
            Line[{{Min[u0, u1, u2, u3, u4, u5, u6, u7, u8, u9], 
                  0, -0.001}, {Max[u0, u1, u2, u3, u4, u5, u6, u7, u8, 
                    u9], 0, -0.001}}]}, {Thickness[0.01], GrayLevel[0], 
            Line[bpoints[[1]]], Line[bpoints[[2]]], 
            Line[bpoints[[3]]], Line[bpoints[[4]]], 
            Line[bpoints[[5]]], Line[bpoints[[6]]], 
            Line[bpoints[[7]]], 
            Line[bpoints[[8]]]}, {Text[
              itNin["0", "3"], {(u0 + u1 + u2)/3, 
                0.5 splineN[(u0 + u1 + u2)/3, 0, 3, 9], 
                0}, {0, -1.5}], 
            Text[itNin["1", "3"], {(u1 + u2 + u3)/
                  3,  .5 splineN[(u1 + u2 + u3)/3, 1, 3, 9], 
                0}, {0, -1.5}], 
            Text[itNin["2", "3"], {(u2 + u3 + u4)/
                  3,  .5 splineN[(u2 + u3 + u4)/3, 2, 3, 9], 
                0}, {0, -1.5}], 
            Text[itNin["3", "3"], {(u3 + u4 + u5)/
                  3,  .5 splineN[(u3 + u4 + u5)/3, 3, 3, 9], 
                0}, {0, -1.5}], 
            Text[itNin["4", "3"], {(u4 + u5 + u6)/
                  3,  .5 splineN[(u4 + u5 + u6)/3, 4, 3, 9], 
                0}, {0, -1.5}], 
            Text[itNin["5", "3"], {(u5 + u6 + u7)/
                  3,  .5 splineN[(u5 + u6 + u7)/3, 5, 3, 9], 
                0}, {0, -1.5}], 
            Text[itNin["6", "3"], {(u6 + u7 + u8)/
                  3,  .5 splineN[(u6 + u7 + u8)/3, 6, 3, 9], 
                0}, {0, -1.5}], 
            Text[itNin["7", "3"], {(u7 + u8 + u9)/
                  3,  .5 splineN[(u7 + u8 + u9)/3 - 0.0002, 7, 3, 9], 
                0}, {0, -1.5}], 
            Text[itui[" 0"], {u0, 0, 0}, {0, 1.5}], 
            Text[itui["1"], {u1, 0, 0}, {0, 1.5}], 
            Text[itui["2"], {u2, 0, 0}, {0, 1.5}], 
            Text[itui["3"], {u3, 0, 0}, {0, 1.5}], 
            Text[itui["4"], {u4, 0, 0}, {0, 1.5}], 
            Text[itui["5"], {u5, 0, 0}, {0, 1.5}], 
            Text[itui["6"], {u6, 0, 0}, {0, 1.5}], 
            Text[itui["7"], {u7, 0, 0}, {0, 1.5}], 
            Text[itui["8"], {u8, 0, 0}, {0, 1.5}], 
            Text[itui["9"], {u9, 0, 0}, {0, 1.5}]}}, 
        ViewPoint -> {0, 0, 4}, ViewVertical -> {0, 1, 0}, 
        SphericalRegion -> True, 
        PlotRange -> {{0.1, 0.9}, {-0.2, 0.7}, {-0.1, 0.1}}, 
        Boxed -> False, Axes -> False, Ticks -> Automatic, 
        Lighting -> False, 
        AxesLabel -> {"x", "y", "z"}, 
        TextStyle -> newTextStyle]

Show[
      chap8fig17 //. 
        Join[independentVariables, dependentVariables]]

SetDirectory["/Users/martin/Desktop/mmasources"]

WriteLiveForm["chap8fig17.m", chap8fig17]

WriteHtmlPage["chap8fig17.html", "<FONT SIZE=+2><B>Figure \
8.17</B> [Farin 2002, page 141]</FONT>",  "chap8fig17.m", 800, 500, 
      independentVariables,  
      dependentVariables, "<PARAM NAME=BGCOLOR VALUE=#FFFFFF>\n<PARAM NAME=\
\"MOUSE_DRAG_ACTION\" VALUE=\"NONE\">\n<PARAM NAME=\"POINT_EDGE_COLOR\" \
VALUE=#000000>\n"]

Figure 8.18, page 142

Input: coordinates u0, u1, u2, u3, u4, u5, u6, u7, u8, u9 

n=3, K=9, L=7; curve defined over [u2, u7]

Interaction: 
— movement of u0, u1, u2, u3, u4, u5, u6, u7, u8, u9

Output: 
— B-spline functions Nin

SetDirectory["/Users/martin/Desktop/mmasources"]

ClearAll[b, b0, b1, b2, b3, b4, b5, b6, b7, b8, u0, u1, u2, u3, u4, u5, 
      u6, u7, u8, u9, u, splineN];

u[i_] := Symbol["u" <> ToString[i]]

ClearAll[splineN]; 
splineN[s_, i_, 0, k_] := 
      If[i ≤ 0 || i > k, 0, 
        If[s <= u[i - 1] || s ≥ u[i], 0, 
          1]]; 
splineN[s_, i_, n_, k_] := 
      Module[{}, 
        If[i < 0 || i > k - n + 1, 0, 
          If[i == 0, (u[i + n] - s)/(u[i + n] - u[i]) 
              splineN[s, i + 1, n - 1, k], 
            If[i + n ≥ 
                k, (s - u[i - 1])/(u[i + n - 1] - u[i - 1]) 
                splineN[s, i, n - 1, 
                  k], (s - u[i - 1])/(u[i + n - 1] - u[i - 1]) 
                  splineN[s, i, n - 1, 
                    k] + (u[i + n] - s)/(u[i + n] - u[i]) 
                  splineN[s, i + 1, n - 1, k]]]]]

iMax = 32; 
n33points = 
      Table[{i/iMax, 
          0.5 splineN[0.0005 + 0.999  i/iMax, 3, 3, 9], -0.001}, {i, 0, 
          iMax}]; 
n32points = 
      Table[{i/iMax, 
          0.5 splineN[0.0005 + 0.999  i/iMax, 3, 2, 9], -0.002}, {i, 0, 
          iMax}]; 
n42points = 
      Table[{i/iMax, 
          0.5 splineN[0.0005 + 0.999  i/iMax, 4, 2, 9], -0.002}, {i, 0, 
          iMax}]; 
n31points = {{u2, 0, -0.003}, {u3, 0.5, -0.003}, {u4, 
          0, -0.003}}; 
    n41points = {{u3, 0, -0.003}, {u4, 0.5, -0.003}, {u5, 
          0, -0.003}}; 
    n51points = {{u4, 0, -0.003}, {u5, 0.5, -0.003}, {u6, 
          0, -0.003}};

independentVariables = 
      Flatten[{u0 -> 0.001, u1 -> 0.002, u2 -> 0.003, 
          u3 -> 0.2, u4 -> 0.45, u5 -> 0.6, u6 -> 0.8, 
          u7 -> 0.997, u8 -> 0.998, u9 -> 0.999}]

dependentVariables = Flatten[{}];

chap8fig18 := 
      Graphics3D[{{PointSize[0.04], RGBColor[0. , 1, 0. ], Point[{u0, 0, 0}], 
            Point[{u1, 0, 0}], Point[{u2, 0, 0}], Point[{u3, 0, 0}], 
            Point[{u4, 0, 0}], Point[{u5, 0, 0}], Point[{u6, 0, 0}], 
            Point[{u7, 0, 0}], Point[{u8, 0, 0}], 
            Point[{u9, 0, 0}]}, 
{Thickness[0.005], 
            GrayLevel[0], Line[{{0, 0.5, -0.001}, {0, 0, -0.001}}], 
            Line[{{1, 0, -0.001}, {1, 0.5, -0.001}}], 
            Line[{{Min[u0, u1, u2, u3, u4, u5, u6, u7, u8, u9], 
                  0, -0.001}, {Max[u0, u1, u2, u3, u4, u5, u6, u7, u8, 
                    u9], 0, -0.001}}]}, {Thickness[0.01], GrayLevel[0], 
            Line[n33points], GrayLevel[0.6], Line[n32points], 
            Line[n42points], Thickness[0.005], GrayLevel[0.0], 
            Line[n31points], Line[n41points], 
            Line[n51points]}, {Text[
              itNin["3", "1"], {u3,  .5 , 0}, {0, -1.5}], 
            Text[itNin["4", "1"], {u4,  .5 , 0}, {0, -1.5}], 
            Text[itNin["5", "1"], {u5,  .5 , 0}, {0, -1.5}], 
            Text[itui["0"], {u0, 0, 0}, {0, 1.5}], 
            Text[itui["1"], {u1, 0, 0}, {0, 1.5}], 
            Text[itui["2"], {u2, 0, 0}, {0, 1.5}], 
            Text[itui["3"], {u3, 0, 0}, {0, 1.5}], 
            Text[itui["4"], {u4, 0, 0}, {0, 1.5}], 
            Text[itui["5"], {u5, 0, 0}, {0, 1.5}], 
            Text[itui["6"], {u6, 0, 0}, {0, 1.5}], 
            Text[itui["7"], {u7, 0, 0}, {0, 1.5}], 
            Text[itui["8"], {u8, 0, 0}, {0, 1.5}], 
            Text[itui["9"], {u9, 0, 0}, {0, 1.5}]}}, 
        ViewPoint -> {0, 0, 4}, ViewVertical -> {0, 1, 0}, 
        SphericalRegion -> True, 
        PlotRange -> {{0.1, 0.9}, {-0.2, 0.7}, {-0.1, 0.1}}, 
        Boxed -> False, Axes -> False, Ticks -> Automatic, 
        Lighting -> False, 
        AxesLabel -> {"x", "y", "z"}, 
        TextStyle -> newTextStyle]

Show[
      chap8fig18 //. 
        Join[independentVariables, dependentVariables]]

SetDirectory["/Users/martin/Desktop/mmasources"]

WriteLiveForm["chap8fig18.m", chap8fig18]

WriteHtmlPage["chap8fig18.html", "<FONT SIZE=+2><B>Figure \
8.18</B> [Farin 2002, page 142]</FONT>",  "chap8fig18.m", 800, 500, 
      independentVariables,  
      dependentVariables, "<PARAM NAME=BGCOLOR VALUE=#FFFFFF>\n<PARAM NAME=\
\"MOUSE_DRAG_ACTION\" VALUE=\"NONE\">\n<PARAM NAME=\"POINT_EDGE_COLOR\" \
VALUE=#000000>\n"]

Figures for Chapter 9

none, so far

Figures for Chapter 10

Figure 10.1, page 180

Input: points b0, b1, b2, b3

Interaction: 
— free movement of b0, b1, b2, b3

Output: 
— curve, arrows, derivatives

SetDirectory["/Users/martin/Desktop/mmasources"]

<< Arrow3D`

SetOptions[Arrow3D, HeadLength -> 0.2];

ClearAll[b, db, t]

\(defineVector[{"b0", "b1", "b2", "b3", "x", "dxdt"}]\)

bernstein[i_, n_, t_] := 
      Binomial[n, i] t^i (1 - t)^(n - i)

b[t_] := 
      Sum[bernstein[i, 3, t]*Symbol["b" <> ToString[i]], {i, 0, 
          3}];

db[t_] = D[b[t], t]

iMax = 64; 
bpoints = 
      Table[{0, 0, -0.001} + b[i/iMax + 0.0000001], {i, 0, 
          iMax}];

independentVariables = 
      Flatten[{independentVariablesForVector["b0", {-0.5, 
              1.0, -0.5}], 
          independentVariablesForVector["b1", {-0.5, 0.8, 0.0}], 
          independentVariablesForVector["b2", {1.5, 0.4, 0. }], 
          independentVariablesForVector["b3", {1.5, 1.0, -0.5}], 
          t -> 0.3}]

dependentVariables = 
      Flatten[{t -> Max[0, Min[t, 1]], 
          dependentVariablesForVector["x", b[t]], 
          dependentVariablesForVector["dxdt", db[t]]}]

chap10fig1 := 
      Graphics3D[{{PointSize[0.04], RGBColor[0. , 1, 0. ], Point[b0], 
            Point[b1], Point[b2], Point[b3], Point[{t, 0, 0.01}], 
            GrayLevel[0], PointSize[0.02], Point[{0, 0, 0}], 
            Point[{1, 0, 0}], Point[x]}, {Thickness[0.01], GrayLevel[0], 
            Line[bpoints]}, {Thickness[0.005], GrayLevel[0. ], 
            Line[{b0 + {0, 0, -0.01}, b1 + {0, 0, -0.01}, 
                b2 + {0, 0, -0.01}, b3 + {0, 0, -0.01}}], 
            Thickness[0.005], GrayLevel[0], 
            Line[{{0, 0, 0}, {t - 0.01, 0, 0}}], 
            Line[{{t + 0.01, 0, 0}, {1, 0, 0}}]}, {Thickness[0.01], 
            EdgeForm[], GrayLevel[0], 
            Arrow3D[x, x + dxdt]}, {Text[itt, {t, 0, 0.01}, {0, 1.5}], 
            Text["0", {0, 0, 0}, {0, 1.5}], 
            Text["1", {1, 0, 0}, {0, 1.5}], 
            Text[StringForm["````````", bfx, "(", itt, ")"], 
              x, {0, -1.5}], 
            Text[StringForm["````````", 
                StyleForm[Overscript[bfx, "·"], 
                  ScriptSizeMultipliers -> 1, 
                  ScriptBaselineShifts -> {0.6, 0.9, 0.9, 
                      0.9}], "(", itt, ")"], 
              x + dxdt, {-1.1, -1.5}]}}, ViewPoint -> {0, 0, 4}, 
        ViewVertical -> {0, 1, 0}, SphericalRegion -> True, 
        PlotRange -> {{-1, 2}, {-0.5, 1.5}, {-0.1, 0.1}}, 
        Boxed -> False, Axes -> False, Ticks -> Automatic, 
        Lighting -> False, 
        AxesLabel -> {"x", "y", "z"}, 
        TextStyle -> newTextStyle]

Show[
      chap10fig1 //. 
        Join[independentVariables, dependentVariables]]

SetDirectory["/Users/martin/Desktop/mmasources"]

WriteLiveForm["chap10fig1.m", chap10fig1]

WriteHtmlPage["chap10fig1.html", "<FONT SIZE=+2><B>Figure \
10.1</B> [Farin 2002, page 180]</FONT>",  "chap10fig1.m", 800, 500, 
      independentVariables,  
      dependentVariables, "<PARAM NAME=BGCOLOR VALUE=#FFFFFF>\n<PARAM NAME=\
\"POINT_EDGE_COLOR\" VALUE=#000000>\n"]

Figure 10.2a, page 182

Input: points b0, b1, b2, b3

Interaction: 
— free movement of b0, b1, b2, b3

Output: 
— curve, arrows, derivatives

SetDirectory["/Users/martin/Desktop/mmasources"]

<< Arrow3D`

SetOptions[Arrow3D, HeadLength -> 0.2];

ClearAll[b, db, t]

\(defineVector[{"b0", "b1", "b2", "b3", "x", "dxdt", "ddxddt", "dddxdddt"}]\)

bernstein[i_, n_, t_] := 
      Binomial[n, i] t^i (1 - t)^(n - i)

b[t_] := 
      Sum[bernstein[i, 3, t]*Symbol["b" <> ToString[i]], {i, 0, 
          3}];

db[t_] = D[b[t], t]

ddb[t_] = D[b[t], {t, 2}]

dddb[t_] = D[b[t], {t, 3}]

iMax = 64; 
bpoints = 
      Table[{0, 0, -0.001} + b[i/iMax + 0.0000001], {i, 0, 
          iMax}];

independentVariables = 
      Flatten[{independentVariablesForVector["b0", {-0.5, 
              1.0, -0.5}], 
          independentVariablesForVector["b1", {-0.5, 0.8, 0.0}], 
          independentVariablesForVector["b2", {1.5, 0.4, 0. }], 
          independentVariablesForVector["b3", {1.5, 1.0, -0.5}], 
          t -> 0.3}]

dependentVariables = 
      Flatten[{t -> Max[0, Min[t, 1]], 
          dependentVariablesForVector["x", b[t]], 
          dependentVariablesForVector["dxdt", db[t]], 
          dependentVariablesForVector["ddxddt", ddb[t]], 
          dependentVariablesForVector["dddxdddt", dddb[t]]}]

chap10fig2 := 
      Graphics3D[{{PointSize[0.04], RGBColor[0. , 1, 0. ], Point[b0], 
            Point[b1], Point[b2], Point[b3], Point[{t, 0, 0.01}], 
            GrayLevel[0], PointSize[0.02], Point[{0, 0, 0}], 
            Point[{1, 0, 0}], Point[x]}, {Thickness[0.01], GrayLevel[0], 
            Line[bpoints]}, {Thickness[0.005], GrayLevel[0. ], 
            Line[{b0 + {0, 0, -0.01}, b1 + {0, 0, -0.01}, 
                b2 + {0, 0, -0.01}, b3 + {0, 0, -0.01}}], 
            Thickness[0.005], GrayLevel[0], 
            Line[{{0, 0, 0}, {t - 0.01, 0, 0}}], 
            Line[{{t + 0.01, 0, 0}, {1, 0, 0}}]}, {Thickness[0.01], 
            EdgeForm[], GrayLevel[0], Arrow3D[x, x + dxdt], 
            Arrow3D[x, x + ddxddt], 
            Arrow3D[x, x + dddxdddt]}, {Text[itt, {t, 0, 0.01}, {0, 1.5}], 
            Text["0", {0, 0, 0}, {0, 1.5}], 
            Text["1", {1, 0, 0}, {0, 1.5}], 
            Text[StringForm["````````", bfx, "(", itt, ")"], 
              x, {0, -1.5}], 
            Text[StringForm["````````", 
                StyleForm[Overscript[bfx, "·"], 
                  ScriptSizeMultipliers -> 1, 
                  ScriptBaselineShifts -> {0.6, 0.9, 0.9, 
                      0.9}], "(", itt, ")"], 
              x + dxdt, {-1.1, -1.5}], 
            Text[StringForm["````````", 
                StyleForm[Overscript[bfx, "··"], 
                  ScriptSizeMultipliers -> 1, 
                  ScriptBaselineShifts -> {0.6, 0.9, 0.9, 
                      0.9}], "(", itt, ")"], 
              x + ddxddt, {0, -1.5}], 
            Text[StringForm["````````", 
                StyleForm[
                  Overscript[
                    bfx, "···"], 
                  ScriptSizeMultipliers -> 1, 
                  ScriptBaselineShifts -> {0.6, 0.9, 0.9, 
                      0.9}], "(", itt, ")"], 
              x + dddxdddt, {-1.1, -1.5}]}}, 
        ViewPoint -> {0, 0, 4}, ViewVertical -> {0, 1, 0}, 
        SphericalRegion -> True, 
        PlotRange -> {{-1, 2}, {-0.5, 1.5}, {-0.1, 0.1}}, 
        Boxed -> False, Axes -> False, Ticks -> Automatic, 
        Lighting -> False, 
        AxesLabel -> {"x", "y", "z"}, 
        TextStyle -> newTextStyle]

Show[
      chap10fig2 //. 
        Join[independentVariables, dependentVariables]]

SetDirectory["/Users/martin/Desktop/mmasources"]

WriteLiveForm["chap10fig2.m", chap10fig2]

WriteHtmlPage["chap10fig2.html", "<FONT SIZE=+2><B>Figure 10.2 \
(left)</B> [Farin 2002, page 182]</FONT>",  "chap10fig2.m", 800, 500, 
      independentVariables,  
      dependentVariables, "<PARAM NAME=BGCOLOR VALUE=#FFFFFF>\n<PARAM NAME=\
\"POINT_EDGE_COLOR\" VALUE=#000000>\n"]

Figure 10.2b, page 182

Input: points b0, b1, b2, b3

Interaction: 
— free movement of b0, b1, b2, b3

Output: 
— curve, arrows, derivatives

SetDirectory["/Users/martin/Desktop/mmasources"]

<< Arrow3D`

SetOptions[Arrow3D, HeadLength -> 0.2];

ClearAll[b, db, t]

\(defineVector[{"b0", "b1", "b2", "b3", "x", "dxdt", "ddxddt", "dddxdddt", "vt", "vm", "vb", "vb1", "vc"}]\)

bernstein[i_, n_, t_] := 
      Binomial[n, i] t^i (1 - t)^(n - i)

b[t_] := 
      Sum[bernstein[i, 3, t]*Symbol["b" <> ToString[i]], {i, 0, 
          3}];

db[t_] = D[b[t], t]

ddb[t_] = D[b[t], {t, 2}]

dddb[t_] = D[b[t], {t, 3}]

iMax = 64; 
bpoints = 
      Table[{0, 0, -0.001} + b[i/iMax + 0.0000001], {i, 0, 
          iMax}];

independentVariables = 
      Flatten[{independentVariablesForVector["b0", {-0.5, 
              1.0, -0.5}], 
          independentVariablesForVector["b1", {-0.5, 0.8, 0.0}], 
          independentVariablesForVector["b2", {1.5, 0.4, 0. }], 
          independentVariablesForVector["b3", {1.5, 1.0, -0.5}], 
          t -> 0.3}]

dependentVariables = 
      Flatten[{t -> Max[0, Min[t, 1]], 
          dependentVariablesForVector["x", b[t]], 
          dependentVariablesForVector["dxdt", db[t]], 
          dependentVariablesForVector["ddxddt", ddb[t]], 
          dependentVariablesForVector["dddxdddt", dddb[t]], 
          dependentVariablesForVector["vt", dxdt/Sqrt[dxdt . dxdt]], 
          dependentVariablesForVector["vb1", Cross[dxdt, ddxddt]], 
          dependentVariablesForVector["vb", vb1/Sqrt[vb1 . vb1]], 
          dependentVariablesForVector["vm", Cross[vb, vt]]}]

chap10fig2b := 
      Graphics3D[{{PointSize[0.04], RGBColor[0. , 1, 0. ], Point[b0], 
            Point[b1], Point[b2], Point[b3], Point[{t, 0, 0.01}], 
            GrayLevel[0], PointSize[0.02], Point[{0, 0, 0}], 
            Point[{1, 0, 0}], Point[x]}, {Thickness[0.01], GrayLevel[0], 
            Line[bpoints]}, {Thickness[0.005], GrayLevel[0. ], 
            Line[{b0 + {0, 0, -0.01}, b1 + {0, 0, -0.01}, 
                b2 + {0, 0, -0.01}, b3 + {0, 0, -0.01}}], 
            Thickness[0.005], GrayLevel[0], 
            Line[{{0, 0, 0}, {t - 0.01, 0, 0}}], 
            Line[{{t + 0.01, 0, 0}, {1, 0, 0}}]}, {Thickness[0.01], 
            EdgeForm[], GrayLevel[0], Arrow3D[x, x + vt], Arrow3D[x, x + vb], 
            Arrow3D[x, x + vm], 
            GrayLevel[0.0]}, {Text[itt, {t, 0, 0.01}, {0, 1.5}], 
            Text["0", {0, 0, 0}, {0, 1.5}], 
            Text["1", {1, 0, 0}, {0, 1.5}], 
            Text[StringForm["````````", bfx, "(", itt, ")"], 
              x, {0, 1.5}], Text[bft, x + vt, {-1.1, 1.5}], 
            Text[bfb, x + vb, {-1.2, -1.2}], 
            Text[bfm, x + vm, {-1.2, 1.4}]}}, 
        ViewPoint -> {0, 0, 4}, ViewVertical -> {0, 1, 0}, 
        SphericalRegion -> True, 
        PlotRange -> {{-1, 2}, {-0.5, 1.5}, {-0.1, 0.1}}, 
        Boxed -> False, Axes -> False, Ticks -> Automatic, 
        Lighting -> False, 
        AxesLabel -> {"x", "y", "z"}, 
        TextStyle -> newTextStyle]

Show[
      chap10fig2b //. 
        Join[independentVariables, dependentVariables]]

SetDirectory["/Users/martin/Desktop/mmasources"]

WriteLiveForm["chap10fig2b.m", chap10fig2b]

WriteHtmlPage["chap10fig2b.html", "<FONT SIZE=+2><B>Figure 10.2 \
(right)</B> [Farin 2002, page 182]</FONT>",  "chap10fig2b.m", 800, 
      500, independentVariables,  
      dependentVariables, "<PARAM NAME=BGCOLOR VALUE=#FFFFFF>\n<PARAM NAME=\
\"POINT_EDGE_COLOR\" VALUE=#000000>\n"]

Figure 10.3, page 183

Input: points b0, b1, b2, b3

Interaction: 
— free movement of b0, b1, b2, b3

Output: 
— curve, arrows, derivatives

SetDirectory["/Users/martin/Desktop/mmasources"]

<< Arrow3D`

SetOptions[Arrow3D, HeadLength -> 0.2];

ClearAll[b, db, t]

\(defineVector[{"b0", "b1", "b2", "b3", "x", "dxdt", "ddxddt", "dddxdddt", "vt", "vm", "vb", "vb1"}]\)

bernstein[i_, n_, t_] := 
      Binomial[n, i] t^i (1 - t)^(n - i)

b[t_] := 
      Sum[bernstein[i, 3, t]*Symbol["b" <> ToString[i]], {i, 0, 
          3}];

db[t_] = D[b[t], t]

ddb[t_] = D[b[t], {t, 2}]

dddb[t_] = D[b[t], {t, 3}]

iMax = 64; 
bpoints = 
      Table[{0, 0, -0.001} + b[i/iMax + 0.0000001], {i, 0, 
          iMax}];

independentVariables = 
      Flatten[{independentVariablesForVector["b0", {-0.5, 
              1.0, -0.5}], 
          independentVariablesForVector["b1", {-0.5, 0.8, 0.0}], 
          independentVariablesForVector["b2", {1.5, 0.4, 0. }], 
          independentVariablesForVector["b3", {1.5, 1.0, -0.5}], 
          t -> 0.3}]

dependentVariables = 
      Flatten[{t -> Max[0, Min[t, 1]], 
          dependentVariablesForVector["x", b[t]], 
          dependentVariablesForVector["dxdt", db[t]], 
          dependentVariablesForVector["ddxddt", ddb[t]], 
          dependentVariablesForVector["dddxdddt", dddb[t]], 
          dependentVariablesForVector["vt", dxdt/Sqrt[dxdt . dxdt]], 
          dependentVariablesForVector["vb1", Cross[dxdt, ddxddt]], 
          dependentVariablesForVector["vb", vb1/Sqrt[vb1 . vb1]], 
          dependentVariablesForVector["vm", Cross[vb, vt]], 
          kappa -> Sqrt[vb1 . vb1]/Sqrt[(dxdt . dxdt)^3], 
          tau -> 
            Det[{dxdt, ddxddt, dddxdddt}]/(vb1 . vb1)}]

chap10fig3 := 
      Graphics3D[{{PointSize[0.04], RGBColor[0. , 1, 0. ], Point[b0], 
            Point[b1], Point[b2], Point[b3], Point[{t, 0, 0.01}], 
            GrayLevel[0], PointSize[0.02], Point[{0, 0, 0}], 
            Point[{1, 0, 0}], Point[x]}, {Thickness[0.01], GrayLevel[0], 
            Line[bpoints]}, {Thickness[0.005], GrayLevel[0. ], 
            Line[{b0 + {0, 0, -0.01}, b1 + {0, 0, -0.01}, 
                b2 + {0, 0, -0.01}, b3 + {0, 0, -0.01}}], 
            Thickness[0.005], GrayLevel[0], 
            Line[{{0, 0, 0}, {t - 0.01, 0, 0}}], 
            Line[{{t + 0.01, 0, 0}, {1, 0, 0}}]}, {Thickness[0.01], 
            EdgeForm[], GrayLevel[0], Arrow3D[x, x + vt], Arrow3D[x, x + vb], 
            Arrow3D[x, x + vm], GrayLevel[0.6], 
            Arrow3D[x + vt, x + vt + kappa vm], 
            Arrow3D[x + vb, x + vb - tau vm], 
            Arrow3D[x + vm, x + vm + tau vb], 
            Arrow3D[x + vm, x + vm - kappa vt], 
            Arrow3D[x + vm, x + vm + tau vb - kappa vt], Thickness[0.0025], 
            Line[{x + vm - kappa vt, x + vm + tau vb - kappa vt, 
                x + vm + tau vb}]}, {Text[itt, {t, 0, 0.01}, {0, 1.5}], 
            Text["0", {0, 0, 0}, {0, 1.5}], 
            Text["1", {1, 0, 0}, {0, 1.5}], 
            Text[StringForm["````````", bfx, "(", itt, ")"], 
              x, {0, 1.5}], Text[bft, x + vt, {-1.1, 1.5}], 
            Text[bfb, x + vb, {-1.2, -1.2}], 
            Text[bfm, x + vm, {-1.2, 0}], 
            Text[StringForm["````", "-τ ", bfm], 
              x + vb - tau vm, {1. , -1.3}], 
            Text[StringForm["````", "κ ", bfm], 
              x + vt + kappa vm, {0. , -1.3}], 
            Text[StringForm["````", "-κ ", bft], 
              x + vm - kappa vt, {1. , 0}], 
            Text[StringForm["````", "τ ", bfb], 
              x + vm + tau vb, {-0.9, -1.1}]}}, 
        ViewPoint -> {0, 0, 4}, ViewVertical -> {0, 1, 0}, 
        SphericalRegion -> True, 
        PlotRange -> {{-1, 2}, {-0.5, 1.5}, {-0.1, 0.1}}, 
        Boxed -> False, Axes -> False, Ticks -> Automatic, 
        Lighting -> False, 
        AxesLabel -> {"x", "y", "z"}, 
        TextStyle -> newTextStyle]

SetDirectory["/Users/martin/Desktop/mmasources"]

WriteLiveForm["chap10fig3.m", chap10fig3]

WriteHtmlPage["chap10fig3.html", "<FONT SIZE=+2><B>Figure \
10.3</B> [Farin 2002, page 183]</FONT>",  "chap10fig3.m", 800, 500, 
      independentVariables,  
      dependentVariables, "<PARAM NAME=BGCOLOR VALUE=#FFFFFF>\n<PARAM NAME=\
\"POINT_EDGE_COLOR\" VALUE=#000000>\n"]

Figure 10.4, page 184

Input: points b0, b1, b2, b3

Interaction: 
— free movement of b0, b1, b2, b3

Output: 
— curve, arrows, derivatives

SetDirectory["/Users/martin/Desktop/mmasources"]

<< Arrow3D`

SetOptions[Arrow3D, HeadLength -> 0.2];

ClearAll[b, db, t]

\(defineVector[{"b0", "b1", "b2", "b3", "x", "dxdt", "ddxddt", "dddxdddt", "vt", "vm", "vb", "vb1", "vc"}]\)

bernstein[i_, n_, t_] := 
      Binomial[n, i] t^i (1 - t)^(n - i)

b[t_] := 
      Sum[bernstein[i, 3, t]*Symbol["b" <> ToString[i]], {i, 0, 
          3}];

db[t_] = D[b[t], t]

ddb[t_] = D[b[t], {t, 2}]

dddb[t_] = D[b[t], {t, 3}]

iMax = 64; 
bpoints = 
      Table[{0, 0, -0.001} + b[i/iMax + 0.0000001], {i, 0, 
          iMax}];

iMax = 64; 
cpoints = 
      Table[N[vc + rho*Cos[2 Pi i/iMax]*vm + 
            rho*Sin[2 Pi i/iMax]*vt], {i, 0, iMax}];

independentVariables = 
      Flatten[{independentVariablesForVector["b0", {-0.5, 
              1.0, -0.5}], 
          independentVariablesForVector["b1", {-0.5, 0.8, 0.0}], 
          independentVariablesForVector["b2", {1.5, 0.4, 0. }], 
          independentVariablesForVector["b3", {1.5, 1.0, -0.5}], 
          t -> 0.3}]

dependentVariables = 
      Flatten[{t -> Max[0, Min[t, 1]], 
          dependentVariablesForVector["x", b[t]], 
          dependentVariablesForVector["dxdt", db[t]], 
          dependentVariablesForVector["ddxddt", ddb[t]], 
          dependentVariablesForVector["dddxdddt", dddb[t]], 
          dependentVariablesForVector["vt", dxdt/Sqrt[dxdt . dxdt]], 
          dependentVariablesForVector["vb1", Cross[dxdt, ddxddt]], 
          dependentVariablesForVector["vb", vb1/Sqrt[vb1 . vb1]], 
          dependentVariablesForVector["vm", Cross[vb, vt]], 
          kappa -> Sqrt[vb1 . vb1]/Sqrt[(dxdt . dxdt)^3], 
          rho -> Sqrt[(dxdt . dxdt)^3]/Sqrt[vb1 . vb1], 
          dependentVariablesForVector["vc", x + rho vm]}]

chap10fig4 := 
      Graphics3D[{{PointSize[0.04], RGBColor[0. , 1, 0. ], Point[b0], 
            Point[b1], Point[b2], Point[b3], Point[{t, 0, 0.01}], 
            GrayLevel[0], PointSize[0.02], Point[{0, 0, 0}], 
            Point[{1, 0, 0}], Point[x], Point[vc]}, {Thickness[0.01], 
            GrayLevel[0], Line[bpoints]}, {Thickness[0.005], GrayLevel[0. ], 
            Line[{b0 + {0, 0, -0.01}, b1 + {0, 0, -0.01}, 
                b2 + {0, 0, -0.01}, b3 + {0, 0, -0.01}}], 
            Thickness[0.005], GrayLevel[0.6], Line[cpoints], 
            Line[{vc, vc + rho vt}], GrayLevel[0], 
            Line[{{0, 0, 0}, {t - 0.01, 0, 0}}], 
            Line[{{t + 0.01, 0, 0}, {1, 0, 0}}]}, {Thickness[0.01], 
            EdgeForm[], GrayLevel[0], Arrow3D[x, x + vt], Arrow3D[x, x + vb], 
            Arrow3D[x, x + vm], GrayLevel[0.0], 
            Line[{x + vm, vc}]}, {Text[itt, {t, 0, 0.01}, {0, 1.5}], 
            Text["0", {0, 0, 0}, {0, 1.5}], 
            Text["1", {1, 0, 0}, {0, 1.5}], 
            Text[StringForm["````````", bfx, "(", itt, ")"], 
              x, {0, 1.5}], Text[bft, x + vt, {-1.1, 1.5}], 
            Text[bfb, x + vb, {-1.2, -1.2}], 
            Text[bfm, x + vm, {-1.2, 1.4}], 
            Text[bfc, vc, {-1.2, -1.4}], GrayLevel[0.6], 
            Text["ρ", vc + rho/2 vt, {-1.2, -1.4}]}}, 
        ViewPoint -> {0, 0, 4}, ViewVertical -> {0, 1, 0}, 
        SphericalRegion -> True, 
        PlotRange -> {{-1, 2}, {-0.5, 1.5}, {-0.1, 0.1}}, 
        Boxed -> False, Axes -> False, Ticks -> Automatic, 
        Lighting -> False, 
        AxesLabel -> {"x", "y", "z"}, 
        TextStyle -> newTextStyle]

SetDirectory["/Users/martin/Desktop/mmasources"]

WriteLiveForm["chap10fig4.m", chap10fig4]

WriteHtmlPage["chap10fig4.html", "<FONT SIZE=+2><B>Figure \
10.4</B> [Farin 2002, page 184]</FONT>",  "chap10fig4.m", 800, 500, 
      independentVariables,  
      dependentVariables, "<PARAM NAME=BGCOLOR VALUE=#FFFFFF>\n<PARAM NAME=\
\"POINT_EDGE_COLOR\" VALUE=#000000>\n"]

Figures for Chapter 19

Figure 19.1, page 350

Input: point u, quadratic Bezier patch points b00, b01, b02, b10, b11, b12, b20, b21, b22

Interaction: 
— free movement of u

Output: 
— boundary curves of Bezier patch, coordinate axes, normal vector, partial derivatives

SetDirectory["/Users/martin/Desktop/mmasources"]

<< Arrow3D`

SetOptions[Arrow3D, HeadLength -> 0.2];

ClearAll[b, xu, xv, normal]

\(defineVector[{"normal", "x", "xu", "xv", "b00", "b01", "b02", "b10", "b11", "b12", \ "b20", "b21", "b22"}]\)

bernstein[i_, n_, t_] := 
      Binomial[n, i] t^i (1 - t)^(n - i)

b[u_, v_] := 
      Sum[bernstein[i, 2, u]*bernstein[j, 2, v]*
          Symbol["b" <> ToString[i] <> ToString[j]], {i, 0, 2}, {j, 0, 
          2}]

dbdu[u_, v_] = D[b[u, v], u]; 
dbdv[u_, v_] = D[b[u, v], v];

iMax = 32; 
ba0points = 
      Table[b[i/iMax + 10. ^-10, 10. ^-10], {i, 0, 
          iMax}]; 
ba1points = 
      Table[b[i/iMax + 10. ^-10, 1 + 10. ^-10], {i, 0, 
          iMax}]; 
b0apoints = 
      Table[b[10. ^-10, i/iMax + 10. ^-10], {i, 0, 
          iMax}]; 
b1apoints = 
      Table[b[1 + 10. ^-10, i/iMax + 10. ^-10], {i, 0, 
          iMax}]; 
bavpoints = 
      Table[b[i/iMax + 10. ^-10, v], {i, 0, 
          iMax}]; 
buapoints = 
      Table[b[u, i/iMax + 10. ^-10], {i, 0, 
          iMax}];

\(independentVariables = 
      Flatten[{u -> 0.5, 
          v -> 
            0.5, 
independentVariablesForVector["b00", {\(-3\), 0.5, 0. }], 
          independentVariablesForVector["b10", {\(-2.5\), 0.5, 0.5}], 
          independentVariablesForVector["b20", {\(-2\), 0.2, 1}], 
          independentVariablesForVector["b01", {\(-2.7\), 
              0.9, \(-0.3\)}], 
          independentVariablesForVector["b11", {\(-2.1\), 1.1, 0. }], 
          independentVariablesForVector["b21", {\(-1.5\), 0.3, 0.8}], 
          independentVariablesForVector["b02", {\(-2. \), 
              1.0, \(-1.5\)}], 
          independentVariablesForVector["b12", {\(-1.5\), 
              1.2, \(-1. \)}], 
          independentVariablesForVector["b22", {\(-0.5\), 
              0.6, \(-0.5\)}]}]\)

\(dependentVariables = 
      Flatten[{u -> Max[0, Min[1, u]], 
          v -> 
            Max[0, Min[1, 
                v]], 
dependentVariablesForVector["x", 
            b[u, v]], dependentVariablesForVector["xu", dbdu[u, v]], 
          dependentVariablesForVector["xv", 
            dbdv[u, v]], 
dependentVariablesForVector["normal", 
            Cross[xu, xv]/Sqrt[Cross[xu, xv] . Cross[xu, xv]]]}]; \)

chap19fig1 := 
      Graphics3D[{{PointSize[0.02], RGBColor[0. , 1, 0. ], Point[b00], 
            Point[b01], Point[b02], Point[b10], Point[b11], Point[b12], 
            Point[b20], Point[b21], Point[b22], PointSize[0.04], 
            Point[{u, v, 0.0001}], GrayLevel[0], PointSize[0.02], 
            Point[x]}, {Thickness[0.005], GrayLevel[0], Line[ba0points], 
            Line[ba1points], Line[b0apoints], Line[b1apoints], 
            Line[bavpoints], Line[buapoints]}, {Thickness[0.005], 
            Line[{{0, 0, 0}, {1, 0, 0}}], Line[{{0, 1, 0}, {1, 1, 0}}], 
            Line[{{0, 0, 0}, {0, 1, 0}}], Line[{{1, 0, 0}, {1, 1, 0}}], 
            Line[{{u, 0, 0}, {u, v, 0}}], Line[{{0, v, 0}, {u, v, 0}}], 
            Line[{{u, v, 0}, {u, 1, 0}}], 
            Line[{{u, v, 0}, {1, v, 0}}]}, {Thickness[0.01], EdgeForm[], 
            GrayLevel[0], Arrow3D[x, x + xu], Arrow3D[x, x + xv], 
            Arrow3D[x, x + normal]}, {Thickness[0.005], EdgeForm[], 
            GrayLevel[0], 
            Arrow3D[b00 - 0.5 (b01 - b00), 
              b00 - 0.5 (b01 - b00) + 0.5 (b10 - b00)], 
            Text[itu, 
              b00 - 0.5 (b01 - b00) + 0.5 (b10 - b00), {-1.4, 
                0.5}], Arrow3D[b00 - 0.5 (b10 - b00), 
              b00 - 0.5 (b10 - b00) + 0.5 (b01 - b00)], 
            Text[itv, 
              b00 - 0.5 (b10 - b00) + 
                0.5 (b01 - b00), {-1.3, -1.3}]}, {Text[bfx, 
              x, {0, 1.1}], Text[bfn, x + normal, {0, -1.1}], 
            Text[bfxv, x + xv, {-1.1, -0.9}], 
            Text[bfxu, x + xu, {-1.1, 0.9}], 
            Text[bfu, {u, v, 0}, {1.2, 0.9}],   Text[
              StringForm["`` = const", itu], {u, 1, 0}, {0, -1.2}], 
            Text[StringForm["`` = const", itv], {1, v, 0}, {-1.1, 
                0}], Text[
              StringForm["````-plane", itu, itv], {0.5, 0, 0}, {0, 
                1.2}]}}, ViewPoint -> {0, 0, 4}, 
        ViewVertical -> {0, 1, 0}, SphericalRegion -> True, 
        PlotRange -> {{-2. , 1.0}, {-0.1, 1.1}, {-1.1, 
              1.1}}, Boxed -> False, Axes -> False, 
        Lighting -> False, Ticks -> Automatic, 
        AxesLabel -> {"x", "y", "z"}, 
        TextStyle -> newTextStyle]

Show[chap19fig1 //. 
          Join[independentVariables, 
            dependentVariables] /. {(Lighting -> 
                False) -> Lighting -> None}]

SetDirectory["/Users/martin/Desktop/mmasources"]

WriteLiveForm["chap19fig1.m", chap19fig1]

WriteHtmlPage["chap19fig1.html", "<FONT SIZE=+2><B>Figure \
19.1</B> [Farin 2002, page 350]</FONT>",  "chap19fig1.m", 800, 500, 
      independentVariables,  
      dependentVariables, "<PARAM NAME=BGCOLOR VALUE=#FFFFFF>\n<PARAM NAME=\
\"POINT_EDGE_COLOR\" VALUE=#000000>\n"]

Figure 19.2, page 351

Input: point u, point udu, point udv, quadratic Bezier patch points b00, b01, b02, b10, b11, b12, b20, b21, b22

Interaction: 
— free movement of u, v
—

Output: 
— boundary curves of Bezier patch, coordinate axes, normal vector, partial derivatives

SetDirectory["/Users/martin/Desktop/mmasources"]

<< Arrow3D`

SetOptions[Arrow3D, HeadLength -> 0.2];

ClearAll[b, xu, xv, normal, u, v, du, dv]

\(defineVector[{"normal", "x", "xu", "xv", "b00", "b01", "b02", "b10", "b11", "b12", \ "b20", "b21", "b22"}]\)

bernstein[i_, n_, t_] := 
      Binomial[n, i] t^i (1 - t)^(n - i)

b[u_, v_] := 
      Sum[bernstein[i, 2, u]*bernstein[j, 2, v]*
          Symbol["b" <> ToString[i] <> ToString[j]], {i, 0, 2}, {j, 0, 
          2}]

dbdu[u_, v_] = D[b[u, v], u]; 
dbdv[u_, v_] = D[b[u, v], v];

iMax = 32; 
ba0points = 
      Table[b[i/iMax + 10. ^-10, 10. ^-10], {i, 0, 
          iMax}]; 
ba1points = 
      Table[b[i/iMax + 10. ^-10, 1 + 10. ^-10], {i, 0, 
          iMax}]; 
b0apoints = 
      Table[b[10. ^-10, i/iMax + 10. ^-10], {i, 0, 
          iMax}]; 
b1apoints = 
      Table[b[1 + 10. ^-10, i/iMax + 10. ^-10], {i, 0, 
          iMax}]; 
bavpoints = 
      Table[b[i/iMax + 10. ^-10, v], {i, 0, 
          iMax}]; 
bavdvpoints = 
      Table[b[i/iMax + 10. ^-10, v + dv], {i, 0, 
          iMax}]; 
buapoints = 
      Table[b[u, i/iMax + 10. ^-10], {i, 0, 
          iMax}]; 
buduapoints = 
      Table[b[u + du, i/iMax + 10. ^-10], {i, 0, 
          iMax}];

\(independentVariables = 
      Flatten[{u -> 0.6, v -> 0.6, udu -> 0.8, 
          vdv -> 0.8, uOld -> 0.6, 
          vOld -> 
            0.6, 
independentVariablesForVector["b00", {\(-3\), 0.5, 0. }], 
          independentVariablesForVector["b10", {\(-2.5\), 0.5, 0.5}], 
          independentVariablesForVector["b20", {\(-2\), 0.2, 1}], 
          independentVariablesForVector["b01", {\(-2.7\), 
              0.9, \(-0.3\)}], 
          independentVariablesForVector["b11", {\(-2.1\), 1.1, 0. }], 
          independentVariablesForVector["b21", {\(-1.5\), 0.3, 0.8}], 
          independentVariablesForVector["b02", {\(-2. \), 
              1.0, \(-1.5\)}], 
          independentVariablesForVector["b12", {\(-1.5\), 
              1.2, \(-1. \)}], 
          independentVariablesForVector["b22", {\(-0.5\), 
              0.6, \(-0.5\)}]}]; \)

(dependentVariables = 
        Flatten[{
u -> 
              Max[0, Min[1, u]], 
v -> 
              Max[0, Min[1, v]], 
udu -> 
              If[u == uOld, 
                udu, (u - uOld) + udu], 
vdv -> 
              If[v == vOld, 
                vdv, (v - vOld) + vdv], 
du -> 
              udu - u, 
dv -> 
              vdv - v, 
uOld -> 
              u, 
vOld -> 
              v, 
dependentVariablesForVector["x", 
              b[u, v]], dependentVariablesForVector["xu", dbdu[u, v]], 
            dependentVariablesForVector["xv", 
              dbdv[u, v]]}]);

chap19fig2 := 
      Graphics3D[{{PointSize[0.02], RGBColor[0. , 1, 0. ], Point[b00], 
            Point[b01], Point[b02], Point[b10], Point[b11], Point[b12], 
            Point[b20], Point[b21], Point[b22], PointSize[0.04], 
            Point[{u, v, 0.00001}], Point[{udu, v, 0.00001}], 
            Point[{u, vdv, 0.00001}], GrayLevel[0], PointSize[0.02], 
            Point[x]}, {Thickness[0.005], GrayLevel[0], Line[ba0points], 
            Line[ba1points], Line[b0apoints], Line[b1apoints], 
            Line[bavpoints], Line[bavdvpoints], Line[buapoints], 
            Line[buduapoints]}, {Thickness[0.005], 
            Line[{{0, 0, 0}, {1, 0, 0}}], Line[{{0, 1, 0}, {1, 1, 0}}], 
            Line[{{0, 0, 0}, {0, 1, 0}}], Line[{{1, 0, 0}, {1, 1, 0}}], 
            Line[{{u, 0, 0}, {u, v, 0}}], Line[{{u, v, 0}, {u, v + dv, 0}}], 
            Line[{{u, v + dv, 0}, {u, 1, 0}}], Line[{{0, v, 0}, {u, v, 0}}], 
            Line[{{u, v, 0}, {u + du, v, 0}}], 
            Line[{{u + du, v, 0}, {1, v, 0}}], 
            Line[{{u + du, 0, 0}, {u + du, v, 0}}], 
            Line[{{u + du, v, 0}, {u + du, v + dv, 0}}], 
            Line[{{u + du, v + dv, 0}, {u + du, 1, 0}}], 
            Line[{{0, v + dv, 0}, {u, v + dv, 0}}], 
            Line[{{u, v + dv, 0}, {u + du, v + dv, 0}}], 
            Line[{{u + du, v + dv, 0}, {1, v + dv, 0}}], 
            EdgeForm[{GrayLevel[0], Thickness[0.005]}], GrayLevel[0.7], 
            Polygon[{{u, v, 0}, {u + du, v, 0}, {u + du, v + dv, 0}, {u, 
                  v + dv, 0}}]}, {Thickness[0.01], EdgeForm[], GrayLevel[0], 
            Arrow3D[x, x + xu*du], Arrow3D[x, x + xv*dv]}, {Thickness[0.005], 
            EdgeForm[], GrayLevel[0], 
            Arrow3D[b00 - 0.5 (b01 - b00), 
              b00 - 0.5 (b01 - b00) + 0.5 (b10 - b00)], 
            Text[itu, 
              b00 - 0.5 (b01 - b00) + 0.5 (b10 - b00), {-1.4, 
                0.5}], Arrow3D[b00 - 0.5 (b10 - b00), 
              b00 - 0.5 (b10 - b00) + 0.5 (b01 - b00)], 
            Text[itv, 
              b00 - 0.5 (b10 - b00) + 
                0.5 (b01 - b00), {-1.3, -1.3}], 
            EdgeForm[{GrayLevel[0], Thickness[0.005]}], GrayLevel[0.7], 
            Polygon[{x, x + xu*du, x + xu*du + xv*dv, x + xv*dv}]}, {Text[
              bfx, x, {1.2, 0.9}], 
            Text[StringForm["``d``", bfxv, itv], 
              x + xv*dv, {-1.1, -0.9}], 
            Text[StringForm["``d``", bfxu, itu], 
              x + xu*du, {-1.1, 0.9}], Text[bfu, {u, v, 0}, {1.2, 0.9}], 
            Text[StringForm["d``", itu], {u + du/2, 0, 0}, {0, 1.2}], 
            Text[StringForm["d``", itv], {1, v + dv/2, 0}, {-1.2, 
                0}]}}, ViewPoint -> {0, 0, 4}, 
        ViewVertical -> {0, 1, 0}, SphericalRegion -> True, 
        PlotRange -> {{-2. , 1.0}, {-0.1, 1.1}, {-1.1, 
              1.1}}, Boxed -> False, Axes -> False, 
        Lighting -> False, Ticks -> Automatic, 
        AxesLabel -> {"x", "y", "z"}, 
        TextStyle -> newTextStyle]

Show[chap19fig2 //. 
          Join[independentVariables, 
            dependentVariables] /. {(Lighting -> 
                False) -> Lighting -> None}]

SetDirectory["/Users/martin/Desktop/mmasources"]

WriteLiveForm["chap19fig2.m", chap19fig2]

WriteHtmlPage["chap19fig2.html", "<FONT SIZE=+2><B>Figure \
19.2</B> [Farin 2002, page 351]</FONT>",  "chap19fig2.m", 800, 500, 
      independentVariables,  
      dependentVariables, "<PARAM NAME=BGCOLOR VALUE=#FFFFFF>\n<PARAM NAME=\
\"POINT_EDGE_COLOR\" VALUE=#000000>\n"]

Figure 19.4, page 353

Input: point u, point udu, point udv, quadratic Bezier patch points b00, b01, b02, b10, b11, b12, b20, b21, b22

Interaction: 
— free movement of u, v
—

Output: 
— boundary curves of Bezier patch, coordinate axes, normal vector, partial derivatives

SetDirectory["/Users/martin/Desktop/mmasources"]

<< Arrow3D`

SetOptions[Arrow3D, HeadLength -> 0.2];

ClearAll[b, xu, xv, normal, u, v, du, dv]

\(defineVector[{"normal", "x", "xu", "xv", "b00", "b01", "b02", "b10", "b11", "b12", \ "b20", "b21", "b22", "dxdt", "ddxddt", "dddxdddt", "vt", "vb1", "vb", "vm", "vc", "vcn"}]\)

bernstein[i_, n_, t_] := 
      Binomial[n, i] t^i (1 - t)^(n - i)

b[u_, v_] := 
      Sum[bernstein[i, 2, u]*bernstein[j, 2, v]*
          Symbol["b" <> ToString[i] <> ToString[j]], {i, 0, 2}, {j, 0, 
          2}]

dbdu[u_, v_] = D[b[u, v], u]; 
dbdv[u_, v_] = D[b[u, v], v];

u[t_] := 
      u*(1 - t)^2 + 2*udu*t (1 - t) + 
        uddu*t*t; 
v[t_] := v*(1 - t)^2 + 2*vdv*t (1 - t) + vddv*t*t;

iMax = 32; 
ba0points = 
      Table[b[i/iMax + 10. ^-10, 10. ^-10], {i, 0, 
          iMax}]; 
ba1points = 
      Table[b[i/iMax + 10. ^-10, 1 + 10. ^-10], {i, 0, 
          iMax}]; 
b0apoints = 
      Table[b[10. ^-10, i/iMax + 10. ^-10], {i, 0, 
          iMax}]; 
b1apoints = 
      Table[b[1 + 10. ^-10, i/iMax + 10. ^-10], {i, 0, 
          iMax}]; 
bavpoints = 
      Table[b[i/iMax + 10. ^-10, v], {i, 0, 
          iMax}]; 
buapoints = 
      Table[b[u, i/iMax + 10. ^-10], {i, 0, 
          iMax}]; 
upoints = 
      Table[{u[2 i/iMax + 10. ^-10], v[2 i/iMax + 10. ^-10], 
          0}, {i, -iMax/4, iMax/2}]; 
btpoints = 
      Table[b[u[2 i/iMax + 10. ^-10], 
          v[2 i/iMax + 10. ^-10]], {i, -iMax/4, 
          iMax/2}];

db[t_] = D[b[u[t], v[t]], t];

ddb[t_] = D[b[u[t], v[t]], {t, 2}];

dddb[t_] = D[b[u[t], v[t]], {t, 3}];

iMax = 64; 
cpoints = 
      Table[N[vc + rho*Cos[2 Pi i/iMax]*vm + 
            rho*Sin[2 Pi i/iMax]*vt], {i, 0, 
          iMax}]; 
cnpoints = 
      Table[N[vcn + rhon*Cos[2 Pi i/iMax]*normal + 
            rhon*Sin[2 Pi i/iMax]*vt], {i, 0, iMax}];

\(independentVariables = 
      Flatten[{u -> 0.2, v -> 0.5, uOld -> 0.2, 
          vOld -> 0.5, 
udu -> 0.35, 
          vdv -> 0.7, 
uddu -> 0.45, 
          vddv -> 
            0.9, 
independentVariablesForVector["b00", {\(-3\), 0.5, 0. }], 
          independentVariablesForVector["b10", {\(-2.5\), 0.5, 0.5}], 
          independentVariablesForVector["b20", {\(-2\), 0.2, 1}], 
          independentVariablesForVector["b01", {\(-2.7\), 
              0.9, \(-0.3\)}], 
          independentVariablesForVector["b11", {\(-2.1\), \(-1.5\), \(-0.5\)}], independentVariablesForVector["b21", {\(-1.5\), 0.3, 0.8}], 
          independentVariablesForVector["b02", {\(-2. \), 
              1.0, \(-1.5\)}], 
          independentVariablesForVector["b12", {\(-1.5\), 
              1.2, \(-1. \)}], 
          independentVariablesForVector["b22", {\(-0.5\), 
              0.6, \(-0.5\)}]}]; \)

\(\((dependentVariables = 
        Flatten[{
u -> 
              Max[0, Min[1, u]], 
v -> 
              Max[0, Min[1, v]], 
udu -> 
              If[u == uOld, 
                udu, \((u - uOld)\) + udu], 
vdv -> 
              If[v == vOld, 
                vdv, \((v - vOld)\) + vdv], 
uddu -> 
              If[u == uOld, 
                uddu, \((u - uOld)\) + uddu], 
vddv -> 
              If[v == vOld, 
                vddv, \((v - vOld)\) + vddv], 
du -> 
              udu - u, 
dv -> 
              vdv - v, 
ddu -> 
              uddu - udu, 
ddv -> 
              vddv - vdv, 
uOld -> 
              u, 
vOld -> 
              v, 
dependentVariablesForVector["x", 
              b[u, v]], dependentVariablesForVector["xu", dbdu[u, v]], 
            dependentVariablesForVector["xv", dbdv[u, v]], 
            dependentVariablesForVector["normal", 
              Cross[xu, xv]/Sqrt[Cross[xu, xv] . Cross[xu, xv]]], 
            dependentVariablesForVector["dxdt", db[0]], 
            dependentVariablesForVector["ddxddt", ddb[0]], 
            dependentVariablesForVector["dddxdddt", dddb[0]], 
            dependentVariablesForVector["vt", dxdt/Sqrt[dxdt . dxdt]], 
            dependentVariablesForVector["vb1", Cross[dxdt, ddxddt]], 
            dependentVariablesForVector["vb", vb1/Sqrt[vb1 . vb1]], 
            dependentVariablesForVector["vm", Cross[vb, vt]], 
            kappa -> Sqrt[vb1 . vb1]/Sqrt[\((dxdt . dxdt)\)^3], 
            rho -> Sqrt[\((dxdt . dxdt)\)^3]/Sqrt[vb1 . vb1], 
            dependentVariablesForVector["vc", 
              x + rho\ vm], 
cosphi -> 
              vm . normal, 
rhon -> 
              rho/cosphi, 
dependentVariablesForVector["vcn", 
              x + rhon\ normal]}])\); \)

chap19fig4 := 
      Graphics3D[{{PointSize[0.02], RGBColor[0. , 1, 0. ], Point[b00], 
            Point[b01], Point[b02], Point[b10], Point[b11], Point[b12], 
            Point[b20], Point[b21], Point[b22], PointSize[0.04], 
            Point[{u, v, 0.00001}], Point[{udu, vdv, 0.00001}], 
            Point[{uddu, vddv, 0.00001}], GrayLevel[0], PointSize[0.02], 
            Point[x]}, {Thickness[0.0025], GrayLevel[0], Line[ba0points], 
            Line[ba1points], Line[b0apoints], Line[b1apoints], 
            Line[bavpoints], Line[buapoints], Thickness[0.005], 
            Line[btpoints]}, {Thickness[0.0025], 
            Line[{{0, 0, 0}, {1, 0, 0}}], Line[{{0, 1, 0}, {1, 1, 0}}], 
            Line[{{0, 0, 0}, {0, 1, 0}}], Line[{{1, 0, 0}, {1, 1, 0}}], 
            Line[{{u, 0, 0}, {u, v, 0}}], Line[{{u, v, 0}, {u, 1, 0}}], 
            Line[{{0, v, 0}, {u, v, 0}}], Line[{{u, v, 0}, {1, v, 0}}], 
            Thickness[0.005], Line[upoints]}, {Thickness[0.01], EdgeForm[], 
            GrayLevel[0], Arrow3D[x, x + normal]}, {Thickness[0.005], 
            EdgeForm[], GrayLevel[0], 
            Arrow3D[b00 - 0.5 (b01 - b00), 
              b00 - 0.5 (b01 - b00) + 0.5 (b10 - b00)], 
            Text[itu, 
              b00 - 0.5 (b01 - b00) + 0.5 (b10 - b00), {-1.4, 
                0.5}], Arrow3D[b00 - 0.5 (b10 - b00), 
              b00 - 0.5 (b10 - b00) + 0.5 (b01 - b00)], 
            Text[itv, 
              b00 - 0.5 (b10 - b00) + 
                0.5 (b01 - b00), {-1.3, -1.3}]}, {Text[bfx, 
              x, {1.2, 0.9}], Text[bfn, x + normal, {-1.2, 1.1}], 
            Text[bfu, {u, v, 0}, {1.2, 0.9}], 
            Text[StringForm["````-plane", itu, itv], {0.5, 0, 0}, {0, 
                1.2}]}, {Thickness[0.01], EdgeForm[], GrayLevel[0], 
            Arrow3D[x, x + vt], Text[bft, x + vt, {-1.1, 1.1}], 
            Arrow3D[x, x + vm], Text[bfm, x + vm, {1.2, 1.2}], GrayLevel[0], 
            PointSize[0.02], Point[vc], Thickness[0.005], Line[{x + vm, vc}], 
            Text[bfc, vc, {-1.2, -1.4}], Thickness[0.005], 
            GrayLevel[0.6], Line[cpoints], GrayLevel[0.6], PointSize[0.02], 
            Point[vcn], Thickness[0.005], Line[{x + normal, vcn}], 
            Text[Subscript[bfc, "n"], vcn, {-1. , -1.1}], 
            Thickness[0.005], GrayLevel[0.6], Line[cnpoints]}}, 
        ViewPoint -> {0, 0, 4}, ViewVertical -> {0, 1, 0}, 
        SphericalRegion -> True, 
        PlotRange -> {{-2. , 1.0}, {-0.1, 1.1}, {-1.1, 
              1.1}}, Boxed -> False, Axes -> False, 
        Lighting -> False, Ticks -> Automatic, 
        AxesLabel -> {"x", "y", "z"}, 
        TextStyle -> newTextStyle]

SetDirectory["/Users/martin/Desktop/mmasources"]

WriteLiveForm["chap19fig4.m", chap19fig4]

WriteHtmlPage["chap19fig4.html", "<FONT SIZE=+2><B>Figure \
19.4</B> [Farin 2002, page 353]</FONT>",  "chap19fig4.m", 800, 500, 
      independentVariables,  
      dependentVariables, "<PARAM NAME=BGCOLOR VALUE=#FFFFFF>\n<PARAM NAME=\
\"POINT_EDGE_COLOR\" VALUE=#000000>\n"]

Figures for Chapter 21

general subdivision code

triangulateQuads[complex : polygonComplex[vertices_, polygons_]] := 
      Module[{a, b, c, d}, 
        complex /. 
          Polygon[{a_, b_, c_, d_}] :> {Polygon[{a, b, c}], 
              Polygon[{c, d, a}]}]

showComplex[complex : polygonComplex[vertices_, polygons_]] := 
      Module[{i}, 
        Show[Graphics3D[
            polygons /. i_Integer :> vertices[[i]]], 
          Boxed -> False, 
          PlotRange -> {{-0.1, 1.1}, {-0.1, 1.1}, {-0.1, 
                1.1}}]]

primitivesComplex[complex : polygonComplex[vertices_, polygons_]] := 
      Module[{i}, 
        polygons /. 
          i_Integer :> N[Expand[vertices[[i]]]]]

edgesComplex[complex : polygonComplex[vertices_, polygons_]] := 
      Module[{indices}, 
        Union[Flatten[
            Flatten[polygons] /. 
              Polygon[indices_] :> 
                Map[Sort, Transpose[{indices, RotateLeft[indices]}]], 
            1]]]

edgesPolygon[polygon : Polygon[indices_]] := 
      Module[{}, 
        Union[Map[Sort, 
            Transpose[{indices, RotateLeft[indices]}]]]]

vertexCoordinates[vertices_, vertexIndex_] := 
      Module[{}, vertices[[vertexIndex]]]

vertexNeighbors[edges_, vertexIndex_] := 
      Module[{i}, 
        Cases[Union[
            Flatten[Cases[edges, {vertexIndex, i_} | {i_, vertexIndex}]]], 
          i_ /; i ≠ vertexIndex]]

commonVertexNeighbors[edges_, {vertexIndex1_, vertexIndex2_}] := 
      Module[{neighbors1 = vertexNeighbors[edges, vertexIndex1], 
          neighbors2 = vertexNeighbors[edges, vertexIndex2]}, 
        Intersection[neighbors1, neighbors2]]

polygonNeighbors[polygons_, {vertexIndex1_, vertexIndex2_}] := 
      Module[{}, 
        Select[polygons, (MemberQ[#[[1]], vertexIndex1] && 
                MemberQ[#[[1]], vertexIndex2]) &]]

polygonNeighbors[polygons_, vertexIndex_Integer] := 
      Module[{}, 
        Select[polygons, (MemberQ[#[[1]], 
                vertexIndex]) &]]

boundaryEdgeQ[polygons_, {vertexIndex1_, vertexIndex2_}] := 
      Module[{}, 
        Length[polygonNeighbors[polygons, {vertexIndex1, vertexIndex2}]] < 
          2]

boundaryVertexQ[edges_, polygons_, vertexIndex_] := 
      Module[{incident, i}, 
        incident = Cases[edges, {vertexIndex, i_} | {i_, vertexIndex}]; 
        Apply[Or, Map[boundaryEdgeQ[polygons, #] &, incident]]]

edgeIndex[edges_, {vertexIndex1_, vertexIndex2_}] := 
      Module[{sorted = {Min[vertexIndex1, vertexIndex2], 
              Max[vertexIndex1, vertexIndex2]}}, Position[edges, 
            sorted][[1, 1]]]

polygonIndex[polygons_, poly_Polygon] := 
      Module[{}, Position[polygons, poly][[1, 1]]]

splitVertexIndex[polygons_, indexedVertices_, poly_Polygon, 
          vertexIndex_] := 
        Module[{polyIndex}, 
          polyIndex = Position[polygons, poly][[1, 1]]; Position[
              indexedVertices, {polyIndex, vertexIndex}][[1, 
              1]]];

(* Doo - Sabin subdivision,  Figure 21.4,  
      page 382 in Section 21.2 of [Farin,  2002] *)

dooSabinSubdivision[complex : polygonComplex[vertices_, polygons_]] := 
        Module[{polys = Flatten[polygons], edges = edgesComplex[complex], 
            verticesNew, indexedVertices, vertexPolygons, edgePolygons, 
            polygonPolygons, polygonsNew}, 
          indexedVertices = 
            Flatten[MapIndexed[(Transpose[{Table[#2[[1]], {Length[#1[[1]]]}], #1[[1]]}]) &, polys], 
              1]; 
verticesNew = 
            Map[dooSabinSubdivisionNewVertexCoordinates[vertices, 
                  polys, #] &, 
              indexedVertices]; 
polygonPolygons = 
            Map[dooSabinSubdivisionNewPolygonPolygons[vertices, polys, 
                  indexedVertices, #] &, 
              polys]; 
edgePolygons = 
            Map[dooSabinSubdivisionNewEdgePolygons[vertices, polys, 
                  indexedVertices, #] &, edges]; 
          vertexPolygons = 
            Map[dooSabinSubdivisionNewVertexPolygons[vertices, edges, polys, 
                  indexedVertices, #] &, 
              Range[Length[vertices]]]; 
polygonsNew = 
            Flatten[{polygonPolygons, edgePolygons, vertexPolygons}, 
              1]; 
polygonComplex[verticesNew, 
            polygonsNew]];

dooSabinSubdivisionNewVertexCoordinates[vertices_, 
        polygons_, {polygonIndex_, vertexIndex_}] := 
      Module[{indices = polygons[[polygonIndex, 1]]}, 
        indices = 
          RotateLeft[
            indices, Position[indices, vertexIndex][[1]] - 1]; 
        Apply[Plus, 
          MapIndexed[(If[#2[[1]] == 
                      1, (Length[indices] + 5)/(4*
                          Length[indices]), (3 + 
                          2*Cos[2 Pi (#2[[1]] - 1)/
                                  Length[indices]])/(4*
                          Length[indices])]*
                  vertexCoordinates[vertices, #1]) &, indices]]]

dooSabinSubdivisionNewPolygonPolygons[vertices_, polygons_, 
        indexedVertices_, Polygon[indices_]] := 
      Module[{polyIndex = polygonIndex[polygons, Polygon[indices]]}, 
        Polygon[Map[
            splitVertexIndex[polygons, indexedVertices, 
                Polygon[indices], #] &, indices]]]

dooSabinSubdivisionNewEdgePolygons[vertices_, polygons_, 
        indexedVertices_, {vertexIndex1_, vertexIndex2_}] := 
      Module[{polys = 
            polygonNeighbors[polygons, {vertexIndex1, vertexIndex2}]}, 
        If[Length[polys] ≠ 2, {},   
            If[FreeQ[
              Partition[Append[polys[[1, 1]], First[polys[[1, 1]]]], 
                2, 1], {vertexIndex1, vertexIndex2}], 
            polys = Reverse[polys]]; 
          Polygon[{splitVertexIndex[polygons, indexedVertices, 
                polys[[1]], vertexIndex1], 
              splitVertexIndex[polygons, indexedVertices, polys[[2]], 
                vertexIndex1], 
              splitVertexIndex[polygons, indexedVertices, polys[[2]], 
                vertexIndex2], 
              splitVertexIndex[polygons, indexedVertices, polys[[1]], 
                vertexIndex2]}]]]

dooSabinSubdivisionNewVertexPolygons[vertices_, edges_, polygons_, 
        indexedVertices_, vertexIndex_] := 
      Module[{polys = {}, 
          polyNeighbors = polygonNeighbors[polygons, vertexIndex], 
          currentNeighbor = 0, firstNeighbor, currentPoly, nextNeighbor}, 
        If[boundaryVertexQ[edges, polygons, vertexIndex], Return[{}]]; 
        firstNeighbor = vertexNeighbors[edges, vertexIndex][[1]]; 
        nextNeighbor = firstNeighbor; 
        While[currentNeighbor ≠ 
            firstNeighbor, 
currentNeighbor = 
            nextNeighbor; 
currentPoly = Join[
                Cases[polyNeighbors, 
                  Polygon[{___, vertexIndex, currentNeighbor, ___}]], 
                Cases[polyNeighbors, 
                  Polygon[{currentNeighbor, ___, 
                      vertexIndex}]]][[1]]; 
nextNeighbor = 
            Part[Prepend[currentPoly[[1]], 
                Last[currentPoly[[1]]]], Position[currentPoly[[1]], 
                  vertexIndex][[1, 1]]]; 
          AppendTo[polys, currentPoly]; 
currentNeighbor = 
            nextNeighbor]; 
        Polygon[Map[
            splitVertexIndex[polygons, indexedVertices, #, vertexIndex] &, 
            polys]]]

(* Catmull - Clark subdivision,  Figure 21.6,  
      page 384 in Section 21.3 of [Farin,  2002] *)

catmullClarkSubdivision[
          complex : polygonComplex[vertices_, polygons_]] := 
        Module[{polys = Flatten[polygons], edges = edgesComplex[complex], 
            verticesLength = Length[vertices], faceVertices, edgeVertices, 
            verticesNew, polygonsNew}, 
          faceVertices = 
            Map[catmullClarkSubdivisionNewFaceVertexCoordinates[
                  vertices, #] &, polys]; 
edgeVertices = 
            Map[catmullClarkSubdivisionNewEdgeVertexCoordinates[vertices, 
                  polys, faceVertices, #] &, 
              edges]; 
verticesNew = 
            Flatten[{Map[
                  catmullClarkSubdivisionNewVertexCoordinates[vertices, 
                      edges, polys, faceVertices, edgeVertices, #] &, 
                  Range[verticesLength]], faceVertices, edgeVertices}, 
              1]; 
polygonsNew = 
            Map[catmullClarkSubdivisionNewPolygon[vertices, edges, 
                  polys, #] &, polys]; 
          polygonComplex[verticesNew, polygonsNew]];

catmullClarkSubdivisionNewFaceVertexCoordinates[vertices_, 
        Polygon[indices_]] := 
      Module[{}, 
        Apply[Plus, Map[vertexCoordinates[vertices, #] &, indices]]/
          Length[indices]]

catmullClarkSubdivisionNewEdgeVertexCoordinates[vertices_, polygons_, 
        faceVertices_, {vertexIndex1_, vertexIndex2_}] := 
      Module[{faceVertexIndices = 
            Map[(polygonIndex[polygons, #]) &, 
              polygonNeighbors[polygons, {vertexIndex1, vertexIndex2}]]}, 
        If[Length[faceVertexIndices] < 2, 
          vertexCoordinates[vertices, vertexIndex1]/2 + 
            vertexCoordinates[vertices, vertexIndex2]/2, 
          vertexCoordinates[vertices, vertexIndex1]/4 + 
            vertexCoordinates[vertices, vertexIndex2]/4 + 
            vertexCoordinates[faceVertices, faceVertexIndices[[1]]]/4 + 
            vertexCoordinates[faceVertices, faceVertexIndices[[2]]]/
              4]]

catmullClarkSubdivisionNewVertexCoordinates[vertices_, edges_, 
        polygons_, faceVertices_, edgeVertices_, vertexIndex_] := 
      Module[{neighbors = vertexNeighbors[edges, vertexIndex], 
          neighborsLength, weight, i, incident, faceVertexIndices, 
          edgeVertexIndices}, 
        incident = Cases[edges, {vertexIndex, i_} | {i_, vertexIndex}]; 
        faceVertexIndices = 
          Map[(polygonIndex[polygons, #]) &, 
            polygonNeighbors[polygons, vertexIndex]]; 
        edgeVertexIndices = 
          Map[(edgeIndex[edges, #]) &, incident]; 
If[
          boundaryVertexQ[edges, polygons, vertexIndex],   
neighbors = 
            Select[neighbors, (boundaryEdgeQ[
                    polygons, {#, vertexIndex}]) &]; 
          neighborsLength = Length[neighbors]; weight = 1/8; 
          weight*Apply[Plus, 
                Map[vertexCoordinates[vertices, #] &, neighbors]] + (1 - 
                  weight*neighborsLength)*
              vertexCoordinates[vertices, vertexIndex],     Apply[Plus, 
                Map[vertexCoordinates[edgeVertices, #] &, edgeVertexIndices]]/
              Length[edgeVertexIndices]^2 + 
            Apply[Plus, 
                Map[vertexCoordinates[faceVertices, #] &, faceVertexIndices]]/
              Length[faceVertexIndices]^2 + (1 - 
                  1/Length[faceVertexIndices] - 
                  1/Length[edgeVertexIndices])*
              vertexCoordinates[vertices, vertexIndex]]]

catmullClarkSubdivisionNewPolygon[vertices_, edges_, polygons_, 
        Polygon[indices_]] := 
      Module[{verticesLength = Length[vertices], 
          polygonsLength = Length[polygons], polygonVertex, edgeVertices}, 
        polygonVertex = 
          polygonIndex[polygons, Polygon[indices]] + verticesLength; 
        edgeVertices = 
          Map[(verticesLength + polygonsLength + edgeIndex[edges, #]) &, 
            Transpose[{indices, RotateLeft[indices]}]]; 
        Map[Polygon, 
          Transpose[{indices, edgeVertices, 
              Table[polygonVertex, {Length[indices]}], 
              RotateRight[edgeVertices]}]]]

(* Loop subdivision,  Figure 21.9,  
      page 388 in Section 21.5 of [Farin,  2002] *)

loopSubdivision[complex : polygonComplex[vertices_, polygons_]] := 
        Module[{polys = Flatten[polygons], edges = edgesComplex[complex], 
            verticesLength = Length[vertices], verticesNew, polygonsNew}, 
          verticesNew = 
            Flatten[{Map[
                  loopSubdivisionNewVertexCoordinates[vertices, edges, 
                      polys, #] &, Range[verticesLength]], 
                Map[loopSubdivisionNewEdgeVertexCoordinates[vertices, 
                      edges, #] &, edges]}, 1]; 
          polygonsNew = 
            Map[loopSubdivisionNewPolygon[vertices, edges, #] &, polys]; 
          polygonComplex[verticesNew, polygonsNew]];

loopSubdivisionNewEdgeVertexCoordinates[vertices_, 
        edges_, {vertexIndex1_, vertexIndex2_}] := 
      Module[{commonNeighbors = 
            commonVertexNeighbors[edges, {vertexIndex1, vertexIndex2}]}, 
        If[Length[commonNeighbors] != 2,  (* 
            boundary edge or non - manifold edge or non - 
              triangle edge*)   vertexCoordinates[vertices, vertexIndex1]/
              2 + vertexCoordinates[vertices, vertexIndex2]/2,   (* 
            edge vertices are neighbors of two other vertices *)   3/8*vertexCoordinates[vertices, vertexIndex1] + 
            3/8*vertexCoordinates[vertices, vertexIndex2] + 
            1/8*vertexCoordinates[vertices, commonNeighbors[[1]]] + 
            1/8*vertexCoordinates[vertices, 
                commonNeighbors[[2]]]]]

loopSubdivisionNewVertexCoordinates[vertices_, edges_, polygons_, 
        vertexIndex_] := 
      Module[{neighbors = vertexNeighbors[edges, vertexIndex], weight, 
          neighborsLength}, neighborsLength = Length[neighbors]; 
        If[boundaryVertexQ[edges, polygons, vertexIndex], weight = 1/8; 
          neighbors = 
            Select[neighbors, (boundaryEdgeQ[
                    polygons, {#, vertexIndex}]) &]; 
          neighborsLength = Length[neighbors], 
          If[neighborsLength ≤ 3, weight = neighborsLength/16, 
            weight = 
              1/neighborsLength*(5/
                      8 - (3/8 + 1/4*Cos[2  Pi/neighborsLength])^2)]]; 
        weight*Apply[Plus, 
              Map[vertexCoordinates[vertices, #] &, neighbors]] + (1 - 
                weight*neighborsLength)*
            vertexCoordinates[vertices, vertexIndex]]

loopSubdivisionNewPolygon[vertices_, edges_, Polygon[indices_]] := 
      Module[{v1, v2, v3, e1, e2, e3, verticesLength = Length[vertices]}, 
        If[Length[indices] ≠ 3, Return[Polygon[indices]]]; 
        v1 = indices[[1]]; v2 = indices[[2]]; v3 = indices[[3]]; 
        e3 = verticesLength + edgeIndex[edges, {v1, v2}]; 
        e1 = verticesLength + edgeIndex[edges, {v2, v3}]; 
        e2 = verticesLength + 
            edgeIndex[edges, {v3, v1}]; {Polygon[{v1, e3, e2}], 
          Polygon[{v2, e1, e3}], Polygon[{v3, e2, e1}], 
          Polygon[{e1, e2, e3}]}]

Figure 21.4, page 382

Input: coordinate t, 3D points u1, u2, u3, u4, u5, u6, u7,u8

Interaction: 
— move t at discreet values 1/3(0, 1, 2)

Output: 
— n = t/2
— coordinate system, Bernstein polynomials for n

SetDirectory["/Users/martin/Desktop/mmasources"]

ClearAll[t, u1, u2, u3, u4, u5, u6, u7, u8]

\(defineVector[{"u1", "u2", "u3", "u4", "u5", "u6", "u7", "u8"}]\)

independentVariables = 
      Flatten[{t -> 0/3. , 
          independentVariablesForVector["u1", {0, 0, -0.5}], 
          independentVariablesForVector["u2", {1, 0, -0.5}], 
          independentVariablesForVector["u3", {0, 1, -0.5}], 
          independentVariablesForVector["u4", {1, 1, -0.5}], 
          independentVariablesForVector["u5", {0, 0, 0.5}], 
          independentVariablesForVector["u6", {1, 0, 0.5}], 
          independentVariablesForVector["u7", {0, 1, 0.5}], 
          independentVariablesForVector["u8", {1, 1, 0.5}]}]

dependentVariables = 
      Flatten[{t -> Round[t*2. ]/2. , 
          t -> If[t > 1, 1, If[t < 0, 0, t]], 
          n -> Round[t*2. ]}]

ytaxis = -0.4;

cube = 
      polygonComplex[{u1, u2, u3, u4, u5, u6, u7, 
          u8}, {{{Polygon[{1, 3, 4, 2}], Polygon[{1, 5, 7, 3}]}, 
            Polygon[{1, 2, 6, 5}], Polygon[{2, 4, 8, 6}], 
            Polygon[{3, 7, 8, 4}], Polygon[{5, 6, 8, 7}]}}]

doosabincube = 
        Table[primitivesComplex[Nest[dooSabinSubdivision, cube, i]], {i, 0, 
            2}];

chap21fig4 := 
      Graphics3D[{{PointSize[0.04], RGBColor[0. , 1, 0. ], 
            Point[{t, ytaxis, 0.01}], Point[u1], Point[u2], Point[u3], 
            Point[u4], Point[u5], Point[u6], Point[u7], 
            Point[u8]}, {Thickness[0.01], PointSize[0.02], 
            FaceForm[GrayLevel[0.8], GrayLevel[0.5]], 
            dummyIf[n == 1, doosabincube[[2]], 
              dummyIf[n == 2, doosabincube[[3]], 
                doosabincube[[1]]]]}, 
{PointSize[
              0.02], Thickness[0.005], GrayLevel[0], 
            Table[Point[{i/2. , ytaxis, 0}], {i, 0, 2}], 
            Table[Line[{{i/2. , ytaxis, 0}, {(i + 1)/2. , ytaxis, 
                    0}}], {i, 0, 2 - 1}]}, {Thickness[0.01], GrayLevel[0], 
            Text[itn, {-1/3. , ytaxis, 0}, {0, 1.5}], 
            Table[Text[ToString[i], {i/2, ytaxis, 0}, {0, 1.5}], {i, 0, 
                2}]}}, ViewPoint -> {1, 0.8, 3}, 
        ViewVertical -> {0, 1, 0}, SphericalRegion -> True, 
        PlotRange -> {{- .1, 1.1}, {-0.5, 1.1}, {-0.6, 
              0.6}}, Boxed -> False, Axes -> False, 
        Ticks -> Automatic, Lighting -> False, 
        AxesLabel -> {"x", "y", "z"}, 
        TextStyle -> newTextStyle]

Show[chap21fig4 /. dummyIf -> If //. 
        Join[independentVariables, dependentVariables]]

SetDirectory["/Users/martin/Desktop/mmasources"]

WriteLiveForm["chap21fig4.m", 
      chap21fig4 /. dummyIf -> If]

WriteHtmlPage["chap21fig4.html", "<FONT SIZE=+2><B>Figure \
21.4</B> [Farin 2002, page 382]</FONT>",  "chap21fig4.m", 800, 500, 
      independentVariables,  
      dependentVariables, "<PARAM NAME=BGCOLOR VALUE=#FFFFFF>\n<PARAM NAME=\
\"POINT_EDGE_COLOR\" VALUE=#000000>\n"]

Figure 21.4 variant for tetrahedron, page 382

Input: coordinate t, 3D points u1, u2, u3, u4, u5, u6, u7,u8

Interaction: 
— move t at discreet values 1/3(0, 1, 2)

Output: 
— n = t/2
— coordinate system, Bernstein polynomials for n

SetDirectory["/Users/martin/Desktop/mmasources"]

ClearAll[t, u1, u2, u3, u4]

defineVector[{"u1", "u2", "u3", "u4"}]

independentVariables = 
      Flatten[{t -> 0/3. , 
          independentVariablesForVector["u1", {0, 0, -0.5}], 
          independentVariablesForVector["u2", {1, 1, -0.5}], 
          independentVariablesForVector["u3", {1, 0, 0.5}], 
          independentVariablesForVector["u4", {0, 1, 0.5}]}]

dependentVariables = 
      Flatten[{t -> Round[t*2. ]/2. , 
          t -> If[t > 1, 1, If[t < 0, 0, t]], 
          n -> Round[t*2. ]}]

ytaxis = -0.4;

tet = 
        polygonComplex[{u1, u2, u3, u4}, {Polygon[{1, 2, 3}], 
            Polygon[{1, 3, 4}], Polygon[{2, 4, 3}], 
            Polygon[{1, 4, 2}]}];

doosabintet = 
        Table[primitivesComplex[Nest[dooSabinSubdivision, tet, i]], {i, 0, 
            2}];

chap21fig4tet := 
      Graphics3D[{{PointSize[0.04], RGBColor[0. , 1, 0. ], 
            Point[{t, ytaxis, 0.01}], Point[u1], Point[u2], Point[u3], 
            Point[u4]}, {Thickness[0.01], PointSize[0.02], 
            FaceForm[GrayLevel[0.8], GrayLevel[0.5]], 
            dummyIf[n == 1, doosabintet[[2]], 
              dummyIf[n == 2, doosabintet[[3]], 
                doosabintet[[1]]]]}, 
{PointSize[0.02], 
            Thickness[0.005], GrayLevel[0], 
            Table[Point[{i/2. , ytaxis, 0}], {i, 0, 2}], 
            Table[Line[{{i/2. , ytaxis, 0}, {(i + 1)/2. , ytaxis, 
                    0}}], {i, 0, 2 - 1}]}, {Thickness[0.01], GrayLevel[0], 
            Text[itn, {-1/3. , ytaxis, 0}, {0, 1.5}], 
            Table[Text[ToString[i], {i/2, ytaxis, 0}, {0, 1.5}], {i, 0, 
                2}]}}, ViewPoint -> {1, 0.8, 3}, 
        ViewVertical -> {0, 1, 0}, SphericalRegion -> True, 
        PlotRange -> {{- .1, 1.1}, {-0.5, 1.1}, {-0.6, 
              0.6}}, Boxed -> False, Axes -> False, 
        Ticks -> Automatic, Lighting -> False, 
        AxesLabel -> {"x", "y", "z"}, 
        TextStyle -> newTextStyle]

Show[chap21fig4tet /. dummyIf -> If //. 
        Join[independentVariables, dependentVariables]]

SetDirectory["/Users/martin/Desktop/mmasources"]

WriteLiveForm["chap21fig4tet.m", 
      chap21fig4tet /. dummyIf -> If]

\(WriteHtmlPage["chap21fig4tet.html", "<FONT SIZE=+2><B>Figure 21.4 (variant for tetrahedron)</B> [Farin 2002, page 382]</FONT>", \ "chap21fig4tet.m", 800, 500, independentVariables, \ 
      dependentVariables, "<PARAM NAME=BGCOLOR VALUE=#FFFFFF>
<PARAM NAME="POINT_EDGE_COLOR" VALUE=#000000>
"]\)

Figure 21.6, page 384

Input: coordinate t, 3D points u1, u2, u3, u4, u5, u6, u7,u8

Interaction: 
— move t at discreet values 1/3(0, 1, 2)

Output: 
— n = t/2
— coordinate system, Bernstein polynomials for n

SetDirectory["/Users/martin/Desktop/mmasources"]

ClearAll[t, u1, u2, u3, u4, u5, u6, u7, u8]

\(defineVector[{"u1", "u2", "u3", "u4", "u5", "u6", "u7", "u8"}]\)

independentVariables = 
      Flatten[{t -> 0/3. , 
          independentVariablesForVector["u1", {0, 0, -0.5}], 
          independentVariablesForVector["u2", {1, 0, -0.5}], 
          independentVariablesForVector["u3", {0, 1, -0.5}], 
          independentVariablesForVector["u4", {1, 1, -0.5}], 
          independentVariablesForVector["u5", {0, 0, 0.5}], 
          independentVariablesForVector["u6", {1, 0, 0.5}], 
          independentVariablesForVector["u7", {0, 1, 0.5}], 
          independentVariablesForVector["u8", {1, 1, 0.5}]}]

dependentVariables = 
      Flatten[{t -> Round[t*2. ]/2. , 
          t -> If[t > 1, 1, If[t < 0, 0, t]], 
          n -> Round[t*2. ]}]

ytaxis = -0.4;

cube = 
      polygonComplex[{u1, u2, u3, u4, u5, u6, u7, 
          u8}, {{{Polygon[{1, 3, 4, 2}], Polygon[{1, 5, 7, 3}]}, 
            Polygon[{1, 2, 6, 5}], Polygon[{2, 4, 8, 6}], 
            Polygon[{3, 7, 8, 4}], Polygon[{5, 6, 8, 7}]}}]

catmullclarkcube = 
        Table[primitivesComplex[Nest[catmullClarkSubdivision, cube, i]], {i, 
            0, 2}];

chap21fig6 := 
      Graphics3D[{{PointSize[0.04], RGBColor[0. , 1, 0. ], 
            Point[{t, ytaxis, 0.01}], Point[u1], Point[u2], Point[u3], 
            Point[u4], Point[u5], Point[u6], Point[u7], 
            Point[u8]}, {Thickness[0.01], PointSize[0.02], 
            FaceForm[GrayLevel[0.8], GrayLevel[0.5]], 
            dummyIf[n == 1, catmullclarkcube[[2]], 
              dummyIf[n == 2, catmullclarkcube[[3]], 
                catmullclarkcube[[1]]]]}, 
{PointSize[
              0.02], Thickness[0.005], GrayLevel[0], 
            Table[Point[{i/2. , ytaxis, 0}], {i, 0, 2}], 
            Table[Line[{{i/2. , ytaxis, 0}, {(i + 1)/2. , ytaxis, 
                    0}}], {i, 0, 2 - 1}]}, {Thickness[0.01], GrayLevel[0], 
            Text[itn, {-1/3. , ytaxis, 0}, {0, 1.5}], 
            Table[Text[ToString[i], {i/2, ytaxis, 0}, {0, 1.5}], {i, 0, 
                2}]}}, ViewPoint -> {1, 0.8, 3}, 
        ViewVertical -> {0, 1, 0}, SphericalRegion -> True, 
        PlotRange -> {{- .1, 1.1}, {-0.5, 1.1}, {-0.6, 
              0.6}}, Boxed -> False, Axes -> False, 
        Ticks -> Automatic, Lighting -> False, 
        AxesLabel -> {"x", "y", "z"}, 
        TextStyle -> newTextStyle]

Show[chap21fig6 /. dummyIf -> If //. 
        Join[independentVariables, dependentVariables]]

SetDirectory["/Users/martin/Desktop/mmasources"]

WriteLiveForm["chap21fig6.m", 
      chap21fig6 /. dummyIf -> If]

WriteHtmlPage["chap21fig6.html", "<FONT SIZE=+2><B>Figure \
21.6</B> [Farin 2002, page 384]</FONT>",  "chap21fig6.m", 800, 500, 
      independentVariables,  
      dependentVariables, "<PARAM NAME=BGCOLOR VALUE=#FFFFFF>\n<PARAM NAME=\
\"POINT_EDGE_COLOR\" VALUE=#000000>\n"]

Figure 21.6 variant for tetrahedron, page 384

Input: coordinate t, 3D points u1, u2, u3, u4

Interaction: 
— move t at discreet values 1/3(0, 1, 2)

Output: 
— n = t/2
— coordinate system, Bernstein polynomials for n

SetDirectory["/Users/martin/Desktop/mmasources"]

ClearAll[t, u1, u2, u3, u4]

defineVector[{"u1", "u2", "u3", "u4"}]

independentVariables = 
      Flatten[{t -> 0/3. , 
          independentVariablesForVector["u1", {0, 0, -0.5}], 
          independentVariablesForVector["u2", {1, 1, -0.5}], 
          independentVariablesForVector["u3", {1, 0, 0.5}], 
          independentVariablesForVector["u4", {0, 1, 0.5}]}]

dependentVariables = 
      Flatten[{t -> Round[t*2. ]/2. , 
          t -> If[t > 1, 1, If[t < 0, 0, t]], 
          n -> Round[t*2. ]}]

ytaxis = -0.4;

tet = 
        polygonComplex[{u1, u2, u3, u4}, {Polygon[{1, 2, 3}], 
            Polygon[{1, 3, 4}], Polygon[{2, 4, 3}], 
            Polygon[{1, 4, 2}]}];

catmullclarktet = 
        Table[primitivesComplex[Nest[catmullClarkSubdivision, tet, i]], {i, 
            0, 2}];

chap21fig6tet := 
      Graphics3D[{{PointSize[0.04], RGBColor[0. , 1, 0. ], 
            Point[{t, ytaxis, 0.01}], Point[u1], Point[u2], Point[u3], 
            Point[u4]}, {Thickness[0.01], PointSize[0.02], 
            FaceForm[GrayLevel[0.8], GrayLevel[0.5]], 
            dummyIf[n == 1, catmullclarktet[[2]], 
              dummyIf[n == 2, catmullclarktet[[3]], 
                catmullclarktet[[1]]]]}, 
{PointSize[
              0.02], Thickness[0.005], GrayLevel[0], 
            Table[Point[{i/2. , ytaxis, 0}], {i, 0, 2}], 
            Table[Line[{{i/2. , ytaxis, 0}, {(i + 1)/2. , ytaxis, 
                    0}}], {i, 0, 2 - 1}]}, {Thickness[0.01], GrayLevel[0], 
            Text[itn, {-1/3. , ytaxis, 0}, {0, 1.5}], 
            Table[Text[ToString[i], {i/2, ytaxis, 0}, {0, 1.5}], {i, 0, 
                2}]}}, ViewPoint -> {1, 0.8, 3}, 
        ViewVertical -> {0, 1, 0}, SphericalRegion -> True, 
        PlotRange -> {{- .1, 1.1}, {-0.5, 1.1}, {-0.6, 
              0.6}}, Boxed -> False, Axes -> False, 
        Ticks -> Automatic, Lighting -> False, 
        AxesLabel -> {"x", "y", "z"}, 
        TextStyle -> newTextStyle]

Show[chap21fig6tet /. dummyIf -> If //. 
        Join[independentVariables, dependentVariables]]

SetDirectory["/Users/martin/Desktop/mmasources"]

WriteLiveForm["chap21fig6tet.m", 
      chap21fig6tet /. dummyIf -> If]

\(WriteHtmlPage["chap21fig6tet.html", "<FONT SIZE=+2><B>Figure 21.6 (variant for tetrahedron)</B> [Farin 2002, page 384]</FONT>", \ "chap21fig6tet.m", 800, 500, independentVariables, \ 
      dependentVariables, "<PARAM NAME=BGCOLOR VALUE=#FFFFFF>
<PARAM NAME="POINT_EDGE_COLOR" VALUE=#000000>
"]\)

Figure 21.4/21.6 for Loop subdivision, page 387

Input: coordinate t, 3D points u1, u2, u3, u4, u5, u6, u7,u8

Interaction: 
— move t at discreet values 1/3(0, 1, 2)

Output: 
— n = t/2
— coordinate system, Bernstein polynomials for n

SetDirectory["/Users/martin/Desktop/mmasources"]

ClearAll[t, u1, u2, u3, u4, u5, u6, u7, u8]

\(defineVector[{"u1", "u2", "u3", "u4", "u5", "u6", "u7", "u8"}]\)

independentVariables = 
      Flatten[{t -> 0/3. , 
          independentVariablesForVector["u1", {0, 0, -0.5}], 
          independentVariablesForVector["u2", {1, 0, -0.5}], 
          independentVariablesForVector["u3", {0, 1, -0.5}], 
          independentVariablesForVector["u4", {1, 1, -0.5}], 
          independentVariablesForVector["u5", {0, 0, 0.5}], 
          independentVariablesForVector["u6", {1, 0, 0.5}], 
          independentVariablesForVector["u7", {0, 1, 0.5}], 
          independentVariablesForVector["u8", {1, 1, 0.5}]}]

dependentVariables = 
      Flatten[{t -> Round[t*2. ]/2. , 
          t -> If[t > 1, 1, If[t < 0, 0, t]], 
          n -> Round[t*2. ]}]

ytaxis = -0.4;

cube = 
      polygonComplex[{u1, u2, u3, u4, u5, u6, u7, 
          u8}, {{{Polygon[{1, 3, 4, 2}], Polygon[{1, 5, 7, 3}]}, 
            Polygon[{1, 2, 6, 5}], Polygon[{2, 4, 8, 6}], 
            Polygon[{3, 7, 8, 4}], Polygon[{5, 6, 8, 7}]}}]

loopcube = 
        Table[primitivesComplex[
            Nest[loopSubdivision, triangulateQuads[cube], i]], {i, 0, 
            2}];

chap21fig6loop := 
      Graphics3D[{{PointSize[0.04], RGBColor[0. , 1, 0. ], 
            Point[{t, ytaxis, 0.01}], Point[u1], Point[u2], Point[u3], 
            Point[u4], Point[u5], Point[u6], Point[u7], 
            Point[u8]}, {Thickness[0.01], PointSize[0.02], 
            FaceForm[GrayLevel[0.8], GrayLevel[0.5]], 
            dummyIf[n == 1, loopcube[[2]], 
              dummyIf[n == 2, loopcube[[3]], 
                loopcube[[1]]]]}, 
{PointSize[0.02], 
            Thickness[0.005], GrayLevel[0], 
            Table[Point[{i/2. , ytaxis, 0}], {i, 0, 2}], 
            Table[Line[{{i/2. , ytaxis, 0}, {(i + 1)/2. , ytaxis, 
                    0}}], {i, 0, 2 - 1}]}, {Thickness[0.01], GrayLevel[0], 
            Text[itn, {-1/3. , ytaxis, 0}, {0, 1.5}], 
            Table[Text[ToString[i], {i/2, ytaxis, 0}, {0, 1.5}], {i, 0, 
                2}]}}, ViewPoint -> {1, 0.8, 3}, 
        ViewVertical -> {0, 1, 0}, SphericalRegion -> True, 
        PlotRange -> {{- .1, 1.1}, {-0.5, 1.1}, {-0.6, 
              0.6}}, Boxed -> False, Axes -> False, 
        Ticks -> Automatic, Lighting -> False, 
        AxesLabel -> {"x", "y", "z"}, 
        TextStyle -> newTextStyle]

Show[chap21fig6loop /. dummyIf -> If //. 
        Join[independentVariables, dependentVariables]]

SetDirectory["/Users/martin/Desktop/mmasources"]

WriteLiveForm["chap21fig6loop.m", 
      chap21fig6loop /. dummyIf -> If]

WriteHtmlPage["chap21fig6loop.html", "<FONT SIZE=+2><B>Figure \
21.6 (variant for Loop subdivision)</B> [Farin 2002, page 384 and 387]</FONT>\
",  "chap21fig6loop.m", 800, 500, independentVariables,  
      dependentVariables, "<PARAM NAME=BGCOLOR VALUE=#FFFFFF>\n<PARAM NAME=\
\"POINT_EDGE_COLOR\" VALUE=#000000>\n"]

Figure 21.4/21.6 variant for tetrahedron and Loop subdivision, page 384 and 387

Input: coordinate t, 3D points u1, u2, u3, u4

Interaction: 
— move t at discreet values 1/3(0, 1, 2)

Output: 
— n = t/2
— coordinate system, Bernstein polynomials for n

SetDirectory["/Users/martin/Desktop/mmasources"]

ClearAll[t, u1, u2, u3, u4]

defineVector[{"u1", "u2", "u3", "u4"}]

independentVariables = 
      Flatten[{t -> 0/3. , 
          independentVariablesForVector["u1", {0, 0, -0.5}], 
          independentVariablesForVector["u2", {1, 1, -0.5}], 
          independentVariablesForVector["u3", {1, 0, 0.5}], 
          independentVariablesForVector["u4", {0, 1, 0.5}]}]

dependentVariables = 
      Flatten[{t -> Round[t*2. ]/2. , 
          t -> If[t > 1, 1, If[t < 0, 0, t]], 
          n -> Round[t*2. ]}]

ytaxis = -0.4;

tet = 
        polygonComplex[{u1, u2, u3, u4}, {Polygon[{1, 2, 3}], 
            Polygon[{1, 3, 4}], Polygon[{2, 4, 3}], 
            Polygon[{1, 4, 2}]}];

looptet = 
        Table[primitivesComplex[Nest[loopSubdivision, tet, i]], {i, 0, 
            2}];

chap21fig6looptet := 
      Graphics3D[{{PointSize[0.04], RGBColor[0. , 1, 0. ], 
            Point[{t, ytaxis, 0.01}], Point[u1], Point[u2], Point[u3], 
            Point[u4]}, {Thickness[0.01], PointSize[0.02], 
            FaceForm[GrayLevel[0.8], GrayLevel[0.5]], 
            dummyIf[n == 1, looptet[[2]], 
              dummyIf[n == 2, looptet[[3]], 
                looptet[[1]]]]}, 
{PointSize[0.02], 
            Thickness[0.005], GrayLevel[0], 
            Table[Point[{i/2. , ytaxis, 0}], {i, 0, 2}], 
            Table[Line[{{i/2. , ytaxis, 0}, {(i + 1)/2. , ytaxis, 
                    0}}], {i, 0, 2 - 1}]}, {Thickness[0.01], GrayLevel[0], 
            Text[itn, {-1/3. , ytaxis, 0}, {0, 1.5}], 
            Table[Text[ToString[i], {i/2, ytaxis, 0}, {0, 1.5}], {i, 0, 
                2}]}}, ViewPoint -> {1, 0.8, 3}, 
        ViewVertical -> {0, 1, 0}, SphericalRegion -> True, 
        PlotRange -> {{- .1, 1.1}, {-0.5, 1.1}, {-0.6, 
              0.6}}, Boxed -> False, Axes -> False, 
        Ticks -> Automatic, Lighting -> False, 
        AxesLabel -> {"x", "y", "z"}, 
        TextStyle -> newTextStyle]

Show[chap21fig6looptet /. dummyIf -> If //. 
        Join[independentVariables, dependentVariables]]

SetDirectory["/Users/martin/Desktop/mmasources"]

WriteLiveForm["chap21fig6looptet.m", 
      chap21fig6looptet /. dummyIf -> If]

WriteHtmlPage["chap21fig6looptet.html", "<FONT SIZE=+2><B>Figure \
21.6 (variant for tetrahedron and Loop subdivision)</B> [Farin 2002, page 384 \
and 387]</FONT>",  "chap21fig6looptet.m", 800, 500, 
      independentVariables,  
      dependentVariables, "<PARAM NAME=BGCOLOR VALUE=#FFFFFF>\n<PARAM NAME=\
\"POINT_EDGE_COLOR\" VALUE=#000000>\n"]