
I have created a java interface called IMatrix.java.
Your job for this week's homework is twofold:


(1) Create a java class Matrix.java that implements
    this interface.  Your class should start out looking
    something like this:

    public class Matrix implements IMatrix
    {
        ....
    }

    and needs to provide an implementation for all of
    the methods in interface IMatrix.


(2) Create a java applet that demonstrates the use
    of your Matrix class.  You can make 3D shapes as
    follows:

    (a) Create an array of 3D vertices.

    (b) Create a set of edges that connect these vertices.
        Each edge should refer to the index of each of the
	two vertices it connects.

    For example, here is how you might define a cube:

       double[][] vertices = {
          { -1,-1,-1}, { 1,-1,-1}, {-1, 1,-1}, {1, 1,-1},
          { -1,-1, 1}, { 1,-1, 1}, {-1, 1, 1}, {1, 1, 1},
       };

       int[][] edges = {
          {0,1},{2,3},{4,5},{6,7}, // EDGES IN X DIRECTION
          {0,2},{1,3},{4,6},{5,7}, // EDGES IN Y DIRECTION
          {0,4},{1,5},{2,6},{3,7}, // EDGES IN Z DIRECTION
       };

    To render your shape, you can do something like this:

       Matrix matrix = new Matrix();

       double[] point0 = new double[3];
       double[] point1 = new double[3];

       int[] a = new int[2];
       int[] b = new int[2];

       public void render(Graphics g) {

          ...

	  g.setColor(Color.white);
	  g.fillRect(0, 0, w, h);
	  g.setColor(Color.black);

	  matrix.identity();
	  /*
	     SEQUENCE OF MATRIX TRANSFORMATIONS GOES HERE
          */

          for (int e = 0 ; e < edges.length ; e++) {
             int i = edges[e][0];
             int j = edges[e][1];

             matrix.transform(vertices[i], point0);
             matrix.transform(vertices[j], point1);

	     projectPoint(point0, a);
	     projectPoint(point1, b);

	     g.drawLine(a[0], a[1], b[0], b[1]);
          }
       }

    The implementation of the projectPoint() method is
    described in PROJECTION.txt.

    If you are really stuck, you can use my cube as your
    example, but you get extra points if you come up with
    your own more interesting 3D shapes!

    Your shape should animate over time.  One good way to
    do this is to use time as a variable, as we showed
    in example1.java.  In particular, you can use
    constructs like Math.sin(time) in the arguments
    to your matrix methods.

