Revision 5 as of 2007-01-18 09:30:31

    Assignment2

Assignment 2 - Animating a Clock Escapement

Due Date: Thursday January 25th, 11:59PM

In this assignment you will practice working with transformations. We'd like you to use OpenGL to create an animation of a pendulum clock, using a hierarchy of transformation represented by a scene graph to properly place various components of the clock on screen. In this assignment you'll also learn to work with several classes from the Stanford Toolkit (libST), these classes provide the ability to save and load shapes and images from disk, as well as organize the components of a scene using a scene graph. As a bonus, you'll get to learn a bit about how a clock works (the TAs did!).

About Clock Escapements

In high school physics, you might have done an experiment demonstrating how the period of a swinging pendulum is only dependent on the length of the pendulum (not on how hard or high you swing it). Because of this property, clock designers have long use pendulums to keep accurate time. In a pendulum clock, an energy source, such as a falling weight or coiled spring drives the rotation of a gear. A device called an escapement utilizes the periodic motion of the pendulum to limit the speed at which the gear turns. This gear drives other gears which spin the various hands of a clock. For example, the second hand is attached to a gear that rotates one complete revolution per minute. Before being coding on this assignment, take a few minutes to read the simple explanation of how pendulum clocks work at HowStuffWorks.com. You also might want to check out the clock escapement animations here.

In this assignment you will animate a pendulum clock with two hands (a second and a minute hand).

Steps

Download and build the starter code

  1. We've created a library of C++ classes that are designed to be simple to use and handy for graphics (we called it libST, for Stanford Toolkit). You;ll use parts of this libary in most of the remaining assignments in the class. Download the assigment 2 starter code and libST source here.

  2. Build the toolkit. libST source code is located in the /libst subdirectory. In this directory there is a Makefile for building with g++ on Linux. Solution files for Visual Studio 2003 and 2005 are located in the /libst/vc2003 and /libst/vc2005 directories respectively. A Visual Studio build of the library should result in the creation of /libst/lib/libst.lib (or libst.a when using g++).

  3. Build the clock application. The starter code for assignment 2 is located in the directory cs148code/assignment2. For this assignment you will modify clock.cpp to produce your clock animation. This directory also contains a number of text files with a .shp extension. These files describe 2D shapes that can be loaded and drawn by the STShape class. Again g++ Makefile or Visual Studio project files for VS 2003 or VS 2005 are provided so your should be able to build the clock application on your platform of choice. Running the provided sample code will produce an animation of a clockwise rotating yellow gear and a counter-clockwise rotating circle and rectangle. It should look like this:

starter

Understanding the Stanford Toolkit

Draw the Clock

  1. Draw the pendulum
  2. Draw all three gears
  3. Draw the second and minute hands

Animate the clock

Save your animation

Grading

Submission Instructions

Additional Resources

Recent