xxxxxxxxxx
55
let W=800;
let H=600;
let t=0;
let a=250;
let b=150;
let points=[];
let l1,l2;
function setup() {
createCanvas(800, 600);
background(355,255,255);
}
function draw() {
background(355,255,255);
translate(W/2,H/2);
stroke('BLACK');
for(i=0;i<points.length;i++){
point(points[i].x,points[i].y);
}
strokeWeight(5);
stroke('RED')
point(-150,0);
point(150,0);
push()
noStroke();
text("S'",-150,0);
text("S",150,0);
pop();
stroke('GREEN')
point(a*cos(t),b*sin(t));
push()
noStroke();
text("P",a*cos(t),b*sin(t));
pop();
stroke('BLUE');
points.push({x:a*cos(t),y:b*sin(t)});
l1=dist(-150, 0, a*cos(t),b*sin(t));
l2=dist(150, 0, a*cos(t),b*sin(t));
strokeWeight(2);
line(-150,0,a*cos(t),b*sin(t));
line(150,0,a*cos(t),b*sin(t));
stroke('ORANGE');
push();
noStroke();
fill('PURPLE');
textSize(20);
text("SP+S'P=2a",00,200);
pop();
t=t+0.005;
}