I notice that you're looking for the trajectory of the projectile after seconds (s). I didn't read that in my first lecture
Okay, so this is easy after all that.
You are given a, g, v, and s.
you can change a and v into x and y (see Lecture 1) by using these formulas:
SIN(a)=y/v
COS(a)=x/v
therefore:
y = v*SIN(a)
x = v*COS(a)
now, gravity doesn't affect horizonal motion at all, so x will stay unchanged.
you've got an object that starts out moving y m/s UP, and x m/s ACROSS. Every second that passes, y decreases by g m/s, right? 'Cause gravity is acting down on it.
therefore, after s seconds:
xnew = x (unchanged)
ynew = y + g*s (original value plus the effect of gravity/second after s seconds)
NOTES:
* x, y, v, xnew, ynew, and g are NOT LOCATIONS of the object. They are velocities (x, y, xnew, ynew) and accelerations (g). Velocities are in meters/second and accelerations are in (meters/second)/second. So when you get xnew and ynew, they don't tell you where the projectile IS, just the direction and speed that it's currently moving at. To determine the location of the object, you'd need to use another formula. Let me know if this is what you want.
* keep in mind that g should be a NEGATIVE number, so that it's being subtracted from y.
* note that y will begin positive, meaning the object is rising in height (provided you entered an angle that throws the projectile UPwards, i.e. -10 will throw it downwards). The object will reach a peak, and then start falling, as y becomes negative.
* finally, it's important to note that the SIN and COS functions in QBasic take their parameters in RADIANS, not DEGREES. You have to input a (probably in degrees) and then convert it to radians before passing it to the SIN and COS functions. Since 360 degrees (once around the unit circle) equals 2 PI radians (once around the unit circle), the conversion goes like this:
360 degrees = (2 * PI) radians, once around the unit circle
180 degrees = PI radians, halfway around the unit circle
(180 degrees/PI radians) = 1
so to convert from angle to radians, multiply by PI/180
to convert from radians to angle, multiply by 180/PI
You can see where I used this formula in the code above, right underneath the input of angle a.
Let me know if this all makes sense.
*peace*
Meg.