Spinning Pins
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Condenado a estar toda la vida, preparando alguna despedida (Desarraigo, Extremoduro)
I live just a few minutes from the Spanish National Museum of Science and Technology (MUNCYT), where I use to go from time to time with my family. The museum is plenty of interesting artifacts, from a portrait of Albert Einstein made with thousands of small dices to a wind machine to experiment with the Bernoulli’s effect. There is also a device which creates waves. It is formed by a number of sticks, arranged vertically, each of one ending with a ball (so it forms a sort of pin). When you push the start button, all the pins start to move describing circles. Since each pair of consecutive pins are separated by the same angle, the resulting movement imitates a wave. In this experiment I created some other machines. The first one imitates exactly the one of the museum:
If you look carefully only to one pin, you will see how it describes a circle. Each one starts at a different angle and all them move at the same speed. Although an individual pin is pretty boring, all together create a nice pattern. The museum’s machine is formed just by one row of 20 pins. I created a 20×20 grid of pins to make result more appealing.
Playing with the angle between pins you can create another nice patterns like these:
The code is incredibly simple and can be used as a starting point to create much more complicated patterns, changing the speed depending on time or the location of pins. Play with colors or shapes of points, the number of pins or with the separation and speed of them. The magic of movement is created with gganimate
package. You can find the code here.
Merry Christmas and Happy New Year. Thanks a lot for reading my posts.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.