アットウィキロゴ

game1022

import java.awt.*;
import java.awt.event.*;

class game1022 extends Frame{
int s,m;
double[] data=new double[101];
double[] gdata=new double[101];
double[] alpha=new double[101];
double delta;
int x;

public static void main(String args[]){
game1022 f=new game1022();
f.setTitle("game1022");
f.setSize(700,700);
f.setBackground(Color.yellow);
f.setVisible(true);
}

game1022(){

for (s=0;s<101;s++){
data[s]=100;
}

delta=(double)Math.PI/100;

for (m=0;m<101;m++){
alpha[m]=seekalpha(delta,m,data);
}

for (s=0;s<101;s++){
gdata[s]=seekfou(alpha,s*delta);
}

addWindowListener(new stopwin());
}

class stopwin extends WindowAdapter{
   public void windowClosing(WindowEvent we){System.exit(0);}
}


public static double seekfou(double[] alpha,double x){
double z;
int m;
z=alpha[0]/2;
for (m=1;m<100;m++){
z=z+alpha[m]*Math.cos(m*x);
}
return z;
}

public static double seekalpha(double delta,int m,double[] data){
int n,nx;
double x1,y1,z;
z=0;
for (n=-100;n<100;n++){
nx=n;
if (nx<0)nx=-nx;  
x1=nx*delta;  
y1=data[nx]*Math.cos(m*x1);  
z=z+delta*y1;
}
z=z/Math.PI;
return z;
}



public void paint(Graphics g){
int x1,x2;

g.drawLine(100,600,100,600);
g.drawLine(100,600,100,100);

g.setColor(Color.blue);
for (s=0;s<100;s++){
x1=(int)gdata[s];
x2=(int)gdata[s+1];
g.drawLine(100+5*s,600-x1,105+5*s,600-x2);
}

g.setColor(Color.red);
for (s=0;s<100;s++){
x1=(int)data[s];
x2=(int)data[s+1];
g.drawLine(100+5*s,600-x1,105+5*s,600-x2);
}

}

}
最終更新:2011年03月07日 16:02