For more help, this book’s examples distribution also includes text-based versions of
this plotting script that print circle point coordinates to the stdout stream for review,
instead of rendering them in a GUI. See the plotterText.py scripts in the clock’s
directory. Here is the sort of output they produce when plotting 4 and 12 points on a
circle that is 400 points wide and high; the output format is simply:
pointnumber : angle = (Xcoordinate, Ycoordinate)
and assumes that the circle is centered at coordinate (0,0):
----------
1 : 90.0 = (200, 0)
2 : 180.0 = (0, −200)
3 : 270.0 = (−200, 0)
4 : 360.0 = (0, 200)
----------
1 : 30.0 = (100, 173)
2 : 60.0 = (173, 100)
3 : 90.0 = (200, 0)
4 : 120.0 = (173, −100)
5 : 150.0 = (100, −173)
6 : 180.0 = (0, −200)
7 : 210.0 = (−100, −173)
8 : 240.0 = (−173, −100)
9 : 270.0 = (−200, 0)
10 : 300.0 = (−173, 100)
11 : 330.0 = (−100, 173)
12 : 360.0 = (0, 200)
----------
Numeric Python Tools
If you do enough number crunching to have followed this section’s abbreviated geom-
etry lesson, you will probably also be interested in exploring the NumPy numeric pro-
gramming extension for Python. It adds things such as vector objects and advanced
mathematical operations, effectively turning Python into a scientific/numeric program-
ming tool that supports efficient numerical array computations, and it has been com-
pared to MatLab. NumPy has been used effectively by many organizations, including
Lawrence Livermore and Los Alamos National Labs—in many cases, allowing Python
with NumPy to replace legacy FORTRAN code.
NumPy must be fetched and installed separately; see Python’s website for links. On the
web, you’ll also find related numeric tools (e.g., SciPy), as well as visualization and 3-
D animation tools (e.g., PyOpenGL, Blender, Maya, vtk, and VPython). At this writing,
NumPy (like the many numeric packages that depend upon it) is officially available for
Python 2.X only, but a version that supports both versions 2.X and 3.X is in early
development release form. Besides the math module, Python itself also has a built-in
complex number type for engineering work, a fixed-precision decimal type added in
release 2.4, and a rational fraction type added in 2.6 and 3.0. See the library manual
and Python language fundamentals books such as Learning Python for details.
750 | Chapter 11: Complete GUI Programs