CS 101 Lecture Notes

Week Twelve, Monday/Tuesday: Data Structures, Continued

Example Program: Geometry

Geometric modeling is an important topic in computer science with applications in many fields including physics, electrical product engineering, design, and computer graphics.

Geometric objects, such as points, lines, polygons, and solids, can be modeled using C structs. Here we model points, lines, and polygons in two dimensions, and use functions to compute the distance between two points and the minimal distance between two polygons. Consider this source code, which, when compiled, produces the follwing output:


Program execution.


This page established March 16, 1999; last updated March 28, 1999.