Mathematical Visualization SS07 Technical University Berlin

Assignment 6

Theme: Wallpaper Groups, Tools, and Bouncing Balls

Due: June 6, 2007.

In case you were wondering what theFullMonty means, check out this link.

Part 1. Mathematics

This mathematical assignment provides the mathematics necessary to implement the second part of the programming assignment below.

Part 2. Programming

First, update with the latest version of cvs. See here, if you've forgotten.

Make sure that you have javaDoc links correctly for the jar files jReality-core.jar, charlesgunn.jar, and discreteGroup.jar. If you have forgotten how to do this, see the previous assignment.

Programming project

I have added a new class to the CVS repository, Assignment06. This is a new application which builds upon Assignment05 while introducing jReality tools, in the form of three different interactive tools. It's actually a subclass of Assignment05, so only the new code is visible in Assignment06. Notice that I have made a few changes to Assignment05 in order to make Assignment 06 work smoothly. For example, I now draw a fundamental region as a blue polygon, previously face-drawing was turned off.

  • Download it in the Eclipse Package Explore by selecting "Team... -> Synchronize with repository ..." etc.
  • Choose "Project->Generate javaDoc...". Select in the PackageExplorer and select "Navigate->Open External JavaDoc..." to read more details about the assignment.
  • Run it. First play with the new mouse scroll wheel tool:
    • With your mouse over the graphics window, click the mouse to make sure that window has the focus.
    • Now turn the scroll wheel on your mouse. You should see the pattern become larger or smaller, depending on which direction you turn the wheel.
    • Study the source code to see how the tool is created and attached to the scene graph.
  • Notice that the application has two new tool icons, a pentagon dodecahedron (the default icon in case the tool doesn't provide its own), and a pencil. The following instructions show how to use these tools:
    • Using the affine conjugacy tool:
      • Select the stretching tool (to be more precise: affine conjugacy tool) by selecting the pentagon dodecahedron icon.
      • With the left mouse button, drag vertically over the graphics window. The tessellation should get smaller and larger. When you release, you should see that the tessellation is recomputed to cover the visible window.
      • Using the scroll wheel, you can zoom out to see which elements have been computed. Look at the <i>deactivate()</i> method for the stretcher tool to see how these elements are computed.
    • Using the sketching tool
      • Select the sketching tool by selecting the pencil icon.
      • With your cursor over the blue polygon (fundamental region for the group), press the left mouse button and drag.
      • You should see a series of spheres appear marking the path of your cursor.
      • As you move over the fundamental region itself, they should appear red.
      • If you move your cursor over the "L" shape, they should appear green. Refer to the javaDoc for an explanation.
      • Clicking the middle mouse button removes all the points added with the last left mouse drag.
    • In the main() method, uncomment out the line beginning Secure.setProperty(...) and run the program again.
      • Try using the scroll wheel as above. Nothing happens.
      • Try using the '-' key or '=' keys; they should now have the same effect as the scroll wheel up and down previously had. That is, you should be able to zoom in and out this way.
      • You can find the relevant configuration files on the file system. In a shell, execute:
        • cd /net/pub/www/geometrie/Lehre/SS07/MathVis/resources/sandbox.
        • diff toolconfig-orig.xml toolconfig-modified.xml
      • The difference of these two files should make clear why the click wheel tool behaves differently now.
      • Study the XML files in this directory to see how real hardware devices (keyboard, mouse, etc) are mapped to ascii strings which are then used to identify InputSlots, which serve to activate the interactive tools.
    • There is also a built-in feature for generating an animated tesselllation:
      • Rechoose the group 'O' by selecting "Group->O" from the menu.
      • Activate it by choosing "Actions->Toggle run" or typing the '3' key.
      • You should see a red curve begin to move around. If you focus on the blue square, you should notice that the curve bounces off the sides of this polygon so that it always remains within the square. Your assignment includes writing an extension of this feature (see below).
  • Software engineering comments:
  • Your assignment is to extend Assignment06 according to the following rules.
    1. Create a new class of your own which is a subclass of mathvisss07.Assignment06.
      1. I'd recommend using the name Assignment06-familyname (where lastname is your family name, e.g., gunn). This will help me keep straight the different versions.
      2. Subclassing from Assignment06 means your own code can be much more compact, and it's easier for me to read it and see what you've done. And, if I make improvements to Assignment06, your class will inherit these improvements.
      3. Make sure that you include a file Assignment06Help.html explaining what you did. (Make sure that this file actually shows up in the Help tab of the application. )
    2. Overwrite the method addSketcher() with a modification of this tool, of your own design. Possible directions for modification include:
      1. Create curves instead of point sets.
      2. Write a tool to create polygons.
      3. Use a different coloring scheme.
      4. Write a miniature paint program which instead of creating geometry, creates an image. This image is then texture mapped onto the fundamental domain and tessellated. [this could be turned into a semester project].
    3. Make a copy of the configuration file /net/pub/www/geometrie/Lehre/SS07/MathVis/resources/sandbox/toolconfig-modified.xml in the same directory. Change it in some way and verify that the tool behaviors in Assignment06 change accordingly.
    4. Bouncing ball: This programming task is concerned with providing more content for the wallpaper group application contained in
      1. The main idea: find a convex polygon which is a fundamental domain for the group, and bounce a point (ball) around inside this polygon.
      2. Special case: For the group 'O', this fundamental region is a square. For this special case the current assignment contains a class UnitSquareBouncer which bounces a point around inside the unit square. If you've followed the instructions so far, you played around with this feature above.
        1. One begins with a position and a direction, and for each call to update(), the point is moved in direction a distance based on the speed field of the UnitSquareBouncer. That is, the point moves along the line determined by the point and the direction.
        2. After each move, the position of the point is checked against the four sides (walls) of the unit square. If it has moved across one of the sides, then the position and the direction are mirrored across the line determined by this side.
      3. The general case: Each wallpaper group has a standard fundamental domain, which in every case is a convex polygon. The same algorithm can be carried out if you replace the unit square with this polygon:
        1. For each side of the convex polygon, you calculate the line equation for the line containing this side. This gives line coordinates for the line.
        2. Use these line coordinates to tell when the moving point has crossed the line. When that occurs, mirror the position and the direction across this line.
      4. The exercise sheet provides the mathematics necessary to carry out this:
        1. Exercise 3 of the sheet provides a simple test for telling when a point lies within the convex polygon, and for determining which line it has crossed if it doesn't lie within the polygon.
        2. If the point has crossed a boundary line, you can use Exercise 2 to reflect it (and the direction of motion) across this line.
      5. After completing the exercise sheet, implement a class ConvexPolygonBouncer which extends the class AbstractBouncer:
        1. Replace the existing instance of UnitSquareBouncer in Assignment06 with an instance of your class.
        2. Add code to the method replaceGroup() in Assignment06 so that you set up the convex polygon corresponding to the newly chosen group. I've inserted some code already to extract the vertices of this convex polygon, you just have to initialize your bouncer accordingly.
      6. Helpful tips:
        1. the Java method de.jreality.math.Rn.average(double[][] pts) can be used to calculate the center of gravity referred to in exercise 3 of the sheet.
        2. Be careful with the coordinate systems used. Read the javaDoc for the class AbstractBouncer for details.
  • This assignment is due on 6 Juni, 2007. Please email me if you have any questions or difficulties: there may be mistakes.
  • With this assignment, we have covered all the essentials of jReality that you will need. You should begin spending time each week working on your semester project. If you haven't begun, don't panic. Just get to work. If you need help in getting started, please contact me via e-mail or drop by my office. I'll be in touch with each of you next week to check up on your progress.