(* Content-type: application/mathematica *) (*** Wolfram Notebook File ***) (* http://www.wolfram.com/nb *) (* CreatedBy='Mathematica 6.0' *) (*CacheID: 234*) (* Internal cache information: NotebookFileLineBreakTest NotebookFileLineBreakTest NotebookDataPosition[ 145, 7] NotebookDataLength[ 17979, 488] NotebookOptionsPosition[ 17239, 458] NotebookOutlinePosition[ 17576, 473] CellTagsIndexPosition[ 17533, 470] WindowFrame->Normal ContainsDynamic->True *) (* Beginning of Notebook Content *) Notebook[{ Cell[CellGroupData[{ Cell["Lesson 13 Answers - Animation and Manipulation", "Section", CellChangeTimes->{ 3.462207241452711*^9, 3.462209253295637*^9, {3.466773904755886*^9, 3.466773907624906*^9}}], Cell[TextData[{ "1) Use ", StyleBox["Manipulate", "Input"], " and ", StyleBox["Locator", "Input"], " to create a triangle graphic whose vertices can be moved around.You will \ need to specify the initial locations of the vertices. The boundary of the \ triangle can be drawn with ", StyleBox["Line", "Input"], " or by using ", StyleBox["EdgeForm", "Input"], "." }], "Text", CellChangeTimes->{{3.462208953585993*^9, 3.462208954514999*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"Manipulate", "[", RowBox[{ RowBox[{"Graphics", "[", RowBox[{ RowBox[{"{", RowBox[{"Orange", ",", RowBox[{"EdgeForm", "[", "Thick", "]"}], ",", RowBox[{"Polygon", "[", RowBox[{"{", RowBox[{"a", ",", "b", ",", "c"}], "}"}], "]"}]}], "}"}], ",", RowBox[{"PlotRange", "\[Rule]", "2"}]}], "]"}], ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"a", ",", RowBox[{"{", RowBox[{ RowBox[{"-", "1"}], ",", RowBox[{"-", "1"}]}], "}"}]}], "}"}], ",", "Locator"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"b", ",", RowBox[{"{", RowBox[{"0", ",", "1"}], "}"}]}], "}"}], ",", "Locator"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"c", ",", RowBox[{"{", RowBox[{"1", ",", "0"}], "}"}]}], "}"}], ",", "Locator"}], "}"}], ",", RowBox[{"SaveDefinitions", "\[Rule]", "True"}]}], "]"}]], "Input", CellChangeTimes->{{3.45044253996196*^9, 3.4504425523992968`*^9}, { 3.450442606097495*^9, 3.450442607340969*^9}, {3.4504427841496964`*^9, 3.450442787739378*^9}, {3.450889566097866*^9, 3.450889571438648*^9}, { 3.4508896062523603`*^9, 3.4508896067883797`*^9}, {3.450889676996503*^9, 3.450889727261488*^9}, {3.45108258774856*^9, 3.451082588450747*^9}}, FontSlant->"Italic"], Cell[BoxData[ TagBox[ StyleBox[ DynamicModuleBox[{$CellContext`a$$ = {-1, -1}, $CellContext`b$$ = {0, 1}, $CellContext`c$$ = {1, 0}, Typeset`show$$ = True, Typeset`bookmarkList$$ = {}, Typeset`bookmarkMode$$ = "Menu", Typeset`animator$$, Typeset`animvar$$ = 1, Typeset`name$$ = "\"untitled\"", Typeset`specs$$ = {{{ Hold[$CellContext`a$$], {-1, -1}}, Automatic}, {{ Hold[$CellContext`b$$], {0, 1}}, Automatic}, {{ Hold[$CellContext`c$$], {1, 0}}, Automatic}}, Typeset`size$$ = { 360., {178., 182.}}, Typeset`update$$ = 0, Typeset`initDone$$, Typeset`skipInitDone$$ = True}, DynamicBox[Manipulate`ManipulateBoxes[ 1, StandardForm, "Variables" :> {$CellContext`a$$ = {-1, -1}, $CellContext`b$$ = {0, 1}, $CellContext`c$$ = {1, 0}}, "ControllerVariables" :> {}, "OtherVariables" :> { Typeset`show$$, Typeset`bookmarkList$$, Typeset`bookmarkMode$$, Typeset`animator$$, Typeset`animvar$$, Typeset`name$$, Typeset`specs$$, Typeset`size$$, Typeset`update$$, Typeset`initDone$$, Typeset`skipInitDone$$}, "Body" :> Graphics[{Orange, EdgeForm[Thick], Polygon[{$CellContext`a$$, $CellContext`b$$, $CellContext`c$$}]}, PlotRange -> 2], "Specifications" :> {{{$CellContext`a$$, {-1, -1}}, Automatic, ControlType -> Locator}, {{$CellContext`b$$, {0, 1}}, Automatic, ControlType -> Locator}, {{$CellContext`c$$, {1, 0}}, Automatic, ControlType -> Locator}}, "Options" :> {}, "DefaultOptions" :> {}], ImageSizeCache->{402., {203.375, 208.625}}, SingleEvaluation->True], Deinitialization:>None, DynamicModuleValues:>{}, SynchronousInitialization->True, UnsavedVariables:>{Typeset`initDone$$}, UntrackedVariables:>{Typeset`size$$}], "Manipulate", Deployed->True, StripOnInput->False], Manipulate`InterpretManipulate[1]]], "Output", CellChangeTimes->{3.462209169730764*^9}] }, Open ]], Cell[TextData[{ "2) Use ", StyleBox["Manipulate", "Input"], " to change the width of the smile of the face created in Lesson 10. The \ definitions of ", StyleBox["eyes", "Input"], ", ", StyleBox["face", "Input"], " and ", StyleBox["nose", "Input"], " can be the same as before, but the ", StyleBox["Graphics", "Input"], " command that generates the mouth has to be inside the ", StyleBox["Manipulate", "Input"], " command so that the width of the smile can be controlled by a slider." }], "Text", CellChangeTimes->{{3.462209050276698*^9, 3.4622090513851967`*^9}}], Cell[CellGroupData[{ Cell[BoxData[{ RowBox[{ RowBox[{"eyes", "=", " ", RowBox[{"Graphics", "[", RowBox[{"{", RowBox[{ RowBox[{"Darker", "[", "Magenta", "]"}], ",", RowBox[{"Disk", "[", RowBox[{ RowBox[{"{", RowBox[{"2", ",", "1.75"}], "}"}], ",", ".3"}], "]"}], ",", RowBox[{"Disk", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"-", "2"}], ",", "1.75"}], "}"}], ",", ".3"}], "]"}]}], "}"}], "]"}]}], ";"}], "\n", RowBox[{ RowBox[{"face", " ", "=", " ", RowBox[{"Graphics", "[", RowBox[{"{", RowBox[{"Thick", ",", RowBox[{"RGBColor", "[", RowBox[{".1", ",", ".75", ",", ".75"}], "]"}], ",", RowBox[{"Circle", "[", RowBox[{ RowBox[{"{", RowBox[{"0", ",", "0"}], "}"}], ",", "4"}], "]"}]}], "}"}], "]"}]}], ";"}], "\n", RowBox[{ RowBox[{"nose", "=", RowBox[{"Graphics", "[", RowBox[{"{", RowBox[{"Green", ",", RowBox[{"Polygon", "[", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"-", ".5"}], ",", RowBox[{"-", ".5"}]}], "}"}], ",", RowBox[{"{", RowBox[{".5", ",", RowBox[{"-", ".5"}]}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", ".75"}], "}"}]}], "}"}], "]"}]}], "}"}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{"Manipulate", "[", RowBox[{ RowBox[{"Show", "[", RowBox[{"face", ",", " ", RowBox[{"Graphics", "[", RowBox[{"{", RowBox[{"Red", ",", RowBox[{"Thickness", "[", "0.015", "]"}], ",", RowBox[{"Circle", "[", RowBox[{ RowBox[{"{", RowBox[{"0", ",", "2"}], "}"}], ",", "4", ",", RowBox[{"{", RowBox[{ RowBox[{ RowBox[{ RowBox[{"-", "Pi"}], "/", "2"}], "-", "s"}], ",", RowBox[{ RowBox[{ RowBox[{"-", "Pi"}], "/", "2"}], "+", "s"}]}], "}"}]}], "]"}]}], "}"}], "]"}], ",", "nose", ",", "eyes", ",", RowBox[{"ImageSize", "\[Rule]", "300"}]}], "]"}], ",", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"s", ",", ".5", ",", "\"\\""}], "}"}], ",", ".1", ",", "1"}], "}"}], ",", RowBox[{"SaveDefinitions", "\[Rule]", "True"}]}], "]"}]}], "Input", CellChangeTimes->{{3.450889996038104*^9, 3.450890076355582*^9}, { 3.450890121709135*^9, 3.4508901368389997`*^9}, {3.4508901783919563`*^9, 3.450890190864532*^9}, {3.450890223717744*^9, 3.450890274494368*^9}, { 3.450890353864113*^9, 3.450890365712512*^9}, {3.45089047421525*^9, 3.450890492943688*^9}, {3.4508905742794323`*^9, 3.450890626913891*^9}, { 3.4508906610898027`*^9, 3.450890661346195*^9}, {3.450890702297543*^9, 3.4508907048978033`*^9}, {3.450890735225788*^9, 3.450890738722505*^9}, { 3.450890850003406*^9, 3.450890852769493*^9}, {3.45089097167651*^9, 3.450890972062512*^9}, {3.450891027725472*^9, 3.450891049790825*^9}, 3.4508911115522127`*^9, {3.450891203343809*^9, 3.4508912693497553`*^9}, { 3.450891346578233*^9, 3.450891355051043*^9}, {3.45089141499993*^9, 3.4508915362396593`*^9}, {3.450891572072846*^9, 3.450891704298152*^9}, { 3.4510825975972633`*^9, 3.4510826008784933`*^9}}, FontSlant->"Italic"], Cell[BoxData[ TagBox[ StyleBox[ DynamicModuleBox[{$CellContext`s$$ = 0.5, Typeset`show$$ = True, Typeset`bookmarkList$$ = {}, Typeset`bookmarkMode$$ = "Menu", Typeset`animator$$, Typeset`animvar$$ = 1, Typeset`name$$ = "\"untitled\"", Typeset`specs$$ = {{{ Hold[$CellContext`s$$], 0.5, "Smile"}, 0.1, 1}}, Typeset`size$$ = { 300., {148., 152.}}, Typeset`update$$ = 0, Typeset`initDone$$, Typeset`skipInitDone$$ = False, $CellContext`s$7879$$ = 0}, DynamicBox[Manipulate`ManipulateBoxes[ 1, StandardForm, "Variables" :> {$CellContext`s$$ = 0.5}, "ControllerVariables" :> { Hold[$CellContext`s$$, $CellContext`s$7879$$, 0]}, "OtherVariables" :> { Typeset`show$$, Typeset`bookmarkList$$, Typeset`bookmarkMode$$, Typeset`animator$$, Typeset`animvar$$, Typeset`name$$, Typeset`specs$$, Typeset`size$$, Typeset`update$$, Typeset`initDone$$, Typeset`skipInitDone$$}, "Body" :> Show[$CellContext`face, Graphics[{Red, Thickness[0.015], Circle[{0, 2}, 4, {(-Pi)/2 - $CellContext`s$$, (-Pi)/ 2 + $CellContext`s$$}]}], $CellContext`nose, $CellContext`eyes, ImageSize -> 300], "Specifications" :> {{{$CellContext`s$$, 0.5, "Smile"}, 0.1, 1}}, "Options" :> {}, "DefaultOptions" :> {}], ImageSizeCache->{342., {190.375, 195.625}}, SingleEvaluation->True], Deinitialization:>None, DynamicModuleValues:>{}, Initialization:>({$CellContext`face = Graphics[{ Thickness[Large], RGBColor[0.1, 0.75, 0.75], Circle[{0, 0}, 4]}], $CellContext`nose = Graphics[{ RGBColor[0, 1, 0], Polygon[{{-0.5, -0.5}, {0.5, -0.5}, { 0, 0.75}}]}], $CellContext`eyes = Graphics[{ RGBColor[2/3, 0, 2/3], Disk[{2, 1.75}, 0.3], Disk[{-2, 1.75}, 0.3]}]}; Typeset`initDone$$ = True), SynchronousInitialization->True, UnsavedVariables:>{Typeset`initDone$$}, UntrackedVariables:>{Typeset`size$$}], "Manipulate", Deployed->True, StripOnInput->False], Manipulate`InterpretManipulate[1]]], "Output", CellChangeTimes->{3.462209147040612*^9}] }, Open ]], Cell["\<\ For extra fun, try controlling the width and radius of the smile with a 2-D \ slider.\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[{ RowBox[{ RowBox[{"eyes", "=", " ", RowBox[{"Graphics", "[", RowBox[{"{", RowBox[{ RowBox[{"Darker", "[", "Magenta", "]"}], ",", RowBox[{"Disk", "[", RowBox[{ RowBox[{"{", RowBox[{"2", ",", "1.75"}], "}"}], ",", ".3"}], "]"}], ",", RowBox[{"Disk", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"-", "2"}], ",", "1.75"}], "}"}], ",", ".3"}], "]"}]}], "}"}], "]"}]}], ";"}], "\n", RowBox[{ RowBox[{"face", " ", "=", " ", RowBox[{"Graphics", "[", RowBox[{"{", RowBox[{"Thick", ",", RowBox[{"RGBColor", "[", RowBox[{".1", ",", ".75", ",", ".75"}], "]"}], ",", RowBox[{"Circle", "[", RowBox[{ RowBox[{"{", RowBox[{"0", ",", "0"}], "}"}], ",", "4"}], "]"}]}], "}"}], "]"}]}], ";"}], "\n", RowBox[{ RowBox[{"nose", "=", RowBox[{"Graphics", "[", RowBox[{"{", RowBox[{"Green", ",", RowBox[{"Polygon", "[", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"-", ".5"}], ",", RowBox[{"-", ".5"}]}], "}"}], ",", RowBox[{"{", RowBox[{".5", ",", RowBox[{"-", ".5"}]}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", ".75"}], "}"}]}], "}"}], "]"}]}], "}"}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{"Manipulate", "[", RowBox[{ RowBox[{"Show", "[", RowBox[{"face", ",", " ", RowBox[{"Graphics", "[", RowBox[{"{", RowBox[{"Red", ",", RowBox[{"Thickness", "[", "0.015", "]"}], ",", RowBox[{"Circle", "[", RowBox[{ RowBox[{"{", RowBox[{"0", ",", RowBox[{ RowBox[{"s", "[", RowBox[{"[", "1", "]"}], "]"}], "-", "2"}]}], "}"}], ",", RowBox[{"s", "[", RowBox[{"[", "1", "]"}], "]"}], ",", RowBox[{"{", RowBox[{ RowBox[{ RowBox[{ RowBox[{"-", "Pi"}], "/", "2"}], "-", RowBox[{"s", "[", RowBox[{"[", "2", "]"}], "]"}]}], ",", RowBox[{ RowBox[{ RowBox[{"-", "Pi"}], "/", "2"}], "+", RowBox[{"s", "[", RowBox[{"[", "2", "]"}], "]"}]}]}], "}"}]}], "]"}]}], "}"}], "]"}], ",", "nose", ",", "eyes", ",", RowBox[{"ImageSize", "\[Rule]", "300"}]}], "]"}], ",", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"s", ",", RowBox[{"{", RowBox[{"2", ",", ".5"}], "}"}], ",", "\"\\""}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", ".5"}], "}"}], ",", RowBox[{"{", RowBox[{"4", ",", "1"}], "}"}]}], "}"}], ",", RowBox[{"SaveDefinitions", "\[Rule]", "True"}]}], "]"}]}], "Input", CellChangeTimes->{{3.450889996038104*^9, 3.450890076355582*^9}, { 3.450890121709135*^9, 3.4508901368389997`*^9}, {3.4508901783919563`*^9, 3.450890190864532*^9}, {3.450890223717744*^9, 3.450890274494368*^9}, { 3.450890353864113*^9, 3.450890365712512*^9}, {3.45089047421525*^9, 3.450890492943688*^9}, {3.4508905742794323`*^9, 3.450890626913891*^9}, { 3.4508906610898027`*^9, 3.450890661346195*^9}, {3.450890702297543*^9, 3.4508907048978033`*^9}, {3.450890735225788*^9, 3.450890738722505*^9}, { 3.450890850003406*^9, 3.450890852769493*^9}, {3.45089097167651*^9, 3.450890972062512*^9}, {3.450891027725472*^9, 3.450891049790825*^9}, 3.4508911115522127`*^9, {3.450891203343809*^9, 3.4508912693497553`*^9}, { 3.450891346578233*^9, 3.450891355051043*^9}, {3.45089141499993*^9, 3.4508915362396593`*^9}, 3.450891572072846*^9, {3.4510826073290462`*^9, 3.4510826077347727`*^9}}, FontSlant->"Italic"], Cell[BoxData[ TagBox[ StyleBox[ DynamicModuleBox[{$CellContext`s$$ = {2, 0.5}, Typeset`show$$ = True, Typeset`bookmarkList$$ = {}, Typeset`bookmarkMode$$ = "Menu", Typeset`animator$$, Typeset`animvar$$ = 1, Typeset`name$$ = "\"untitled\"", Typeset`specs$$ = {{{ Hold[$CellContext`s$$], {2, 0.5}, "Smile"}, {1, 0.5}, {4, 1}}}, Typeset`size$$ = {300., {148., 152.}}, Typeset`update$$ = 0, Typeset`initDone$$, Typeset`skipInitDone$$ = False, $CellContext`s$7903$$ = {0, 0}}, DynamicBox[Manipulate`ManipulateBoxes[ 1, StandardForm, "Variables" :> {$CellContext`s$$ = {2, 0.5}}, "ControllerVariables" :> { Hold[$CellContext`s$$, $CellContext`s$7903$$, {0, 0}]}, "OtherVariables" :> { Typeset`show$$, Typeset`bookmarkList$$, Typeset`bookmarkMode$$, Typeset`animator$$, Typeset`animvar$$, Typeset`name$$, Typeset`specs$$, Typeset`size$$, Typeset`update$$, Typeset`initDone$$, Typeset`skipInitDone$$}, "Body" :> Show[$CellContext`face, Graphics[{Red, Thickness[0.015], Circle[{0, Part[$CellContext`s$$, 1] - 2}, Part[$CellContext`s$$, 1], {(-Pi)/2 - Part[$CellContext`s$$, 2], (-Pi)/2 + Part[$CellContext`s$$, 2]}]}], $CellContext`nose, $CellContext`eyes, ImageSize -> 300], "Specifications" :> {{{$CellContext`s$$, {2, 0.5}, "Smile"}, { 1, 0.5}, {4, 1}}}, "Options" :> {}, "DefaultOptions" :> {}], ImageSizeCache->{342., {218.375, 223.625}}, SingleEvaluation->True], Deinitialization:>None, DynamicModuleValues:>{}, Initialization:>({$CellContext`face = Graphics[{ Thickness[Large], RGBColor[0.1, 0.75, 0.75], Circle[{0, 0}, 4]}], $CellContext`nose = Graphics[{ RGBColor[0, 1, 0], Polygon[{{-0.5, -0.5}, {0.5, -0.5}, { 0, 0.75}}]}], $CellContext`eyes = Graphics[{ RGBColor[2/3, 0, 2/3], Disk[{2, 1.75}, 0.3], Disk[{-2, 1.75}, 0.3]}]}; Typeset`initDone$$ = True), SynchronousInitialization->True, UnsavedVariables:>{Typeset`initDone$$}, UntrackedVariables:>{Typeset`size$$}], "Manipulate", Deployed->True, StripOnInput->False], Manipulate`InterpretManipulate[1]]], "Output", CellChangeTimes->{3.4622091565686703`*^9}] }, Open ]] }, Open ]] }, WindowSize->{640, 569}, WindowMargins->{{46, Automatic}, {Automatic, 14}}, FrontEndVersion->"6.0 for Mac OS X x86 (32-bit) (April 20, 2007)", StyleDefinitions->"Default.nb" ] (* End of Notebook Content *) (* Internal cache information *) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[CellGroupData[{ Cell[590, 23, 183, 3, 67, "Section"], Cell[776, 28, 449, 13, 56, "Text"], Cell[CellGroupData[{ Cell[1250, 45, 1446, 41, 73, "Input"], Cell[2699, 88, 1983, 39, 430, "Output"] }, Open ]], Cell[4697, 130, 578, 16, 56, "Text"], Cell[CellGroupData[{ Cell[5300, 150, 3344, 88, 148, "Input"], Cell[8647, 240, 2232, 49, 404, "Output"] }, Open ]], Cell[10894, 292, 109, 3, 26, "Text"], Cell[CellGroupData[{ Cell[11028, 299, 3799, 102, 163, "Input"], Cell[14830, 403, 2381, 51, 460, "Output"] }, Open ]] }, Open ]] } ] *) (* End of internal cache information *)