Mathematics 308 - Fall 2005
Announcements (most recent first)
Here are the student projects.
Projects are due by midnight, Friday, December 16.
After that, they will be docked 5%
per day late, but accepted for only for two more days.
Extensions will be granted only for very serious reasons.
The second mid-term examination will be on Wednesday, November 2.
No class Friday, October 28.
The first mid-term examination will be on Friday, October 7.
Class on Wednesday, September 14 will be in
the MATH-STATS computer labs #1 and #2 in the small
flat building just south of the mathematics
building - the Mathematics & Statistics Resource Building (MSRC).
If you do not yet have a Department computer id,
send me email.
- Instructor - Bill Casselman
12:00-1:00 M W F
Math Annex 1100
In the course this fall, as in previous years,
I will show how mathematics and
computers can be used together to produce
graphics of mathematical interest.
The primary programming language to be
used is PostScript. It is ideal for this purpose
because its imaging model uses
affine (and even, implicitly, projective)
geometry in a crucial manner.
Elementary 3D graphics including perspective, and
perhaps something about the regular solids, will also be discussed.
A 3D extension to PostScript will be introduced for this purpose.
Towards the end of the term, students
will have to propose and carry out their own projects.
These will be a major component of the course.
To get an idea of what is involved, you
can look at some previous years' projects:
M308 - Fall 1996.
These were among the earliest a class ever did,
and they wouldn't be acceptable now because of their
low mathematical content. They do illustrate in many cases
a high technical level.
- Fall 1999. These are of much higher mathematical quality,
although the quality varies widely. A few (Dawson, Ting)
M308 - Fall 2002.
Also some spectacular ones.
M308 - Fall 2003.
None as brilliant as the best in other years, but the average quality was
There are therefore two components to the course:
(1) Euclidean geometry and (2) graphics design,
but of course they interact. Geometry is required to
produce graphics, and graphics can be used to explain geometry.
There will be at least one mid-term examination
as well as a final examination. I do not yet know dates.
There will also be regular quizzes whenever
a homework assignment is to be handed in.
Homework will be assigned roughly every two weeks.
The subject of the
course is Euclidean geometry.
More specifically we will range over these and related topics:
Pythagoras' theorem and other stuff from Euclid, vector dot-products,
linear and affine transformations
in two and three dimensions, perspective,
regular solids, and spherical geometry
(although not necessarily in that order).
But the special feature of this course is
that I will teach you how to
apply linear algebra and geometry to
draw figures in both two and three dimensions by computer.
The primary programming language will be PostScript, although
you might be given the option of
using other programming languages for some assignments.
For this purpose you will be given accounts
in the Mathematics department
undergraduate computer laboratory, and given an introduction
to the system. You will be asked
to write programs in assignments and
examinations, but you will not have to memorize large
chunks of any programming language, because as we go along we shall
accumulate a dictionary of useful commands, and
in examinations you will be allowed to refer to it.
Nonetheless, you will have to become familiar with PostScript
through assignments, because the `official' dictionary will be
only a brief summary.
From past experience I would say that
it is not necessary that you already be familiar with
programming in order to do well in this course,
although it will undoubtedly save
you time if you are.
The main reason I am introducing you to PostScript is that
it is a well designed programming language
that forces you to think carefully about aspects of geometry that
might otherwise seem pointless. (One of the
inventors of \ps/, and one of the two co-founders of
the Adobe Systems software company, was once a
graduate student in mathematics at the University of Utah.)
I expect that you will actually enjoy this part of the course
more than some of the more purely mathematical parts, but you must keep
in mind that the two go together.
Roughly speaking, I expect you to spend
an average of about 2-3 hours per week with a computer, but you
should also keep in mind that drawing good pictures with
a computer will often take some time
calculating with just paper and pencil.
The first assignment is due next Monday - write up
in some detail what we discussed in class on Friday, September 9
The second assignment is due Monday, September 19.
Make a PostScript picture to
illustrate the simple proof
(subtractive principle) that areas of a parallelogram and rectangle
with the same base and height are equal.
Make a PostScript program that illustrates the second proof (additive
principle). It should be a page-animation, illustrating
how the decomposition changes as the skewness of the parallelogram increases.
- Locate online and read I.34 and I.35 from
Euclid's Elements. Make a PostScript program
that illustrates his proof of our theorem.
The third assignment is in three parts, and due next Monday
(postponed to next Wednesday, September 28):
Redo the last two questions from the second assignment,
but adding text and consequently changing
diagrams as well. With simple text as well as diagrams,
your proofs can be close to perfect - completely clear
to almost anybody. You can try using the command cvi
(ConVert to Integer)
in the decomposition, but it is actually
not necessary to do so, even to do it perfectly.
The reason for using it is that integers must
be used in repeat loops.
Explain III.20 and III.21 of Euclid's Elements in the same way.
The fourth assignment is due by class on Wednesday, October 5.
When asked to design a procedure, you should also
put in a sample of how it is used to produce a picture,
so that the grader can try out various inputs.
is a sample of how this would work with a procedure that builds a square.
Design a procedure Itransform that has an array of two numbers as input
and another array of two numbers as output.
The input represents a point's coordinates in a coordinate
system that has lower left as origin, one unit equal to one inch.
The output is its coordinates in the user coordinate system.
Thus at the beginning of a program,
before any coordinate changes are made,
[1 1] Itransform would leave [72 72] on the stack,
and after 72 72 translate it would leave [0 0] on the stack.
Use PS to make a sheet of graph paper.
The origin should be at page center.
There should be two grids, one light with squares 1 mm x 1 mm,
the other dark with squares 1 cm x 1 cm.
Design a procedure inscribed with one integer N
as input. It returns an array of points - i.e. each an array
of two numbers - representing a regular polygon of N
sides inscribed in a unit circle. Somewhat like the square
procedure mentioned above.
Locate on the Internet and illustrate in PS
your favorite proof of Pythagoras' Theorem Euclid I.47).
Your program should have the lines
/a 3 def
/b 4 def
/c a dup mul b dup mul add sqrt def
so the grader can change a and b
to be sure you understand the mathematics
in your pictures.
Fifth homework, due at midnight on Friday, October 21.
(Paper) Write out a formula for the inverse of
the `matrix' [a b c d e
(a) (Paper) Write out a formula for the inverse of a three x three matrix
(ai, j). (b) (PostScript) Implement this in PS,
by designing a procedure 3x3inverse with input a 9-array of numbers,
output a 9-array representing the inverse of the corresponding matrix.
The sample part of the exercise should look like this:
so the grader can easily test the
procedure on a `matrix' of his own devising
(contained in the file 3x3.inc).
Design a procedure shear with one numerical argument x
that effects a horizontal shear by x on the coordinate system.
Design a procedure Display-path that displays the components of the
current path by putting a square at the argument of a moveto,
a white diamond at the argument of a lineto,
and a black diamond at each of the three points of an argument to
curveto. The squares should be 4 Adobe points on a side.
There is a sting to this I'll discuss on Monday - you will have
to use procedures that transform back
and forth to page coordinates.
(Look at the section on O in Chapter 6 of the text.)
Thus the code
0 0 moveto
1 0 lineto
4 0 curveto
produces this picture:
Sixth homework - due before class Monday, October 31.
Design a procedure /fcurve
with three arguments: (a) a procedure f
which is in effect furnishes a parametrization
[[x(t) y(t)] [x'(t) y'(t)]];
(b) two numbers t0 and t1
specifying a range of parameters.
It should be called as t0 t1 /f fcurve,
similar to what I did in class (but since I added this suggestion late,
no penalty off for another order).
The effect of the procedure is to
add a single curve segment to the current path approximating
the curve in the range [t0, t1].
Use this and a suitable parametrization function
to draw the curve
x4 + y4 = 1 with 8
Design a procedure /lcurve which has as input a single integer N
and builds (but does not draw) the complete path around the same curve
as N straight line segments. In four drawings,
exhibit the curve drawn with 10, 20, 40, 80 straight line segments,
with a line width of 5 points and in medium gray;
and on top of it in dark red
the curve drawn as in the previous exercise, with line width 1.
Seventh homework - due Monday midnight, November 14.
For 3D drawing, place your eye at z = 5.
(Paper) A regular tetrahedron is a figure made up of 4
equilateral triangular faces, all necessarily of the same size.
It has 4 vertices and 6 edges, all of the same length. Suppose that
the centre of the tetrahedron is at the origin
and that its radius - the distance
from the centre to any vertex - is 1. Suppose also
that one vertex is (0, 0, 1), and that another has
coordinate (0, y, z) with y positive.
What are y and z? What are the other vertices?
(Programming) Draw the tetrahedron (as a frame) in 3D, and set it up
so that page-turning rotates it around the x axis.
Draw in 3D a circle whose centre is at (-1, -1, -1),
which has radius 1, and lies in the plane x=-1?
Set it up so that page-turning rotates it around the line
x=-1, z=0. (here a circle should be a large number of straight
line segments. For rotation around an axis not through the origin,
look at the analogous question in 2D, discussed in Chapter 1 of the text.)
Include the coordinate axes in your picture, but DO NOT ROTATE THEM
with the circle.
Last homework, partial solutions
How to hand in homework?
should be all included in one file
and sent as email to email@example.com
before midnight on the due date, that is to say at
24:00 on that day.
Paper work should be handed in at the beginning of class on
that date. Paper copies of your PostScript pictures should not
be handed in. With few exceptions, the grader will
never look at your code, but grade it only by looking hopefully
at the graphical output.
He will be looking for clarity and elegance in your pictures.
What he sees is what you get.
Your one file could be a single PostScript file
with clearly separated pages for each problem,
or a single .zip file containing one or more such files.
If you send a zip file you must change
the extension to .zap in order to get
past our SPAM filters. The single file must have
your name in its name, as well as the assignment number.
An acceptable file name might JohnJones-hw1.zap. All of the files
must have the same information plus the number
of the question(s) in its name, and code files must have a .ps
extension. Every file must also have your name etc. in it
as a comment at the beginning and end, for example
a line % John Jones - Assignment 1, Question 1.
Some help on how to rename Windows files
and in particular chaning the extension can be found at
various sites on the Internet,
for example this
one. Or google
windows "renaming files"
Friday, September 9
Monday, September 12:
`Animation' by page-turning:
[ Picture |
Using gsave/grestore for stroking
a filled path:
[ Picture |
Friday, September 16
Monday, September 19
Wednesday, September 21
Friday, September 23
Wednesday, September 28. Today I introduced commands
Friday, September 30:
of how to use transform etc.
Wednesday, October 19 - Introduction to drawing parametrized curves
Monday, October 24 -
Solutions for the fifth homework
Question 3 - Effecting a shear in the coordinate
Question 4 - Tracking control points of the current
Wednesday, October 26 - procedures as arguments
Monday, October 31 -
Solutions for the sixth homework
Friday, November 4 -
Beginning of 3D
ps3d.inc - the basic package
(the file epsetup.inc) just sets up the 2D environment
with stuff like 72 dup scale etc.) Keep in mind that the 2D and 3D
environments are independent. The 3D coordinate changes
affect where 3D points are drawn ina n ideal
3D space. These points are projected onto
the viewing plane towards the eye, whose location
should be set once in a program with set-eye.
Coordinates on the viewing plane
are in current 2D user coordinates, so the 2D coordinate changes
affect how they are rendered in your graphics window.
Zip file of all code I demonstrated today,
the package ps3d.inc, and a whole lot more
the file epsetup.inc
which is run in a few demonstration files
Monday, November 7 -
More about 3D
Wednesday, November 9 - rotating around an arbitrary axis
Wednesday, November 16 - solutions to homework due this day
The tetrahedron: [ Picture ][ Code ]
Rotating a circle around an offset axis: [ Picture ][ Code ]
How to construct a regular tetrahedron -
One vertex is at P=(0,0,1)
and another at Q=(0,y,z) with y > 0.
What are the other vertices?
(1) The distance from the origin to all
vertices is the same, namely 1. Therefore y2 + z2 = 1,
and once z is known we can find y.
(2) Because the bottom of the tetrahedron is an equilateral triangle,
all of its vertices have the same z-value. They are obtained by rotating
the given one (0,y,z) around the z-axis by 120o.
This is essentially a rotation in the (x,y)-plane, and
we know the formula for this rotation. We deduce that the
other vertices are R=(-sqrt(3)y/2, -y/2, z)
and S=(sqrt(3)y/2, -y/2, z).
(3) The distance between all pairs
of vertices is the same. The distance2 from Q
to R is
3y2/4 + 9y2/4
and that from P to Q is
y2 + (1-z)2
and if we equate these, substituting y2 = 1- z2,
we get a quadratic equation in z, giving z=-1/3. Then
y = 2 sqrt(2)/3.
Friday, November 18 -
Refer to Chapter 14 of the manual for more
about drawing surfaces. In the examples below, a
face is an array [ < array of 3D points > + < array [A B C D] of four numbers designating
normal function > + < array of 3 numbers
designating colour > ].
Read Chapter 13 for more on
a function normal-function in ps3d.inc
that constructs a normal function from an array of 3D points.
The PS command forall is a kind of loop
command that works a bit like for: it has one argument, an array,
and successively puts items from the array on the stack.
The length operator replaces an array by its length.
Monday, November 21
Monday, November 28 - mathematics fonts
Wednesday, November 30 - solutions to the last homework (incomplete)