xxxxxxxxxx
let Cx = 0;
let Cy = 0;
let t = 0; let tx= 0; let ty= 0;
let v= 5;
//-----------------------------------------------------//
let Cx1 = 0; let Cy1 = 0;
let tx1 = 0; let ty1= 0;
let a= 0.25;
function setup() {
createCanvas(windowWidth, windowHeight);
}
function draw() {
background(100);
rettilineo ( Cx, Cy , t , tx , ty, v );
accelerato ( Cx1 , Cy1 , tx1 , ty1 , a );
//--------------TIME : --------------//
textSize(50);
strokeWeight(0.5);
line(0, 12, width, 12);
textAlign(CENTER, TOP);
text('TIME ( sec ? ) :'+ t , 0, 12, width);
}
// MOTO RETTILINEO
function rettilineo( a, b , c, d , e , f){
stroke(220);
strokeWeight(1);
fill('rgb(0,255,0)');
textSize(40);
strokeWeight(0.5);
line(500, 15, 40, 15);
textAlign(RIGHT, TOP);
text('MOTO UNIFORME ' , 0, 12, width);
if ( Cx > windowWidth) {Cx= 0; tx= 0;}
if ( Cy > windowHeight) {Cy= 0; ty= 0;}
ellipse(Cx, Cy, 200, 200);
t++; tx++; ty++; // incremento temporale per T counter, tempo in x e in y
Cy= v*ty; Cx= v*tx; // moto rettilineo uniforme
}
// MOTO ACCELERATO
function accelerato(g , h, i ,l , m ) {
stroke(10);
strokeWeight(1);
fill('rgb(134,215,0)');
textSize(40);
strokeWeight(0.5);
line(500, 15, 40, 15);
textAlign(RIGHT, TOP);
text('MOTO ACCELERATO ' , 0, 50, width);
if ( Cx1 > windowWidth ) {Cx1= 0; tx1=0 ; }
if ( Cy1 > windowHeight) {Cy1= 0; ty1=0; }
ellipse(Cx1, Cy1, 80, 80);
tx1++; ty1++; // incremento temporale per T counter, tempo in x e in y
Cy1= a*pow(ty1, 2)*0.5; Cx1= a*pow(tx1, 2)*0.5; // moto accelerato uniforme, considerando che v iniziale = v0 è nulla
}