|
Sinus-Kosinus

Sinus-Kosinus-Funktion mit Processing
| Quelltext |
nach "www.roro-seiten.de":Robert Rothhardt |
final int W = 400; final int H = 400;
float x = 0; float y = 200;
int i = 0;
void setup(){
size( W, H );
strokeWeight(2);
background( #FFFFFF );
}
public void line3D( float x, float y, float z ){
int a = round( x + y/2 );
int b = H - round( y/2 );
int c = b - round(z);
stroke( 0, 0, 127, 20 ); line( a, b, a, c );
stroke( 0, 255, 127, 20 ); line( a+2, b, a+2, c );
stroke( 255, 0, 127, 20 ); line( a, c-2, a+2, c );
}
public void draw(){
x++;
if (x > 100){ y--; x=0; }
line3D( round(x*2), round(y*2), cos(x/20)*sin(y/20)*100+100 );
if (i < 10000) i++; else noLoop();
}
|