Question: Step 5 : Show the expected trajectory You should be able to calculate the trajectory of the rocket from the kinematics equations we used towards

Step 5: Show the expected trajectory
You should be able to calculate the trajectory of the rocket from the kinematics equations we used towards the beginning of the course. In this step you will calculate this trajectory and draw it on the screen using drawPoint(xdraw,ydraw); You may recognize this as the same function we used to do the projectile in the planetoids lab.
Just after drawLine(0,0,width,0); add this code which will draw a series of points for the position of the object:
x0=100;
y0=25;
Npoints=1000;
for(i=1;i<=Npoints;i+=1)
{
t =(i-1)*dt;
xdraw = x0+?????;
ydraw = y0+?????;
drawPoint(xdraw,ydraw);
}
Fill in the ???? with the terms that give the right trajectory. The two equations at the beginning of this exercise should be a big help! The main problem is how to put this in the code and what to use for vx0
and vy0
.
Advice #1: Expressions like t^2 won't work in this case (or in most other programming languages). Instead use t*t for t2
Advice #2: Don't use vx or vy here because those variables will change after the object is launched.
Advice #3: Remember that the initial speed is v0
Advice #4: You may want to use some trig functions like cos(theta) and sin(theta). It's important that your trajectory is correct for different values of theta.
Ultimately your code should behave like this.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!