(************** Content-type: application/mathematica ************** CreatedBy='Mathematica 5.1' Mathematica-Compatible Notebook This notebook can be used with any Mathematica-compatible application, such as Mathematica, MathReader or Publicon. The data for the notebook starts with the line containing stars above. To get the notebook into a Mathematica-compatible application, do one of the following: * Save the data starting with the line of stars above into a file with a name ending in .nb, then open the file inside the application; * Copy the data starting with the line of stars above to the clipboard, then use the Paste menu command inside the application. Data for notebooks contains only printable 7-bit ASCII and can be sent directly in email or through ftp in text mode. Newlines can be CR, LF or CRLF (Unix, Macintosh or MS-DOS style). NOTE: If you modify the data for this notebook not in a Mathematica- compatible application, you must delete the line below containing the word CacheID, otherwise Mathematica-compatible applications may try to use invalid cache data. For more information on notebooks and Mathematica-compatible applications, contact Wolfram Research: web: http://www.wolfram.com email: info@wolfram.com phone: +1-217-398-0700 (U.S.) Notebook reader applications are available free of charge from Wolfram Research. *******************************************************************) (*CacheID: 232*) (*NotebookFileLineBreakTest NotebookFileLineBreakTest*) (*NotebookOptionsPosition[ 1791523, 52388]*) (*NotebookOutlinePosition[ 1792207, 52412]*) (* CellTagsIndexPosition[ 1792163, 52408]*) (*WindowFrame->Normal*) Notebook[{ Cell[CellGroupData[{ Cell["Interactive Illustrations for Geometric Modelling", "Title"], Cell[TextData[{ "implemented 2005 with ", StyleBox["Mathematica", FontSlant->"Italic"], " and LiveGraphics3D by Martin Kraus (martin_kraus_germany@yahoo.com)" }], "Subtitle"], Cell[TextData[{ "This notebook contains ", StyleBox["Mathematica", FontSlant->"Italic"], " 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 \ \[LongDash] 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." }], "Text"], Cell["\<\ Some of the goals in the implementation of interactive versions of \ these figures are: \[LongDash] merging of separate static figures in one interactive figure \[LongDash] intuitive interaction to show dependencies \[LongDash] consistency of notation LiveGraphics3D has several limitations; thus, another important goal is to \ identify their relevance and propose solutions for some of them. \ \>", "Text"], Cell[TextData[{ "If you have questions about the ", StyleBox["Mathematica", FontSlant->"Italic"], " 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. " }], "Text"], Cell[CellGroupData[{ Cell["Lessons Learned", "Section"], Cell[CellGroupData[{ Cell["Graphics3D objects for LiveGraphics3D in general", "Subsubsection"], Cell["\<\ \[LongDash] always construct graphics in three dimensions (reuse of \ code, etc.)\ \>", "Text"] }, Open ]], Cell[CellGroupData[{ Cell["parametric Graphics3D objects for LiveGraphics3D", "Subsubsection"], Cell[TextData[{ "\[LongDash] 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}\").\n\[LongDash] use \ Evaluate around arguments of functions with attributes HoldFirst, HoldRest, \ HoldFirst, etc. (e.g If) \n\[LongDash] define lists independentVariables and \ dependentVariables that correspond to the parameters of LiveGraphics3D\n\ \[LongDash] 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}\").\n\[LongDash] use \ \"Graphics3D[...] //. Join[independentVariables, dependentVariables]\" to \ produce an object that is displayable in ", StyleBox["Mathematica", FontSlant->"Italic"], " (but note that reassignments of independent variables are ignored this \ way).\n\[LongDash] define new variables for the arguments and the results of \ complex symbolic computations (e.g. solutions of parametrized linear equation \ systems)" }], "Text"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["Functions for Preparing Graphics3D Objects", "Section"], Cell[CellGroupData[{ Cell["Functions for Writing the Input File", "Subsection"], Cell[CellGroupData[{ Cell[BoxData[{ RowBox[{ StyleBox[\(LiveForm[graphics_, animOpts___] := Module[{graphics3d = Switch[graphics, _ContourGraphics, Graphics3D[ SurfaceGraphics[graphics]], _DensityGraphics, Graphics3D[ SurfaceGraphics[graphics]], _SurfaceGraphics, Graphics3D[graphics], _, graphics] //. SequenceForm[x___] \[RuleDelayed] StringForm[StringJoin[Table["\<``\>", {Length[{x}]}]], x]}, Switch[ graphics3d, _List, \(HoldForm[ShowAnimation]\)[ Map[LiveForm, graphics3d], InputForm[N[Flatten[{animOpts}]]]], _, InputForm[N[graphics3d]]]];\), FontFamily->"Courier", FontSize->13], "\[IndentingNewLine]"}], "\[IndentingNewLine]", \(WriteLiveForm[ filename_, graphics_, animOpts___] := Module[{ps, x}, ps = Unprotect[Real]; Format[x_Real, InputForm] := OutputForm[ NumberForm[x, 5, NumberFormat \[Rule] \((If[#3 \[Equal] "\<\>", #1, SequenceForm[#1, "\<*^\>", #3]] &)\)]]; Protect @@ ps; \[IndentingNewLine]WriteString[filename, ToString[LiveForm[graphics, animOpts], CharacterEncoding \[Rule] None]]; Close[filename]; \[IndentingNewLine]ps = Unprotect[Real]; Format[x_Real, InputForm] =. ; Protect @@ ps;];\)}], "Input", InitializationCell->True], Cell[BoxData[ RowBox[{\(General::"spell1"\), \(\(:\)\(\ \)\), "\<\"Possible spelling \ error: new symbol name \\\"\\!\\(LiveForm\\)\\\" is similar to existing \ symbol \\\"\\!\\(LineForm\\)\\\". \\!\\(\\*ButtonBox[\\\"More\[Ellipsis]\\\", \ ButtonStyle->\\\"RefGuideLinkText\\\", ButtonFrame->None, \ ButtonData:>\\\"General::spell1\\\"]\\)\"\>"}]], "Message"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["Functions for Writing the HTML File", "Subsection"], Cell[BoxData[ \(\(WriteHtmlPage[filename_, text_, inputfile_, width_, height_, independentVariables_, dependentVariables_, params_] := Module[{}, WriteString[ filename, "\<\n
\n\>" <> ToString[ text] <> "\<\n\>"]; Close[filename];];\)\)], "Input", InitializationCell->True] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["Global Settings", "Section"], Cell[BoxData[ \(\(newTextStyle = {FontFamily \[Rule] "\"];\)\), "\[IndentingNewLine]",
\(\(bfq := \ symbolBold["\"];\)\), "\[IndentingNewLine]",
\(\(bft := \ symbolBold["\
ooooo`05okZj^_l@413o0000ob4Q8Oo^k^h0Foooool001[ooooo1?l0000>ooooo`05oc8b<_l0
003o0000o`000?nHV9P0Noooool01OmEEEGo0000o`000?l0003oEEEE013ooooo00Cok^k^odA4A?l0
003o