(* 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[ 8107, 243] NotebookOptionsPosition[ 7710, 225] NotebookOutlinePosition[ 8045, 240] CellTagsIndexPosition[ 8002, 237] WindowFrame->Normal ContainsDynamic->False*) (* Beginning of Notebook Content *) Notebook[{ Cell[CellGroupData[{ Cell[BoxData[ RowBox[{ RowBox[{"(*", RowBox[{ RowBox[{ "This", " ", "is", " ", "MATHEMATICA", " ", "code", " ", "for", " ", "drawing", " ", "a", " ", "peano", " ", RowBox[{"curve", ".", "After"}], " ", "the", " ", "code", " ", "has", " ", "been", " ", "loaded"}], ",", RowBox[{"typing", " ", RowBox[{ RowBox[{"`peano", "[", "n", "]"}], "'"}], " ", "will", " ", "draw", " ", "the", " ", "nth", " ", "generation", " ", "of", " ", "the", " ", "snowflake"}]}], "*)"}], RowBox[{ RowBox[{ RowBox[{"g", "=", "0.5"}], ";"}], "\n", RowBox[{ RowBox[{"w", "=", ".002"}], ";"}], "\n", RowBox[{ RowBox[{ RowBox[{"peano", "[", RowBox[{ RowBox[{"n_Integer", "?", "NonNegative"}], ",", "g_", ",", "w_"}], "]"}], ":=", RowBox[{"Graphics", "[", RowBox[{"{", RowBox[{ RowBox[{"GrayLevel", "[", "g", "]"}], ",", RowBox[{"Thickness", "[", "w", "]"}], ",", RowBox[{"FixedPoint", "[", RowBox[{ RowBox[{ RowBox[{"(", RowBox[{"#1", "/.", RowBox[{ RowBox[{"Line", "[", RowBox[{"{", RowBox[{"start_", ",", "finish_"}], "}"}], "]"}], "\[RuleDelayed]", RowBox[{"doline", "[", RowBox[{"start", ",", "finish"}], "]"}]}]}], ")"}], "&"}], ",", RowBox[{"{", RowBox[{ RowBox[{"Line", "[", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"0", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"1", "/", "2"}], ",", RowBox[{ RowBox[{"Sqrt", "[", "3", "]"}], "/", "2"}]}], "}"}]}], "}"}], "]"}], ",", RowBox[{"Line", "[", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"1", "/", "2"}], ",", RowBox[{ RowBox[{"Sqrt", "[", "3", "]"}], "/", "2"}]}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", "0"}], "}"}]}], "}"}], "]"}], ",", RowBox[{"Line", "[", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"1", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "0"}], "}"}]}], "}"}], "]"}]}], "}"}], ",", "n"}], "]"}]}], "}"}], "]"}]}], ";"}], "\n", RowBox[{"Show", "[", RowBox[{ RowBox[{"AspectRatio", "\[Rule]", "Automatic"}], ",", RowBox[{"PlotRange", "\[Rule]", "All"}]}], "]"}], "\n", "\[IndentingNewLine]", RowBox[{ RowBox[{"doline", "[", RowBox[{"start_", ",", "finish_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{"vec", ",", "normal"}], "}"}], ",", RowBox[{ RowBox[{"vec", "=", RowBox[{"finish", "-", "start"}]}], ";", "\[IndentingNewLine]", RowBox[{"normal", "=", RowBox[{ RowBox[{"(", "1.5", ")"}], " ", RowBox[{"Reverse", "[", "vec", "]"}], RowBox[{"{", RowBox[{ RowBox[{"-", "1"}], ",", "1"}], "}"}], RowBox[{ RowBox[{"Sqrt", "[", "3", "]"}], "/", "6"}]}]}], ";", "\[IndentingNewLine]", RowBox[{"{", RowBox[{ RowBox[{"Line", "[", RowBox[{"{", RowBox[{"start", ",", RowBox[{"start", "+", RowBox[{"vec", "/", "3"}]}]}], "}"}], "]"}], ",", RowBox[{"Line", "[", RowBox[{"{", RowBox[{ RowBox[{"start", "+", RowBox[{"vec", "/", "3"}]}], ",", RowBox[{"start", "+", RowBox[{"vec", "/", "3"}], "+", "normal"}]}], "}"}], "]"}], ",", RowBox[{"Line", "[", RowBox[{"{", RowBox[{ RowBox[{"start", "+", RowBox[{"vec", "/", "3"}], "+", "normal"}], ",", RowBox[{"start", "+", RowBox[{"vec", "/", "2"}], "-", "normal"}]}], "}"}], "]"}], ",", RowBox[{"Line", "[", RowBox[{"{", RowBox[{ RowBox[{"start", "+", RowBox[{"vec", "/", "2"}], "-", "normal"}], ",", RowBox[{"start", "+", RowBox[{"2", " ", RowBox[{"vec", "/", "3"}]}], "+", "normal"}]}], "}"}], "]"}], ",", RowBox[{"Line", "[", RowBox[{"{", RowBox[{ RowBox[{"start", "+", RowBox[{"2", " ", RowBox[{"vec", "/", "3"}]}], "+", "normal"}], ",", RowBox[{"start", "+", RowBox[{"2", " ", RowBox[{"vec", "/", "3"}]}]}]}], "}"}], "]"}], ",", RowBox[{"Line", "[", RowBox[{"{", RowBox[{ RowBox[{"start", "+", RowBox[{"2", " ", RowBox[{"vec", "/", "3"}]}]}], ",", "finish"}], "}"}], "]"}]}], "}"}]}]}], "]"}]}], "\n", "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"flake", "[", RowBox[{"n_", ",", "g_", ",", "w_"}], "]"}], ":=", RowBox[{"KochSnowflake", "[", RowBox[{"n", ",", "g", ",", "w"}], "]"}]}], ";"}], "\n", RowBox[{ RowBox[{"plot", "[", RowBox[{ RowBox[{"n_g", "_"}], ",", "w_"}], "]"}], ":=", RowBox[{"Show", "[", RowBox[{ RowBox[{"flake", "[", RowBox[{"n", ",", "g", ",", "w"}], "]"}], ",", RowBox[{"AspectRatio", "\[Rule]", "Automatic"}], ",", RowBox[{"PlotRange", "\[Rule]", "All"}]}], "]"}]}], "\[IndentingNewLine]", "\n", "\[IndentingNewLine]", RowBox[{ RowBox[{"newsave", ":=", RowBox[{"Export", "[", RowBox[{"\"\\"", ",", "%"}], "]"}]}], ";"}], "\n", "\[IndentingNewLine]", RowBox[{ RowBox[{"vk", "[", "n_", "]"}], ":=", RowBox[{"Show", "[", RowBox[{ RowBox[{"peano", "[", RowBox[{"n", ",", "0", ",", ".005"}], "]"}], ",", RowBox[{"AspectRatio", "\[Rule]", "Automatic"}], ",", RowBox[{"PlotRange", "\[Rule]", "All"}]}], "]"}]}], "\n", "\[IndentingNewLine]"}]}]], "Input"], Cell[BoxData[ RowBox[{ RowBox[{"Show", "::", "\<\"shx\"\>"}], RowBox[{ ":", " "}], "\<\"No graphical objects to show. \\!\\(\\*ButtonBox[\\\"\ \[RightSkeleton]\\\", ButtonStyle->\\\"Link\\\", ButtonFrame->None, \ ButtonData:>\\\"paclet:ref/message/Show/shx\\\", ButtonNote -> \ \\\"Show::shx\\\"]\\)\"\>"}]], "Message", "MSG", CellChangeTimes->{3.462542437823237*^9}], Cell[BoxData[ RowBox[{"Show", "[", RowBox[{ RowBox[{"AspectRatio", "\[Rule]", "Automatic"}], ",", RowBox[{"PlotRange", "\[Rule]", "All"}]}], "]"}]], "Output", CellChangeTimes->{3.462542437901775*^9}] }, Open ]], Cell[BoxData[ RowBox[{"\[IndentingNewLine]", RowBox[{"vk", "[", "4", "]"}]}]], "Input", CellChangeTimes->{{3.462542420309511*^9, 3.462542423389407*^9}}] }, WindowSize->{640, 750}, WindowMargins->{{194, Automatic}, {Automatic, 102}}, FrontEndVersion->"6.0 for Linux x86 (32-bit) (June 19, 2007)", StyleDefinitions->"Default.nb" ] (* End of Notebook Content *) (* Internal cache information *) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[CellGroupData[{ Cell[590, 23, 6351, 177, 781, "Input"], Cell[6944, 202, 376, 8, 24, "Message"], Cell[7323, 212, 211, 5, 30, "Output"] }, Open ]], Cell[7549, 220, 157, 3, 55, "Input"] } ] *) (* End of internal cache information *)