MathGroup Archive 2002

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Help for Mathematica

  • To: mathgroup at smc.vnet.net
  • Subject: [mg34141] Re: [mg34139] Help for Mathematica
  • From: Murray Eisenberg <murraye at attbi.com>
  • Date: Mon, 6 May 2002 05:20:09 -0400 (EDT)
  • Organization: Mathematics & Statistics, Univ. of Mass./Amherst
  • References: <200205050848.EAA11957@smc.vnet.net>
  • Reply-to: murray at math.umass.edu
  • Sender: owner-wri-mathgroup at wolfram.com

This won't necessarily help you answer your question, but I wanted you
to know that there's an error in the package that you supplied:  it
won't load without error because of a spurious double-quote in the usage
message for showturtlepath.  That message should be:

 showturtlepath::usage = "showturtlepath displays the turtle's path."  

Caroline wrote:
> 
> Hello! I have a little problem with mathematica. Could someone help
> me, please?
> Well, I have this package called turtle and I must write a function
> "tree" with arguments : length, depth, angle, ratio to draw a binary
> tree. Then I must also write the Sierpinski's triangle with the
> function tree.
> Thanks for helping me.
> Caro
> 
> P.S : Sorry for the bad english, I'm french.
> 
> BeginPackage["Turtle`]
> (* This package provides four functions for controlling the
> movement and orientation of a "turtle" graphics device. It
> maintains a list of the points visited by the turtle in "path",
> which can then be manipulated and displayed as a Graphics
> object. The calling routine must begin by invoking initialize[];
> it can end by either showturtlepath, or by its own
> Show[Graphics[Line[path]], options] command. *)
> 
> initialize::usage = "initialize[p;{0, 0}] places the turtle at
>  p (default is {0, 0}), points it in direction {1, 0}, and
> sets path to {p}."
> 
> showturtlepath::usage = "showturtlepath" displays the turtle's
> path."
> 
> right::usage = "right[a] turns the turtle a degree to the right."
> 
> left::usage = "left[a] turns the turtle a degree to the left."
> 
> forward::usage = "forward[s] moves the turtle forward  s  units,
> and appends the coordinates of the new position to path."
> 
> back::usage = "back[s] moves the turtle back  s  units, and
> appends the coordinates of the new position to path."
> 
> Begin["Turtle`Private`"]
> 
> initialize[start_:{0, 0}] := (X = start; U = {1, 0}; path = {X})
> 
> right[a_] :=
>  U = {{Cos[aa = a Degree//N], Sin[aa]}, {-Sin[aa], Cos[aa]}} . U
> 
> left[a_] :=
>  U = {{Cos[aa = a Degree//N], -Sin[aa]}, {Sin[aa], Cos[aa]}} . U
> 
> forward[s_] := AppendTo[path, X += s U]
> 
> back[s_] := AppendTo[path, X -= s U]
> 
> showturtlepath := Show[Graphics[{{RGBColor[0, 0, 1], Line[path]}}],
>                        PlotRange->All, AspectRatio->1]
> 
> End[]
> 
> EndPackage[]

-- 
Murray Eisenberg                     murray at math.umass.edu
Mathematics & Statistics Dept.       
Lederle Graduate Research Tower      phone 413 549-1020 (H)
University of Massachusetts                413 545-2859 (W)
710 North Pleasant Street
Amherst, MA 01375


  • Prev by Date: Rule application issue
  • Next by Date: RE: Listing
  • Previous by thread: Help for Mathematica
  • Next by thread: Limit to length of lists?