CS 185
Fall 2003
Professor J. L. Sibert
Assignment 3
Assigned: September 29 Due: October 13
Write and test a class to perform 2 dimensional geometric transformations.
The specification for the class is given below:
// class for geometric transforms
public class MyXform {
// instance variables
// constructors
public MyXform () {} // default constructor equivalent to identity matrix
// methods
//reset this MyXform to a Translate
public void setTranslate (double tx, double ty) {}
// reset this MyXform to a Scale
public void setScale (double sx, double sy){}
// reset this MyXform to a Rotate
public void setRotate (double theta){}
// if this MyXform is A , and in is B this
method should do A = B•A
public void preCompose (MyXform in){}
// apply this MyXform to a point--useful for implementing
the rest of the assignment
public MyPoint2d apply(MyPoint2d in);
}// end class Xform definition
In addition, you should write a MyPolygon class
//constructor
public MyPolygon(MyPoint2d verts[], int npts)
//render
public void render(Graphics g, MyView v)
//apply
public void apply (MyXform in)
you will also want to add an apply method to your MyLine2d class
public void apply (MyXform in)
As always:
Write a test applet to thouroughly test your new classes.
Hand in the same as for your previous assignments.