[Univ of Cambridge] [Dept of Engineering]
next up previous contents
Next: Graphics Routines Up: Dodgems: A longer exercise Previous: Arithmetic Routines

Geometric Routines

//Return the distance between x1,y1 and x2,y2
int distance (int x1, int x2, int y1, int y2);

// Given the direction of the dodgem, determine the quadrant direction
Direction get_quadrant_direction(int direction )

// Given coordinates, determine which quadrant the dodgem is in
Quadrant which_quadrant(int x, int y);

// Given coordinates, use which_quadrant and atan to calculate
// the angle of the radius out to the dodgem
int radial_direction(int x, int y);

// calculate the change in x and y for the proposed movement
void get_movement(int speed, int direction, int &x_offset, int &y_offset);



Tim Love
2001-07-05