Turtle graphics

Last updated

In computer graphics, turtle graphics are vector graphics using a relative cursor (the "turtle") upon a Cartesian plane (x and y axis). Turtle graphics is a key feature of the Logo programming language. [1]

Contents

Overview

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 Turtle-animation.gif
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
A spiral drawn with an iterative turtle graphics algorithm Turtle Graphics Spiral.svg
A spiral drawn with an iterative turtle graphics algorithm
A turtle graphic pattern drawn with a Python program Circle pattern.png
A turtle graphic pattern drawn with a 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 fractals.

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. [2] Seymour Papert added support for turtle graphics to Logo in the late 1960s to support his version of the 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-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).

Today, the Python programming language's standard library includes a Turtle graphics module. [3] 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. [4]

Extension to three dimensions

3D turtle graphics generated with Cheloniidae Turtle Graphics Spheres-turtle.png
3D turtle graphics generated with Cheloniidae Turtle Graphics
Pattern drawn with a Python program Square pattern.png
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 [5] 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. 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. [6]

See also

Animated gif with turtle in MSWLogo (Cycloid) Tartapelago Cicloide 02.gif
Animated gif with turtle in MSWLogo (Cycloid)

Related Research Articles

<span class="mw-page-title-main">Cartesian coordinate system</span> Most common coordinate system (geometry)

In geometry, a Cartesian coordinate system in a plane is a coordinate system that specifies each point uniquely by a pair of real numbers called coordinates, which are the signed distances to the point from two fixed perpendicular oriented lines, called coordinate lines, coordinate axes or just axes of the system. The point where they meet is called the origin and has (0, 0) as coordinates.

<span class="mw-page-title-main">Logo (programming language)</span> Computer programming language

Logo is an educational programming language, designed in 1967 by Wally Feurzeig, Seymour Papert, and Cynthia Solomon. Logo is not an acronym: the name was coined by Feurzeig while he was at Bolt, Beranek and Newman, and derives from the Greek logos, meaning word or thought.

<span class="mw-page-title-main">Seymour Papert</span> MIT mathematician, computer scientist, and educator

Seymour Aubrey Papert was a South African-born American mathematician, computer scientist, and educator, who spent most of his career teaching and researching at MIT. He was one of the pioneers of artificial intelligence, and of the constructionist movement in education. He was co-inventor, with Wally Feurzeig and Cynthia Solomon, of the Logo programming language.

<span class="mw-page-title-main">Vector graphics</span> Computer graphics images defined by points, lines and curves

Vector graphics are a form of computer graphics in which visual images are created directly from geometric shapes defined on a Cartesian plane, such as points, lines, curves and polygons. The associated mechanisms may include vector display and printing hardware, vector data models and file formats, as well as the software based on these data models. Vector graphics is an alternative to raster or bitmap graphics, with each having advantages and disadvantages in specific situations.

<span class="mw-page-title-main">2D computer graphics</span> Computer-based generation of digital images

2D computer graphics is the computer-based generation of digital images—mostly from two-dimensional models and by techniques specific to them. It may refer to the branch of computer science that comprises such techniques or to the models themselves.

HP-GL, short for Hewlett-Packard Graphics Language and often written as HPGL, is a printer control language created by Hewlett-Packard (HP). HP-GL was the primary printer control language used by HP plotters. It was introduced with the plotter HP-9872 in 1977 and became a standard for almost all plotters. Hewlett-Packard's printers also usually support HP-GL/2 in addition to PCL.

<span class="mw-page-title-main">Cartesian coordinate robot</span> Robot with axes of control that are linear and orthogonal

A Cartesian coordinate robot is an industrial robot whose three principal axes of control are linear and are at right angles to each other. The three sliding joints correspond to moving the wrist up-down, in-out, back-forth. Among other advantages, this mechanical arrangement simplifies the robot control arm solution. It has high reliability and precision when operating in three-dimensional space. As a robot coordinate system, it is also effective for horizontal travel and for stacking bins.

The computer graphics pipeline, also known as the rendering pipeline or graphics pipeline, is a framework within computer graphics that outlines the necessary procedures for transforming a three-dimensional (3D) scene into a two-dimensional (2D) representation on a screen. Once a 3D model is generated, the graphics pipeline converts the model into a visually perceivable format on the computer display. Due to the dependence on specific software, hardware configurations, and desired display attributes, a universally applicable graphics pipeline does not exist. Nevertheless, graphics application programming interfaces (APIs), such as Direct3D, OpenGL and Vulkan were developed to standardize common procedures and oversee the graphics pipeline of a given hardware accelerator. These APIs provide an abstraction layer over the underlying hardware, relieving programmers from the need to write code explicitly targeting various graphics hardware accelerators like AMD, Intel, Nvidia, and others.

<span class="mw-page-title-main">Constructionism (learning theory)</span> Learning theory involving the construction of mental models

Constructionist learning is the creation by learners of mental models to understand the world around them. Constructionism advocates student-centered, discovery learning where students use what they already know to acquire more knowledge. Students learn through participation in project-based learning where they make connections between different ideas and areas of knowledge facilitated by the teacher through coaching rather than using lectures or step-by-step guidance. Further, constructionism holds that learning can happen most effectively when people are active in making tangible objects in the real world. In this sense, constructionism is connected with experiential learning and builds on Jean Piaget's epistemological theory of constructivism.

<span class="mw-page-title-main">Orientation (geometry)</span> Notion of pointing in a direction

In geometry, the orientation, attitude, bearing, direction, or angular position of an object – such as a line, plane or rigid body – is part of the description of how it is placed in the space it occupies. More specifically, it refers to the imaginary rotation that is needed to move the object from a reference placement to its current placement. A rotation may not be enough to reach the current placement, in which case it may be necessary to add an imaginary translation to change the object's position. The position and orientation together fully describe how the object is placed in space. The above-mentioned imaginary rotation and translation may be thought to occur in any order, as the orientation of an object does not change when it translates, and its position does not change when it rotates.

MicroWorlds is a family of computer programs developed by Logo Computer Systems Inc. (LCSI) that uses the Logo programming language and a turtle-shaped object to teach language, mathematics, programming, and robotics concepts in primary and secondary education. The program was part of a larger set of dialects and implementations created by Seymour Papert aimed at triggering the development of abstract ideas by children through experimentation.

Geometry is a branch of mathematics concerned with questions of shape, size, relative position of figures, and the properties of space. Geometry is one of the oldest mathematical sciences.

MicroWorlds JR is a computer program using a simplified version of the Logo programming language to teach non-readers or early readers to program in Logo. It was first launched in 2004 by Logo Computer Systems, Inc. (LCSI), and as in their original line of MicroWorlds programs, the object on the screen begins as a turtle and can be controlled with basic commands to make it move. Differing from the Logo syntax developed by Seymour Papert and teams at MIT, MicroWorlds JR uses images to replace the command names, which are selected by the child to create turtle graphics. The turtle object can be given a variety of shapes that act as a costume for the turtle, and therefore lends itself to a variety of animations and creative stories and projects for younger students.

<span class="mw-page-title-main">Turtle (robot)</span> 1940s class of educational robots

12px|frameless|alt=Shubham|Shubham

WSFN is an interpreted programming language for controlling robots created by Li-Chen Wang. It was designed to be as small as possible, a "tiny" language, similar to Wang's earlier effort, Palo Alto Tiny BASIC. WSFN was first published in Dr. Dobb's Journal in September 1977.

<span class="mw-page-title-main">Cynthia Solomon</span> Computer scientist

Cynthia Solomon is an American computer scientist known for her work in popularizing computer science for students. She is a pioneer in the fields of computer science, and educational computing. While working as a researcher at Massachusetts Institute of Technology (MIT), Solomon took it upon herself to understand and program in the programming language Lisp. As she began learning this language, she realized the need for a programming language that was more accessible and understandable for children. Throughout her research studies in education, Solomon worked full-time as a computer teacher in elementary and secondary schools. Her work has mainly focused on research on human-computer interaction and children as designers. While working at Bolt, Beranek and Newman, she worked with Wally Feurzeig and Seymour Papert, to create the first programming language for children, named Logo. The language was created to teach concepts of programming related to Lisp. Solomon has attained many accomplishments in her life such as being the vice president of R&D for Logo Computer Systems, Inc., when Apple Logo was developed and was the Director of the Atari Cambridge Research Laboratory. Solomon worked on the program committee of Constructing Modern Knowledge and the Marvin Minsky Institute for Artificial Intelligence in 2016. Further, she has published many writings based on research in the field of child education and technology in the classroom. Solomon has conducted workshops in elementary schools, high schools, and colleges regarding academic research and writing. She continues to contribute to the field by speaking at conferences and working with the One Laptop per Child Foundation.

<span class="mw-page-title-main">LibreLogo</span> Vector graphics language

LibreLogo is an integrated development environment (IDE) for computer programming in the programming language Python, which works like the language Logo using interactive vector turtle graphics. Its final output is a vector graphics rendition within the LibreOffice suite. It can be used for education and desktop publishing.

<span class="mw-page-title-main">UCBLogo</span> Logo programming language dialect

UCBLogo, also termed Berkeley Logo, is a programming language, a dialect of Logo, which derived from Lisp. It is a dialect of Logo intended to be a "minimum Logo standard".

<span class="mw-page-title-main">Turtlestitch</span> Embroidery platform

Turtlestitch is a free and open source platform for generating and sharing patterns for embroidery machines. Turtlestitch is derived from educational programming languages such as Logo, Scratch and Snap! using the same jigsaw style programming paradigm which offers simplicity suitable for novices but has powerful features, described as ‘low threshold, high ceiling’ by Seymour Papert. Its microworld is a turtle representing the needle of a programmable embroidery machine. Turtlestitch can be used for creating novel patterns for embroidery, combining the abstract logic of computing and the physical materiality of textiles. Its primary use is educational, as it offers a way of introducing programming to audiences with diverse interests. A growing gallery of open source embroidery designs enables community-based collaboration and shared learning. In 2017, Turtlestitch received the award for the best Open Educational Resource in the German-speaking countries.

References

  1. Goldman, Ron; Schaefer, Scott; Ju, Tao. "Turtle Geometry in Computer Graphics and Computer Aided Design" (PDF). CSE.WUSTL.edu.
  2. Thornburg, David D. (March 1983). "Friends of the Turtle: On Logo And Turtles". Compute!. p. 148. Retrieved 6 October 2013.
  3. "25.1. turtle — Turtle graphics — Python 3.7.0 documentation". docs.python.org. Retrieved 2018-08-23.
  4. "3. Hello, little turtles! — How to Think Like a Computer Scientist: Learning with Python 3". python.camden.rutgers.edu. Retrieved 2018-08-23.
  5. Verhoeff, Tom (2010). "3D turtle geometry: artwork, theory, program equivalence and symmetry". International Journal of Arts and Technology. 3 (2/3): 288–319. doi:10.1504/IJART.2010.032569 . Retrieved 28 February 2021.
  6. Spencer Tipping on cheloniidae(retrieved 2016-9-17)
  7. Pietrocola, Giorgio (2005). "Tartapelago". Maecla.

Further reading