drawArrow()to represent velocity vectors.
p1. Type this code in the Initial State pane:
p1by giving the particle an attribute. Change the above line of code so that it now looks like this:
[10, 0]is now an attribute of the particle, just as the position of the particle is also an attribute that we can access like this:
dt) is .05 seconds. So if a particle has a velocity of say 10 meters per second, then we need to define how far it would go in .05 seconds. This will be the rate of position change per frame.
ds) will be calculated by multiplying the particle's velocity by the interval time (
dt). This will calculate the change in position for this frame. It is an identical calculation to the one we defined above, but now just in code:
dtrepresents the time interval duration for each frame.