THE GEORGE WASHINGTON UNIVERSITY
School of Engineering and Applied Science
Department of Electrical Engineering and Computer Science

CS 185
Interactive Computer Graphics I
Fall 2003

Professor J. L. Sibert
 

Assigned: 9/15    Due: 9/29

Assignment 2

Your two dimensional line class isn't very useful if it can only draw lines within the 0 to 1 range.  To enable us to do full 2d viewing we have to provide a coordinate transform allowing us to use arbitrary coordinate systems.  You will write a class as specified:

the MyView class will contain the viewing specification,  you need to implement at least the following constructor.

public MyView(MyWindow inw, MyViewport inv) {
}

In addition you need to implement access methods:

// setters
public void setWindow(MyWindow inw){}
public void setViewport(MyViewport inv){}

// getters
public MyWindow getWindow(){}
public MyViewport getViewport(){}

Finally you need a method to apply the viewing specification (window to viewport transformation):

public MyPointNDC apply(MyPoint2d cur){}

Notice that the apply method takes an instanceof MyPoint2d and returns a MyPointNDC.  It is useful to think in terms of points rather than coordinate pairs, so a MyPoint2d represents a 2d point defined in any cartesian coordinate system:

public MyPoint2d( double x, double y){}// constructor

// accessor methods
public double getx(){}
public double gety(){}

public void setx(double in){}
public void sety(double in){}


The MyPointNDC is identical to MyPoint2d except that it's coordinates must lie in NDC space which, as you'll recall, is confined to values between 0 and 1.

You will then add to your MyLine2d class:

An additional constructor:

public MyLine2d (MyPoint2d begin, MyPoint2d end){}

You should also change your MyLine2d render method so that it takes a viewing specification as an argument.

public void render (Graphics g, MyView view){}


Obviously you will have to implment the MyWindow and MyViewport classes as well:

public class MyWindow {

// constructors
public MyWindow(){} // default, set window origin to 0, 0 and diagonal to 1,1

//clone don't assign, avoid side effects
public MyWindow(MyPoint2d llh, MyPoint2d urh){}//  set origin to llh and diagonal to urh


public MyPoint2d getOrigin() {}

public MyPoint2d getDiagonal() {}

public double getHeight() {}

public double getWidth() {}
}

The MyViewport class is similar, but uses MyPointNDC instead of MyPoint2d.






You will turn in, at the beginning of class, a hard copy print out of your source code,
including directions for running the program.

You will also email a zip file, containing all of your source files (including html and
documentation) and your .class files to:

sibert@gwu.edu

include a subject line saying: cs185 assignment 2

The zip file should be named lastname_1.zip, where lastname is your last name.

Get in the habit of doing this, all of your assignments will be turned in this way.