Nature of code — Vectors, Forces, Attractors and a little bit of Repulsion

©from the book “Nature of Code” by Dan Shiffman

Inspiration and research

So, the first beautiful example that I tried to read and work with is Lorenz attractor made in p5.js. This code deals with 3D and uses p5.Vector class.

The original version is even fancier.
The rectangle in Draw() function that hides all the particles’ trails. Without it, the picture gets quite scary.

My sketches

  1. I was thinking about the power of vectors basically after the final for ICM and Physical computing, where we used createVector() for the purpose of following the joints that Kinect gets from the detected body, and making the image of the bone to follow the joint accurately and ROTATE, creating the illusion of Xray. This week felt like the right time to look back at the code.
We also used vectors for debugging purposes. The whole idea of using vectors to help us to get the needed rotation belonged to my ICM professor Lisa Jamhoury.



Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store