Assignment 2

Fall 2013

CS 582 – GEOMETRIC MODELING

September 10, 2011

Due Date:

Thursday, September 19 at the start of class.

Submission Information:

Per instructions in the Programming Assignments information on the course web page. A short report in hard copy is required. The source and byte code files should be submitted using

submit -user cs582 -tag 582_2 A2.java otherSourceFiles classFiles

Goals:

  • Introduce you to Swing and Java 3D.
  • Learn how to use Swing and Java 3D together, Swing for the GUI and Java 3D for manipulating transforms.

Description:

Write a Swing application that lets you read in an arbitrary transform defined as the composition of translations and rotations about the x, y and z-axes, names and stores it, and prints a stored matrix. The order in which the various rotations and translations are applied to define the final transformation is important and should be controlled by the user.

Build a Swing JFrame with a menu bar and three menus: File, Transform, and Print. The File menu has a single item, Exit, which simply quits. The Transform item has a submenu with the following entries: RotateX, RotateY, RotateZ, Translate, Compose, and Done. Print pops up a window which asks for “Name”, and then prints on the terminal the named transform’s 4×4 matrix. Names are Strings with a maximum of 16 characters.

A current transform M is initialized to the identity, M = I. When RotateX is selected, a small window pops up with a label “Angle in Degrees” and a field for inputting the angle. A corresponding rotation matrix Rx is constructed and composed with the current transform: M = Rx * M. That is, the new M corresponds to first applying the old M and then the rotation. Rotations about Y and Z are treated similarly. When Translate is selected, a window pops up with 3 labels and 3 fields for entering DeltaX, DeltaY, and DeltaZ. These deltas are used to construct a translation matrix T, and the current transform is updated as before, M = T * M.

If we select Compose, a window pops up and requests a “Name”. If this is the name of a previously-defined transform, for example, N, the current transform is composed with it, M = N * M; otherwise the request is ignored or a (recoverable) error is flagged. This process continues until we select Done. This pops up a window requesting a Name. The resulting transform is stored under the assigned Name and the current transform is reset to the identity. Reassignment of Names is not allowed. Such a request should be ignored (and perhaps generate an error message). The order in which the data are entered determines the order of composition of the transforms. For example, if we pick RotateY, then RotateX and then Translate, the result is M = T * Rx * Ry, which corresponds to first applying Ry, then Rx, and lastly T.

Print Friendly, PDF & Email