| Lecture 4 - slide 21 : 33 Program 1 |
public class Circle {
static private double sines[] = new double[1000];
static private double cosines[] = new double[1000];
// Pre calculation of sines and cosines:
static {
double deltaX = (Math.PI/2)/(1000-1);
double x;
int i;
for(i=0, x = 0.0; i < 1000; i++, x = x+deltaX){
sines[i] = Math.sin(x);
cosines[i] = Math.cos(x);
}
} //end static
// Circle operations: Use sines[x] instaed of the static method Math.sin(x)
// and cosines[x] instead of the static method Math.cos(x).
// ...
} |