+ Mathematics 308, section 101

Mathematics 308 - Fall 2005

Euclidean geometry

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
  • Fall term
  • Section 101
  • 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.
  • M309 - Fall 1999. These are of much higher mathematical quality, although the quality varies widely. A few (Dawson, Ting) are spectacular.
  • M308 - Fall 2002. Also some spectacular ones.
  • M308 - Fall 2003. None as brilliant as the best in other years, but the average quality was higher.

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.


How to hand in homework?

PostScript programs should be all included in one file and sent as email to m308ta@math.ubc.ca 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"

Sample code

  • Friday, September 9
  • Monday, September 12:
    • `Animation' by page-turning: [ Picture | Code ]
    • Using gsave/grestore for stroking a filled path: [ Picture | Code ]
  • Friday, September 16
  • Monday, September 19
  • Wednesday, September 21
    • A sample answer to the first homework question: [ Picture | Code ]
    • Adding text to it: [ Picture | Code ]

      There is a wide latitude in explaining mathematical arguments in this way - not everybody sees the same things at all - but there are some general principles that should usually be followed:

      • State as clearly as you can what it is you are trying to prove.
      • More generally, give the `reader' an idea of what's coming.
      • Continuity is important. Big jumps are bad. Especially important is avoiding a lot of visual distraction, which is why things like vertex labels in a diagram are usually bad - they are like footnotes or hyperlinks.
      • Use color for cues.
  • Friday, September 23
  • Wednesday, September 28. Today I introduced commands
    • transform - replaces a pair x y on the stack, representing a point's user coordinates, by the pair X Y representing its physical coordinates.
    • itransform - goes the opposite way.
    • The version of these with an extra argument [ a b c d e f ] representing a "matrix" according to which the transforms are applied.
    • A way to get the "matrix" representing the one PS uses in the default or page coordinate system: matrix defaultmatrix. So
      x y transform 
      matrix defaultmatrix 

      returns a pair X Y representing a point's page coordinates. The first few sections of Chapter 4 in the text discuss this topic.

  • Friday, September 30:
    • An example 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 system
    • Question 4 - Tracking control points of the current path
  • 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)