Hi
I have this code and I want to draw each point of the parabole instead of viewing only the point moving.
Code is the following
float dx=10; // Inital x position
float dy=620; // Inital y position
float vx=0; // Inital x velocity
float vy=0; //Inital v velocity, remember negative y is up
float t=.1; // Time steps
float g=9.8; // Acceleration due to gravity, where each pixel = 1 meter
float vyf=0; // Final Velocity
float aimX=50;
float aimY=320;
int angle = 0;
int vi=0;
boolean launch=false;
float time=0.000;
float alturamax;
float projV;
float projAngle;
void setup()
{
size(900, 630);
smooth();
background(100);
frameRate (30/t);
textSize(20);
}
void draw ()
{
background(100);
strokeWeight(1);
fill(255);
ellipse (50, height/2, 50, 50);
ellipse (dx, dy, 20, 20);
fill(180);
rect(25, 25, 90, 25);
rect(25, 75, 90, 25);
strokeWeight(6);
line(-angle+25, 25, -angle+25, 50);
text(-angle+" Deg.", 125, 50);
line(vi+25, 75, vi+25, 100);
text(vi+" m/s", 125, 100);
text("Temps =", 680, 50);
text(time+" s", 770, 50);
text("La velocitat inicial Ă©s =", 545, 70);
text(vi +" m/s", 770, 70);
text("L'angle inicial Ă©s =", 585, 90);
text(-angle +"Âş", 770, 90);
text("La longitud mĂ xima Ă©s =", 525, 110);
text(int(dx-10)+" m", 770, 110);
alturamax=vi*vi*sin(-angle)*sin(-angle)/(2*9.8);
text("La alçada mà xima és =", 545, 130);
text(int(alturamax) + " m", 770, 130);
pushMatrix();
translate(50, height/2);
rotate(radians(angle));
line(0, 0, vi, 0);
line(vi, 0, vi-10, -10);
line(vi, 0, vi-10, 10);
popMatrix();
if (launch)
{
vyf=vy+g*t;
dy=dy+vy*t+.5*(vyf-vy)*t;
vy=vyf;
dx=dx+vx*t;
if (dy<height-10)
{
time=time+t;
}
}
if (dy>(height-10))
{
dy=height-10;
vy=0;
vx=0;
if (dx<770)
{
text(int(dx-10)+" m", dx+15, height-2);
} else
{
text(int(dx-10)+" m", dx-110, height-2);
}
}
}
void mouseDragged()
{
if (mouseX > 25 && mouseX < 115 && mouseY > 25 && mouseY < 50 && dx<11)
{
angle=-mouseX+25;
} else if (mouseX > 25 && mouseX < 115 && mouseY > 75 && mouseY < 100 && dx<11)
{
vi=mouseX-25;
}
}
void mouseReleased()
{
if (dx<11)
{
vy=vi*sin(radians(angle));
vx=vi*cos(radians(angle));
launch=true;
time=0;
}
}
void mousePressed()
{
launch=false;
dx=10;
dy=620;
}
Thanks in advance