xxxxxxxxxx
//specifico le variabili
let x = 1
let y = 1
let Vx = 1
let Vy = 3
let s = 1
let t = 1
let Vs = 3
let Vt = 5
function setup() {
createCanvas(windowWidth, windowHeight);
}
function draw() {
background(mouseX, x, y, 20);
//quadrato di testo non Mru
fill (255)
square(width/3, height/3, 200, 20)
//quadrato di testo Mru
fill (255)
square(width/2 + 50, height/3, 200, 20)
//moto particella non Mru
if (x > width) {
Vy = Vy
Vx = - Vx
}
if (y > height) {
Vx = Vx
Vy = -Vy
}
y = y + Vy++
x = x + Vx++
strokeWeight (50);
point (x + 10, y + 10);
// particella che va di MRU
if (s > width) {
s = 0
}
if (t > width) {
t = 0
}
s = s + Vs
t = t + Vt
strokeWeight (50)
point (s + 10, t + 10)
//componenti di testo
//velocità componenti particella non Mru
textSize (20);
fill (100);
text ('MOTO ? ', width/3 + 50, height/2 - 95);
textSize (10);
fill (0);
text ('Vx particle =' + Vx , width/3 + 50, height/2 -70);
textSize (10);
fill (0);
text ('Vy particle =' + Vy , width/3 + 50, height/2 -50);
//posizione componenti particella
textSize (10);
fill (0);
text ('X position particle =' + x, width/3 + 50, height/2 - 30);
textSize (10);
fill (0);
text ('Y position particle =' + y, width/3 + 50, height/2 - 10);
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
//velocità componenti particella Mru
textSize (20);
fill (100);
text ('MRU', width/2 + 100, height/2 - 95);
textSize (10);
fill (0);
text ('Vx particle =' + Vs , width/2 + 100, height/2 -70);
textSize (10);
fill (0);
text ('Vy particle =' + Vt , width/2 + 100, height/2 -50);
//posizione componenti particella
textSize (10);
fill (0);
text ('X position particle =' + s, width/2 + 100, height/2 - 30);
textSize (10);
fill (0);
text ('Y position particle =' + t, width/2 + 100, height/2 - 10);
}