CS 101 - Intro to Computing, Spring 2008

Lab 14

In class we discussed an example that rotated an image 90 degrees in a clockwise direction.

For this lab, you are to write

Some key issues to think about are

We will need to determine the formulas for the counter clockwise rotation. Consider the following 5x3 "image":
abcde
fghij
klmno
When rotated counter clockwise 90 degrees, it will become:
ejo
din
chm
bgl
afk
We can (hopefully) notice a pattern between the original X and Y positions and the rotated X and Y positions by inspecting the following summary once it is filled in with the pixel position information.
pixelOriginal XOriginal YRotated XRotated Y
a    
b    
c    
d    
e    
f    
g    
h    
i    
...    
o    

The same will need to be done with the image rotated 180 degrees. The above image would be as follows once rotated:
onmlk
jihgf
edcba

Lab Assignment 14

Due: Tuesday 4/29/2007 by 11:59 pm

Write two Java programs that will do the following:

  1. Program 1: Rotate 90 Counter Clockwise

    1. The program is to be named: Lab14a
    2. Print out your name and your net-id
    3. Allow the user to select a picture from a file stored on the local machine
    4. Create an image that has been rotated 90 degrees counter clockwise.
    5. Display the modified image
    6. Save the modfied image to a file on the local machine

  2. Program 2: Rotate 180

    1. The function is to be named: Lab14b
    2. Print out your name and your net-id
    3. Allow the user to select a picture from a file stored on the local machine
    4. Create an image that has been rotated 180 degrees
    5. Display the modified image
    6. Save the modfied image to a file on the local machine

    Be sure to change comment with the name of the author to contain the following:

  3. You are also to submit the Java file electronically by using the UNIX turnin command.

    To use the UNIX turnin command to electronically hand-in your html file using the project name of lab14. To submit the files in lab14a.java and lab14b.java for lab14, the turnin command is entered as:

         turnin -c cs101 -p lab14 lab14a.java lab14b.java
    
    To verify what you submitted using the turnin command type:
         turnin -c cs101 -p lab14 -v
    

Grading Criteria

There is a Finger Exercise based on this lab.