Implementation of Asteroid ADT for Collision Detection Simulation
VerifiedAdded on 2019/09/22
|5
|2383
|25
Homework Assignment
AI Summary
This assignment centers on the design and implementation of an Asteroid Abstract Data Type (ADT) for a collision detection simulation, reminiscent of the classic Atari game Asteroids. The core task involves creating an Asteroid ADT capable of representing asteroids as convex polygons, utilizing provided ADTs for Points and LineSegments. The implementation must support key operations: construction of an asteroid from an array of vertices, movement of the asteroid, computation of its center, and crucially, collision detection with other asteroids. The collision detection logic determines if any vertex of one asteroid lies within the polygon of another. The program takes input describing two asteroids, including vertex coordinates and movement vectors, and simulates their movement, printing intermediate states and a final message indicating whether a collision occurred. The provided code includes the driver (main program) and the ADTs for LineSegment and Point, and students are required to complete the Asteroid ADT implementation. The simulation output, which includes the coordinates of the vertices, is designed to be visualized using a separate viewer program. The assignment emphasizes the use of compiler error messages to guide the implementation process and tests the understanding of geometric concepts and data structure design in a game context.