Programming Assignment 2 - Interference Computations

Introduction to Computer Science II, Summer 2001


Table of Contents

Due Date

This assignment is due on Tuesday, 19 June, no later than 2:00 p.m.

See the assignment turn-in page for instructions on turning in your assignment.

Background

Interference computations are an important part of constructing a realistic environment for computer games. Interference computations are responsible for enforcing the real-world property that two solid objects cannot occupy the same space at the same time; it is the interference computations that keep people from walking through walls and keeps the candle from sinking through the mantle piece.

The Problem

You are working as part of a team creating a new computer game, and you are responsible for implementing a class that provides the basic interference computations for the game. The class must have the public interface
class cube {

  public:

    cube(int s)

    void move(int x, int y, int z)

    bool interferes_with(cube c)
  };
The class may have any private members you think are necessary, but it may have only the three public members shown above.

The three public members have the functions

  1. cube() - create a cube s units on a side. The cube's center is co-incident with the origin of the environment.

  2. move() - move the cube x units along the x axis (positive right, negative left), y units along the y axis (positive up, negative down), and z units along the z axis (positive out, negative in).

  3. interferes_with() - return true if the cube c interferes with any part of this cube; return false if c doesn't interfere with this cube. One cube interferes with another cube if there exists some point p in the environment such that p is part of both cubes. A point p is part of a cube if the point lies on the cube's surface or is part of the cube's interior.

Testing

You can compile your cube source with the test file game.cc to test your code. You can download game.cc from a browser (shift-left-click on the link) or access it directly at

/export/home/us/csfac/cs176-summer2001/pa/2/game.cc

from any PC lab machine or rockhopper.


This page last modified on 6 June 2001.