float time = 0;
float radius = 50;
float x;
float y;
ArrayList
ArrayList
void setup() {
size(800, 700);
}
void draw() {
background(0);
text("Gelombang Sinus",400, 75);
text("Gelombang Cosinus",75, 230);
text("Jika digambar dalam satu sumbu",450, 350);
text("Gelombang sinus dan cosinus berbeda fase 90 derajat",450, 370);
translate(150, 150);
stroke(255);
noFill();
ellipse(0, 0, radius*2, radius*2);
time -= 0.04;
x = radius*cos(time);
y = radius*sin(time);
fill(255);
strokeWeight(1);
ellipse(x, y, 8, 8);
strokeWeight(0.7);
line(0, 0, x, y);
wave.add(0,y);
wave2.add(0,x);
translate(100,0);
stroke(150,150,150);
strokeWeight(0.7);
line(-20, 0, 700, 0);
line(0,-radius, 0, radius);
line(x-100, y, 0, wave.get(0));
beginShape();
noFill();
stroke(255,0,0);
strokeWeight(2);
for (int i =0; i < wave.size(); i++) {
vertex(i,wave.get(i));
}
endShape();
translate(-100,100);
stroke(150,150,150);
strokeWeight(0.7);
line(x, y-100, wave2.get(0),0);
line(0, -20, 0, 700);
line(-radius, 0, radius, 0);
beginShape();
noFill();
stroke(0,0,255);
strokeWeight(2);
for (int i =0; i < wave2.size(); i++) {
vertex(wave2.get(i),i);
}
endShape();
translate(300,200);
stroke(255);
noFill();
ellipse(-100, 0, radius*2, radius*2);
time -= 0.04;
x = radius*cos(time);
y = radius*sin(time);
fill(255);
strokeWeight(1);
ellipse(x-100, y, 8, 8);
strokeWeight(0.7);
line(-100, 0, x-100, y);
stroke(150,150,150);
strokeWeight(0.7);
line(-20, 0, 700, 0);
line(0,-radius, 0, radius);
line(x-100, y, 0, wave.get(0));
beginShape();
noFill();
stroke(255,0,0);
strokeWeight(2);
for (int i =0; i < wave.size(); i++) {
vertex(i,wave.get(i));
}
endShape();
stroke(150,150,150);
strokeWeight(0.7);
line(x-100, y, 0, wave2.get(0));
beginShape();
noFill();
stroke(0,0,255);
strokeWeight(2);
for (int i =0; i < wave2.size(); i++) {
vertex(i, wave2.get(i));
}
endShape();
}