home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: sci.math.symbolic
- Path: sparky!uunet!spool.mu.edu!yale.edu!ira.uka.de!chx400!bernina!neptune!maeder
- From: maeder@inf.ethz.ch (Roman Maeder)
- Subject: Re: Mma Koch Snowflake in Not. of AMS
- Message-ID: <1992Sep15.074447.9065@neptune.inf.ethz.ch>
- Sender: news@neptune.inf.ethz.ch (Mr News)
- Nntp-Posting-Host: arcturus.inf.ethz.ch
- Reply-To: maeder@inf.ethz.ch (Roman Maeder)
- Organization: Theoretical Computer Science, ETH Zurich
- References: <1992Sep13.205317.28950@cco.caltech.edu>
- Date: Tue, 15 Sep 1992 07:44:47 GMT
- Lines: 67
-
- It appears that I either copied this program incorrectly,
- there was a typo in the publication (please see comment below),
- or the program is not correct.
-
- According to the 1991 version (2nd edition) of Wolfram's
- Mathematica book, FixedPoint does not allow multiple arguments.
-
- there is a comma at the end of the argument list of FixedPoint,
- giving it an addition Null argument.
-
- KochSnowflake[n_Integer?NonNegative]:=
- Show[Graphics[FixedPoint[
- (#1/.Line[{start_,finish_}]
- :>doline[start,finish]) &,
- {Line[{{0,0},{1/2,Sqrt[3]/2}}],
- Line[{{1/2,Sqrt[3]/2},{1,0}}],
- Line[{{1,0},{0,0}}]},
- n,]],
- AspectRatio->Automatic,PlotRange->All]
-
- it should read
-
- KochSnowflake[n_Integer?NonNegative]:=
- Show[Graphics[FixedPoint[
- (#1/.Line[{start_,finish_}]
- :>doline[start,finish]) &,
- {Line[{{0,0},{1/2,Sqrt[3]/2}}],
- Line[{{1/2,Sqrt[3]/2},{1,0}}],
- Line[{{1,0},{0,0}}]},
- n]],
- AspectRatio->Automatic,PlotRange->All]
-
- A minor stylistic point: Since you are not really computing the fixed-point,
- but stopping after n iteration, I would suggest to use Nest[] instead
- of FixedPoint[] (same calling sequence)
-
- Here's the whole program again:
-
- (* program for a Koch snowflake. found in the Notices
- of the AMS Vol.39 #7 Sept 92, page 709 *)
-
- KochSnowflake[n_Integer?NonNegative]:=
- Show[Graphics[
- Nest[ (#1/.Line[{start_,finish_}] :>doline[start,finish]) &,
- {Line[{{0,0},{1/2,Sqrt[3]/2}}],
- Line[{{1/2,Sqrt[3]/2},{1,0}}],
- Line[{{1,0},{0,0}}]},
- n]],
- AspectRatio->Automatic,PlotRange->All]
-
- doline[start_,finish_]:=
- Module[{vec,normal},
- vec=finish-start;
- normal=Reverse[vec] {-1,1} Sqrt[3]/6;
- {Line[{start,start + vec/3}],
- Line[{start + vec/3,start + vec/2 + normal}],
- Line[{start + vec/2 + normal, start + 2 vec/3}],
- Line[{start + 2 vec/3, finish}]
- }
- ]
-
-
- Roman Maeder
- Theoretical Computer Science
- ETH Zentrum, IFW
- 8092 Zurich
- Switzerland
-