Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Turtle graphics
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|Computer Graphics}} {{More citations needed|date=February 2008}} In [[computer graphics]], '''turtle graphics''' are [[vector graphics]] using a relative [[Cursor (computers)|cursor]] (the "[[turtle (robot)|turtle]]") upon a [[Cartesian coordinate system|Cartesian plane]] (x and y axis). Turtle graphics is a key feature of the [[Logo (programming language)|Logo programming language]].<ref>{{Cite web|url = http://www.cs.wustl.edu/~taoju/research/TurtlesforCADRevised.pdf|title = Turtle Geometry in Computer Graphics and Computer Aided Design |date = |accessdate = |website = CSE.WUSTL.edu |publisher = |last1 = Goldman |first1 = Ron |last2 = Schaefer |first2 = Scott |last3 = Ju |first3 = Tao }}</ref> It is also a simple and didactic way of dealing with [[moving frame]]s. ==Overview== [[File:Turtle-animation.gif|thumb|An animation that shows how the turtle is used to create graphics by combining ''forward'' and ''turn'' commands while a pen is touching the paper]] [[File:Turtle Graphics Spiral.svg|thumb|A spiral drawn with an [[Iteration|iterative]] turtle graphics algorithm]] [[File:Circle pattern.png|thumb|left|A turtle graphic pattern drawn with a [[Python (programming language)|Python program]]]] The turtle has three attributes: a location, an orientation (or direction), and a pen. The pen, too, has attributes: color, width, and on/off state (also called ''down'' and ''up''). The turtle moves with commands that are relative to its own position, such as "move forward 10 spaces" and "turn left 90 degrees". The pen carried by the turtle can also be controlled, by enabling it, setting its color, or setting its width. A student could understand (and predict and reason about) the turtle's motion by imagining what they would do if they were the turtle. [[Seymour Papert]] called this "body syntonic" reasoning. A full turtle graphics system requires control flow, procedures, and recursion: many turtle drawing programs fall short. From these building blocks one can build more complex shapes like squares, triangles, circles and other composite figures. The idea of turtle graphics, for example is useful in a [[Lindenmayer system]] for generating [[fractal]]s. [[Turtle geometry]] is also sometimes used in graphics environments as an alternative to a strictly coordinate-addressed graphics system. ==History== Turtle graphics are often associated with the [[Logo programming language]].<ref name="thornburg198303">{{cite news | url=http://www.atarimagazines.com/compute/issue34/068_1_FRIENDS_OF_THE_TURTLE.php | title=Friends of the Turtle: On Logo And Turtles | work=Compute! | date=March 1983 | accessdate=6 October 2013 | author=Thornburg, David D. | pages=148}}</ref> [[Seymour Papert]] added support for turtle graphics to Logo in the late 1960s to support his version of the [[turtle (robot)|turtle robot]], a simple robot controlled from the user's workstation that is designed to carry out the drawing functions assigned to it using a small retractable pen set into or attached to the robot's body. Turtle geometry works somewhat differently from (''x'',''y'') addressed [[Cartesian geometry]], being primarily [[Vector (geometry)|vector]]-based (i.e. relative direction and distance from a starting point) in comparison to coordinate-addressed systems such as bitmaps or raster graphics. As a practical matter, the use of turtle geometry instead of a more traditional model mimics the actual movement logic of the turtle robot. The turtle is traditionally and most often represented pictorially either as a triangle or a turtle icon (though it can be represented by any icon). import turtle tina = turtle.Turtle() tina.shape('turtle') x = 1 tina.speed(10000) colors = ["red", "orange", "yellow", "green", "blue", "purple"] for i in range(100): for i in colors: tina.forward(x*.3) tina.left(60) tina.color(i) tina.right(30.5) x = x+1 Today, the [[Python (programming language)|Python]] programming language's standard library includes a Turtle graphics module.<ref>{{Cite web|url=https://docs.python.org/3.7/library/turtle.html|title=25.1. turtle β Turtle graphics β Python 3.7.0 documentation|website=docs.python.org|access-date=2018-08-23}}</ref> Like its Logo predecessor, the Python implementation of turtle allows programmers to control one or more turtles in a two-dimensional space. Since the standard Python syntax, control flow, and data structures can be used alongside the turtle module, turtle has become a popular way for programmers learning Python to familiarize themselves with the basics of the language.<ref>{{Cite web|url=https://python.camden.rutgers.edu/python_resources/python3_book/hello_little_turtles.html|title=3. Hello, little turtles! β How to Think Like a Computer Scientist: Learning with Python 3|website=python.camden.rutgers.edu|access-date=2018-08-23}}</ref> ==Extension to three dimensions== [[File:Spheres-turtle.png|thumb|[[3D computer graphics|3D turtle graphics]] generated with [[Cheloniidae Turtle Graphics]]]] [[File:Square pattern.png|thumb|left|Pattern drawn with a Python program]] The ideas behind turtle graphics can be extended to include three-dimensional space. This is achieved by using one of several different coordinate models. A common setup is cartesian-rotational as with the original 2D turtle: an additional "up" vector ([[normal vector]]) is defined to choose the plane the turtle's 2D "forward" vector rotates in; the "up" vector itself also rotates around the "forward" vector. In effect, the turtle has two different heading angles, one within the plane and the other determining the plane's angle. Usually changing the plane's angle does not move the turtle, in line with the traditional setup. Verhoeff 2010<ref>{{cite journal |last1=Verhoeff |first1=Tom |title=3D turtle geometry: artwork, theory, program equivalence and symmetry |journal=International Journal of Arts and Technology |date=2010 |volume=3 |issue=2/3 |pages=288β319 |doi=10.1504/IJART.2010.032569 |access-date=28 February 2021 |url=https://www.researchgate.net/publication/249923159}}</ref> implements the two vector approach; a ''roll'' command is used to rotate the "up" vector around the "forward" vector. The article proceeds to develop an algebraic theory to prove geometric properties from syntactic properties of the underlying turtle programs. One of the insights is that a ''dive'' command is really a shorthand of a turn-roll-turn sequence. Cheloniidae Turtle Graphics is a 3D turtle library for [[Java (programming language)|Java]]. It has a ''bank'' command (same as ''roll'') and a ''pitch'' command (same as ''dive'') in the "Rotational Cartesian Turtle". Other coordinate models, including non-Euclidean geometry, are allowed but not included.<ref>[http://spencertipping.com/cheloniidae/ Spencer Tipping on cheloniidae](retrieved 2016-9-17)</ref> {{clear right}} ==See also== [[File:Tartapelago_Cicloide_02.gif |thumb|upright=1| Animated gif with turtle in MSWLogo ([[Cycloid]])<ref>{{cite web|url=http://www.maecla.it/tartapelago.htm |title=Tartapelago|first=Giorgio|last=Pietrocola |date=2005 |website=Maecla }}</ref>]] * [[Moving frame]] * KTurtle * [[L-system]] * [[UCBLogo]] * [[NetLogo]] * [[FMSLogo]] * [[MSWLogo]] * [[Joy (programming language)]] ==References== {{Reflist}} ==Further reading== * {{cite book |last=Papert |first=Seymour |authorlink=Seymour Papert |title=[[Mindstorms (book)|Mindstorms: Children, Computers, and Powerful Ideas]] |year=1993 |location=New York |publisher=[[Basic Books]] |edition=2nd |isbn=0-465-04674-6 |oclc=794964988}} * {{cite book |last=Papert |first=Seymour |title=The Children's Machine: Rethinking School in the Age of the Computer |url=https://archive.org/details/childrensmachine00pape |url-access=registration |location=New York |publisher=Basic Books |year=1993 |isbn=0-465-01830-0 |oclc=248428992}} {{Authority control}} [[Category:Computer graphics]] [[Category:Free educational software]]
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)
Pages transcluded onto the current version of this page
(
help
)
:
Template:Authority control
(
edit
)
Template:Cite book
(
edit
)
Template:Cite journal
(
edit
)
Template:Cite news
(
edit
)
Template:Cite web
(
edit
)
Template:Clear right
(
edit
)
Template:More citations needed
(
edit
)
Template:Reflist
(
edit
)
Template:Short description
(
edit
)