Monday, February 25, 2013

HW 4 - 3D Objects


  • [ arrow keys ] : x,y translation
  • [ .  / ]  : zoom in / out
  • [ z x ] : rotate
  • [ space ] : reset

Java Applet



My Geometry class has methods for the construction of a prism, cylinder, super sphere, super torus, regular polygon, circle, boy surface, seashell, nautilus, cross-cap, Dini's surface, Enneper's surface, Klein bottle, Mobius strip, random hills, roman surface, and 2d mesh. I assume we will learn how to fix the shading and drawing order issue next class.

I'm currently using a Java hack to define anonymous functions. I have a class called Function that lets you define a method to return a double array. This allows the user to generate any paramaterized surface using my Geometry class. I'm probably going to get rid of its explicit use in Geometry.java code because it generates a million class files upon compiling, but before I change anything I'm going to wait and see how we are supposed to shade our objects.

___________________________________________________________________________________
Download HW4.zip
Download HW4_Szymczak.java
Download Geometry.java

Wednesday, February 20, 2013

HW 3 - Matrix Transform


The controls for the applet are the following:

Applet
            • q, w, e : translate (+) x, y, z
            • a, s, d : translate (-) x, y, z
            • i, o, p : scale (+) x, y, z
            • j, k, l : scale (-) x, y, z
            • 1, 2 : rotation velocity (+/-) x
            • 3, 4 : rotation velocity (+/-) y
            • 5, 6 : rotation velocity (+/-) z
            • [space] : reset to identity

I made my own classes instead of implementing the interface IMatrix. First I have a class Matrix that simply defines a general matrix and has methods to perform operations.

class Matrix 

Variables:
    • double[][] mat
    • int nrows, ncols
Methods:
    • void set(int i, int j, double val) : set value of index i,j (HW)
    • double get(int i, int j) : get value of index i,j (HW)
    • int getn() : number of rows
    • int getm() : number of columns
    • double[][] getmat() : matrix ad 2d array
Static Operations:
    • void prettyPrint(Matrix m) : prints out matrix nicely
    • Matrix eye(int n) : returns nxn identity matrix (HW)
    • Matrix mult(double c, Matrix M) : scalar product of matrix
    • Matrix mult(Matrix ... M) : chain multiplication left to right (HW)
    • Matrix copy(Matrix M) : copy
    • Matrix transpose(Matrix M) : transpose

I also have a class called Transform. This defines the 4x4 Matrix TRS to perform transformations on points. There are two modes: separate=true,false. If separate=false, then only TRS is sequentially updated. If separate is true, then T, R, S, the translation, rotation, and scale matrices, are sequentially updated independently. Then TRS is calculated as the multiplication [T][R][S].

class Transform

Variables:
    • Matrix TRS, T, R, S
    • boolean separate, compressed
Methods:
    • void prettyPrint(): prints TRS, T, R, S nicely
    • void compressTRS() : calculate TRS by multiplying [T][R][S]
    • <> get<>() : retrieve one of the variables
    • void set<>(...) : set one of the matrix variables
    • void rotateZYX() : perform x, then y, then z rotation.
    • Matrix tM, rM, rxM, ryM, rzM, sM(...) : primitive matrices
    • double getTRS(int i, int j) (HW)
    • void setTRS(int i, int j, double val) (HW)
    • void reset() : identity (HW)
    • void translate(double x, double y, double z) (HW)
    • void rotate<>(double rad) (HW)
    • Matrix apply(Matrix src)
    • void apply(Matrix src, Matrix dst)  (HW)


___________________________________________________________________________________
Download HW3.zip
Download Matrix.java
Download Transform.java

Wednesday, February 13, 2013

HW2 - Simple Applet



I figured I'd kill two birds with one stone and make something for class and for Valentine's Day. The applet only works in Safari for me.
  • 'c' : change colors
  • '=' : speed up time
  • '-' : slow down time
  • '1' : toggle movement type
  • [arrow keys] : movement

Click For Valentines Day Applet


___________________________________________________________________________________
Valentine.java

Saturday, February 2, 2013

HW 1 - Introductory Essay





___________________________________________________________________________________