# Pendulum Force

This is a beautiful “lecture” that Simon in his pajamas, chocolate paste adorning is face, game me Friday morning. He spoke about pendulum force, a force he was about to apply in a coding project.

The other videos form the very beginning of the lecture, with Simon plays with sine and cosine and explains why location, velocity and acceleration can be vectors and can be angles:

And this is the code where pendulum force is used. It’s an example from The Nature of Code book by Daniel Shiffman, from Chapter 3 on Oscillation:

# Gravitational Attraction (World Generator in Java). Simon’s new own code!

Simon has come up with a new code of his own! It’s about gravitational attraction (particles attracted to targets or moons attracted to planets) and partially based upon the Box2D library but he wrote most of the code himself. Simon used the gravitational constant and Newton’s law of universal gravitation to build this project. The law states that every point mass (m1) attracts every single other point mass (m2by a force (F) pointing along the line intersecting both points. The force is proportional to the product of the two masses and inversely proportional to the square of the distance between them (r):

Simon had come across this formula before in Daniel Shiffman’s tutorials and just like Daniel he changed r to d (for distance):

float strength = (G * 1 * p.mass) / (distance * distance);

Simon pushed his full code to GitHub at:

https://github.com/simon-tiger/gravitational-attraction/blob/master/WorldGenerator.pde

Here Simon added some new features, like pressing keys for adding new targets and particles:

Here the force is becoming stronger with more targets, Simon explains:

We’ve also got a video of Simon talking about this project in Dutch (showing it to his math teacher):