ECE 538 Assignment 5

Do the following exercises:

  1. Write a Python CGI program that calculates a 3D cross product or calculates the GCD of two integers using HTTP query strings to provide the input information.

  2. Write an HTML form to call your Python CGI script from the program above. If necessary, modify your Python script to output HTML. Ideally, the Python script should produce a filled-in version of the form (ready for new input), combined with the results of the current form.

  3. Write a program to determine if two moving circles will collide, and if so find the time until collision.

  4. Write a ball class that contains (1) ball color (2) ball radius (3) ball name or ID (4) ball coordinates (x,y) and (5) ball velocity (vx, vy). Extend your graphical Java application/applet from the previous assignment to show a collection of balls moving around and bouncing off the walls of an enclosing rectangle.

  5. Write a program to use the mouse to draw two or more line segments. Show all points of intersection with small circles at the point of intersection. Allow the user to drag line segments around either by grabbing one end of the line segment and moving just that end, or by grabbing the middle of the line segment and moving it without changing the orientation (or length) of the line segment.

  6. Write a class that encapsulates the concept of a rectangle. See MFC CRect as an example. The member data should be integers and the rectangles should be aligned with the coordinate axes. Provide suitable insertion and extraction routines (for C++) or string conversion functions (Java and Python). Write a member function to indicate whether an integer point (x, y) is contained within the rectangle. Write member functions to return (a) the bounding rectangle of two rectangle arguments and (b) the intersection rectangle of two rectangle arguments (or null if no intersection exists). Provide member functions to draw rectangles on the screen and use a graphical display to illustrate the bounding rectangle and intersection rectangle with various arguments. Use the mouse to define rectangles on the screen.

Your submission should include the usual source-code files, executable programs, and a document reporting your work in general and validation tests in particular.


Maintained by John Loomis, last updated 24 June 2010