(*^ ::[ frontEndVersion = "Macintosh Mathematica Notebook Front End Version 2.1"; macintoshStandardFontEncoding; paletteColors = 128; automaticGrouping; currentKernel; fontset = title, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeTitle, center, M7, bold, e8, 24, "Times"; ; fontset = subtitle, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeTitle, center, M7, bold, e6, 18, "Times"; ; fontset = subsubtitle, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeTitle, center, M7, italic, e6, 14, "Times"; ; fontset = section, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeSection, grayBox, M22, bold, a20, 18, "Times"; ; fontset = subsection, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeSection, blackBox, M19, bold, a15, 14, "Times"; ; fontset = subsubsection, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeSection, whiteBox, M18, bold, a12, 12, "Times"; ; fontset = text, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 12, "Times"; ; fontset = smalltext, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 10, "Times"; ; fontset = input, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeInput, M42, N23, bold, L-5, 12, "Courier"; ; fontset = output, output, inactive, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, L-5, 12, "Courier"; ; fontset = message, inactive, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, R65535, L-5, 12, "Courier"; ; fontset = print, inactive, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, L-5, 12, "Courier"; ; fontset = info, inactive, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, B65535, L-5, 12, "Courier"; ; fontset = postscript, PostScript, formatAsPostScript, output, inactive, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeGraphics, M7, l34, w282, h287, 12, "Courier"; ; fontset = name, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, italic, 10, "Geneva"; ; fontset = header, inactive, noKeepOnOnePage, preserveAspect, M7, 12, "Times"; ; fontset = leftheader, inactive, L2, 12, "Times"; ; fontset = footer, inactive, noKeepOnOnePage, preserveAspect, center, M7, 12, "Times"; ; fontset = leftfooter, inactive, L2, 12, "Times"; ; fontset = help, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 10, "Times"; ; fontset = clipboard, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 12, "Times"; ; fontset = completions, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 12, "Times"; ; fontset = special1, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 12, "Times"; ; fontset = special2, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 12, "Times"; ; fontset = special3, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 12, "Times"; ; fontset = special4, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 12, "Times"; ; fontset = special5, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 12, "Times"; ; ] :[font = special1; inactive; preserveAspect; ] Virtual Reality -- Flatland The closed initialization cell below defines several Mathematica procedures for working with images. Each image is represented as a list of points -- written {{x1, y1}, {x2, y2}, ... {xn, yn}} The image is drawn by connecting the points in order. The initialization cell defines the following procedures. ShowCurve[list, n] This procedure displays an image of a curve and requires two arguments. The first argument is a list representing a curve as described above. The second argument, n, sets the scale for the x- and y-axies. The two axes go from -n to n. ShowCurves[list, n] This procedure is similar to the first one except it displays a list of curves. Mirror[list] This procedure reflects an image represented by a list in the x-axis. Rot[list, theta] This procedure rotates an image represented by a list around the origin by an angle of theta radians counterclockwise. Trans[list, a, b] This procedure translates an image represented by a list a units horizontally and b units vertically. Dilate[list, factor] This procedure dilates an image represented by a list by the factor, factor. Ident[list] This procedure leaves an image alone. ;[s] 35:0,0;57,1;84,0;141,2;152,0;295,1;329,0;445,1;463,0;630,1;631,0;694,1;696,0;700,1;701,0;704,1;723,0;806,1;818,0;892,1;908,0;997,1;1002,0;1030,1;1047,0;1106,1;1107,0;1131,1;1132,0;1152,1;1172,0;1243,1;1249,0;1252,1;1263,0;1303,-1; 3:18,13,9,Times,0,12,0,0,0;16,13,9,Times,1,12,0,0,0;1,13,9,Times,2,12,0,0,0; :[font = input; initialization; closed; preserveAspect; ] *) Clear[ShowPoint, ShowPoints, ShowCurve, ShowCurves, Transpt, Trans, Mirrorpt, Mirror, Rotpt, Rot, Identpt, Ident] ShowPoint[pt_, high_:8] := Show[Graphics[{PointSize[0.02], Point[pt]}], PlotRange -> {{-high, high}, {-high, high}}, AspectRatio -> Automatic, Frame -> True] ShowPoints[pts_, high_:8] := Show[Graphics[{PointSize[0.02], Map[Point, pts] }], PlotRange -> {{-high, high}, {-high, high}}, AspectRatio -> Automatic, Frame -> True] ShowCurve[curve_, high_:8] := Show[Graphics[Line[curve]], PlotRange -> {{-high, high}, {-high, high}}, AspectRatio -> Automatic, Frame -> True] ShowCurves[curves_, high_:8] := Show[Graphics[{PointSize[0.3], Map[Line, curves]}], PlotRange -> {{-high, high}, {-high, high}}, AspectRatio -> Automatic, Frame -> True] Transpt[pt_, a_, b_] := {pt[[1]] + a, pt[[2]] + b} Mirrorpt[pt_] := {pt[[1]], -pt[[2]]} Rotpt[pt_, theta_] := {pt[[1]] Cos[theta] - pt[[2]] Sin[theta], pt[[1]] Sin[theta] + pt[[2]] Cos[theta]} Dilatept[pt_, ftr_] := {pt[[1]] * ftr, pt[[2]] * ftr} Identpt[pt_] := pt Trans[lst_, a_, b_] := Table[Transpt[lst[[k]], a, b], {k, 1, Length[lst]}] Mirror[lst_] := Table[Mirrorpt[lst[[k]]], {k, 1, Length[lst]}] Rot[lst_, theta_] := Table[Rotpt[lst[[k]], theta], {k, 1, Length[lst]}] Dilate[lst_, ftr_] := Table[Dilatept[lst[[k]], ftr], {k, 1, Length[lst]}] Ident[lst_] := Table[Identpt[lst[[k]]], {k, 1, Length[lst]}] (* :[font = special1; inactive; preserveAspect; ] The cell below shows one way to draw a "V". Evaluate it now. ;[s] 3:0,0;45,1;60,0;62,-1; 2:2,13,9,Times,0,12,0,0,0;1,13,9,Times,1,12,65535,0,0; :[font = input; preserveAspect; ] A := {{1,2}, {2,1}, {3,2}} ShowCurve[A, 4] :[font = special1; inactive; preserveAspect; ] The following cell shows how these procedures can be used to manipulate images and display the results. Evaluate it now. ;[s] 3:0,0;105,1;120,0;122,-1; 2:2,13,9,Times,0,12,0,0,0;1,13,9,Times,1,12,65535,0,0; :[font = input; preserveAspect; ] ShowCurves[{A, Mirror[A]}, 4] ShowCurves[{A, Trans[A, 1, -2]}, 4] ShowCurves[{A, Rot[A, Pi/2]}, 4] ShowCurves[{A, Ident[A]}] ShowCurves[{A, Dilate[A, 2]}] ^*)