Design Patterns Java™ Workbook

(Michael S) #1
Chapter 4. Facade

x[i] = (int) (w / 2 + r Math.cos(theta));
y[i] = (int) (h / 2 - r
Math.sin(theta));
}
g.drawPolyline(x, y, nPoint);
}
}


Defining x and y functions in terms of t lets you divide the tasks of determining x
values and y values. This is often simpler than defining y in terms of x and often
facilitates the mapping of x and y onto a Graphicsobject's coordinates. Parametric
equations also simplify the plotting of curves where y is not a single-valued function
of x.

Free download pdf