The assignment consisted on creating the potential on a circle centered around three charges.
I used a for loop to complete the assignment. The for loop i used starts from 0 to 44, which makes the loop run 45 times, so 45 spheres will be printed out. The 44 number was a random number I used after my tries, because it creates a perfect circle with the same space between each sphere. The rate() instruction displays each sphere at a certain frequency. This instruction is required because the assignment ask for an animation of the program, or else, it would just display all the spheres at the same time. I used rate(3), so each sphere is supposed to appear after 1/3 seconds. The rest of the code, was based on what we did in class. However, for the location of each sphere, I used the cos and sin functions for x and y respectively in order to simulate a circle. This was also used on the label of each potential because without it, the label will block some some previous spheres.
This is the final output.
This is the animation.
No comments:
Post a Comment