Ball cannonball = new Ball(140, 0, 0, 20);
text("R(t) - Position", pos1, line1);
text("x: " + round(cannonball.getX()) + " m", pos1, line2);
text("y: " + round(cannonball.getY()) + " m", pos1, line3);
text("Projectile info", pos2, line1);
text("Vi = " + cannonball.getVi() + " m/s", pos2, line2);
text("Theta = " + cannonball.getTheta() + " °", pos2, line3);
text("Velocity info", pos3, line1);
text("Vx = " + round(cannonball.getVx()) + " m/s", pos3, line2);
text("Vy = " + round(cannonball.getVy()) + " m/s", pos3, line3);
text("Other data", pos4, line1);
text("Time = " + time + " s", pos4, line2);
Ball(float _vi, float _xi, float _yi, float _theta){
if (x >= 0 && x <= width && y >= 0 && y <= height) {
x = vi * t * cos(radians(theta));
y = vi * t * sin(radians(theta)) - 4.9 * pow(t, 2);
ellipse(x + xi, mY(y + yi), 13, 13);
return vi * cos(radians(theta));
return vi * sin(radians(theta)) - 9.8 * time;
float getX () { return x; }
float getY () { return y; }
float getVi () { return vi; }
float getTheta() { return theta; }
float getXi () { return xi; }
float getYi () { return yi; }
float mX (float _value) {
return map(_value, 0, width, width, 0);
float mY (float _value) {
return map(_value, 0, height, height, 0);