Thursday, January 22, 2009

For the third assignment, I was able to successfully create the parametric lines. I am still working on the quadratic and cubic curves. Here is the code for the new myLine method.

public void myLine(int x0, int y0, int x1, int y1, double t){

double x = x0;
double y = y0;
for(double i = 0; i <= 1; i+=t){
if(i == 0){
point(x0, y0);
}else if (i == 1){
point(x1, y1);
}else{
x+= (x1-x0)*t;
y+= (y1-y0)*t;
point(Math.round(x),Math.round(y));
}
}
}

No comments:

Post a Comment