Each of the parameters are being used to find particular X
and Y
values. O
changes from 0 to pi
in steps of pi/8
while Vo
, t
and g
remain unchanged.
The t
variable is simply an array from 0 to 5 in steps of 1 and so there are 6 time points defined all together. With these time points and with a particular value of O
, but with the values of Vo
, t
and g
being held constant throughout this entire endeavour, 6 X
and Y
points are defined and are thus plotted on a graph. A graph is generated for each value of O
and thus a set of 6 different X
and Y
points are generated. Each graph with each value of O
are all plotted on the same graph.
We can rewrite the above code in pseudo-code to make it easier to understand as follows:
for i = 0, pi/8, 2*pi/8, ..., pi
define Vo = 10
define O = i
define t = [0, 1, 2, 3, 4, 5]
define g = 9.8
run function plotTrajectory(Vo, O, t, g)
end
function plotTrajectory(Vo, O, t, g)
calculate x = Vo * cos(O) * t, for t = 0, 1, 2, 3, 4, 5
calculate y = Vo * (sin(O) * t) - (0.5 * g * t^2), for t = 0, 1, 2, 3, 4, 5
plot x and y for t = 0, 1, 2, 3, 4, 5 on the same graph
end
1
solved What does this syntax [0:1:5] mean (do) in the context of the given code?