Turtle3d is a 3-dimensional turtle graphics package with your choice of Logo, Python or Tcl interface. Download it here.

To build, check that the X11_HOME and OPENGL_HOME variables at the top of Makefile are correct for your system, and then type "gmake". It's been tested on Linux and FreeBSD.

To start the Python version, type this at the shell prompt:

% python -i turtle.py

A window should pop up now, with a pointy triangle (the "turtle") in the middle of that window.

And then a sample session might look like this:

>>> fd(50)
>>> rt(90)
>>> fd(45)
>>> up(120)
>>> rl(45)
>>> fd(60)

The names of the commands are inspired by Logo's -- fd=forward, bk=backward, rt=right, lt=left, pu=pen-up, pd=pen-down. In addition, you can pitch the turtle up (up) or down (dn), and roll it (rl -- there's no "left roll", just roll by a negative number of degrees).

Use your mouse to rotate (left button + drag), pan (middle button) and zoom (right button) the image.

Walking on a sphere

The turtle can be constrained to the surface of a sphere. To do that, use sfd instead of fd and sbk instead of bk (and don't use rl, up or dn at all!) The units of sfd and sbk are degrees.

There is no "sphere mode"; you can type sfd and then fd anywhere and anytime you want. However, sfd always assumes the turtle is currently on the surface of a sphere. So, in a sequence of commands such as

>>> sfd(90)
>>> fd(100)
>>> sfd(90)
the first and second sfd's will each trace one quarter of a great circle, but they will not lie on the same sphere.

If you want to see a shaded blue sphere like the one at right, give the following commands:

>>> sphere(1)
>>> lighting(1)

Other interfaces


To start the Tcl version, start tclsh and then your first command to the Tcl interpreter should be "source turtle.tcl". At this point, the commands look just like the Python commands except instead of parentheses use spaces, i.e. "fd 50", "rt 90", etc.


The executable you have built -- draw -- reads Logo-style turtle commands from standard input. Thus the following could be considered the minimal interface:

% cat | ./draw
fd 50
lt 120

And less minimal but still quite spare:

% sh | ./draw
for i in 1 2 3 4 5
echo fd 50
echo rt 75


I've saved this part for last because getting to a Logo interface takes some doing.

Further features of the Python interface

You can write a file of Python functions that use the turtle commands. The file examples.py shows how this might be done. To use the functions from examples.py, it's necessary to start up a little differently. Your shell command should no longer be "python -i turtle.py" but rather
% python
and then, at the Python interpreter prompt, type
>>> from turtle import *
>>> turtleInit()
>>> import examples
then execute one of the functions from examples.py as follows:
>>> examples.randwalk3d()
And we can go even more automated than that. Have a look at the file callexamples.py, and then, at the shell prompt, type
% python callexamples.py


Abelson, Harold and Andrea diSessa, Turtle geometry : the computer as a medium for exploring mathematics, Cambridge, MA : MIT Press, 1981.

Author: Ted Sternberg