Lab Assignment 2d -- Demo of Part 1 Due Thursday, March 9 (or Friday, March 10 - see Murthy)
Demo of Part 2 Due Thursday, March 23
Writeup due Friday, March 24
CS 5721, Spring Semester, 2006
20 Points
Topics: Translation and Rotation

The assignment: for this lab is to add two capabilities to your Lab 2 program:
Part 1: Allow the user to translate (i.e. move) any object to a new position, and
Part 2: Allow the user to rotate polylines and polygons (and polypoints) about any point in the drawing area and by any angle (since SRGP's text, rectangles, and ellipses are always "upright", it doesn't make sense to rotate them). There are two demo programs in the lab2d directory: lab2d.sample (my version) and Demo_Paint, a student program in which the rotations are limited to rotations about vertices (unlike your program, which should be completely general).

Discussion:
Part 1: To translate an object, you first pick an object -- this can also define a point (x1, y1), then click on another point that you want (x1, y1) to go to -- this will be (x2, y2), and finally add the displacements dx = x2 - x1, and dy = y2 - y1 to each of the vertices defining the object (and erase the old object -- you may want to do this before re-defining the vertices and redrawing the object in the new position).

Part 2: To rotate an object, you first pick an object, then click on a rotation point (x1,y1) -- which could be any point in the drawing area, and then establish the rotation angle. To establish the rotation angle, you could:
1) read it in, or
2) click on another point (x2,y2) different from the rotation point, which would establish the rotation angle: if the new point is directly to the right of the rotation point, the angle is 0 degrees; if the new point is directly above the rotation point, the angle is +90 degrees, etc. Equation (5.30) at the bottom of page 208 of the text may be helpful.

Hint: For method 2) of determining the rotation angle, you don't really need to compute the angle theta, all you really need is:

sin_theta = dy / sqrt(dx^2 + dy^2) and
cos_theta = dx / sqrt(dx^2 + dy^2)
where dx = x2 - x1 and dy = y2 - y1.

Additional Features
1) (1 point) Show the object (outline) being "dragged" from (x1,y1) to (x2,y2) during translation.
2) (2 points) Show the (outline of the) object being "drag-rotated" about (x1,y1) during rotation. For 1 point, show the rubber-banded line from (x1,y1) to (x2,y2) that will establish the rotation angle once the button is released.
3) (1 point) Allow the user to make a copy of an object then move it to a new position. This is "copy-and-paste"; ordinary moving above is "cut-&-paste".
4) (1 point) Allow the user to re-scale an object (by moving the vertices or sides of the extent rectangle; rubber-banding it makes it easier on the user).
5) (1 point) Reflect an object (polyline, polygon, polypoint(?) ) about any line (it doesn't make sense to reflect text, or upright rectangles/ellipses).
6) (1 point) Allow the user to select a group of objects to be moved, rotated, copied, etc.
7) (1 or 2 points) Allow the user to "zoom" in on a subrectangle of the picture (and restore the original dimensions when desired). Successive zooming earns 2 points.
n) Any extra credit items from Lab 2c that you haven't implemented yet.
n+1) Any other features you can think of -- approved by instructor.

What to turn in or demo:
Since much of this lab is interactive, part of the grading will be based on a demonstration of your program. Turn in or do the following items from the Computer Science Lab Report Format:
1. (1 point) The Basic Information (your name, class, section, TA's name, assignment number, and date) can be on a separate cover sheet or as (highlighted) comments at the top of your main program file.
2. (1 point) The Problem Statement is a brief description of The assignment: above. Note: the problem statement can (and should) be in a comment at the top of your main program file.
5. (5 points) Just describe the Algorithm(s) for Translate(), Rotate(), and any important new procedures you needed to implement them.
9. Any Extra Credit items.
11. (5 points) Include all Program Listings. These listings should show good style, be appropriately commented, have the new parts highlighted, and include handwritten explanations if it helps the reader's understanding of the code.
13. & 14. (8 points) Do "demos" of your program, showing that it exhibits the correct functionality for Parts 1 and 2.
15. Include a description of any Known Bugs if needed. You may be able to gain back lost points by a careful analysis of what went wrong and possible fixes.
16. This is optional (and no points usually), but it is useful to think about Possible Improvements. Obviously there are many for this program.
17. Comments on the lab assignment are also optional (and again, no points usually), but appreciated!

Important Note: You may discuss algorithms with other students, but the program and lab report should be your own work.


Page URL: http://www.d.umn.edu /~ddunham/cs5721s06/assignments/lab2d/assignment.html
Page Author: Doug Dunham
Last Modified: Wednesday, 01-Mar-2006 16:31:31 CST
Comments to: ddunham@d.umn.edu