The Nature of Code Forces example translated into Lua

Another translation involving the Codea app, only this time Simon decided to translate an example from Daniel Shiffman’s book The Nature of Code (Java) into Lua. The example comes from Chapter 2 of the book, Forces, and focuses on creating forces in the Processing world. Forces are vectors that can be applied to objects, those can be either some forces made up specifically for a project or forces modelling those already present in the real world. The chapter discusses Newton’s second law in detail (Net Force equals mass times acceleration). I have noticed that, thanks to Daniel Shiffman, Simon knows the three Netwon laws very well by now.

Simon introduced gravity, restitution, mass (many objects of varying mass) and wind to his Lua sketch:



Here is a photo of Simon’s code after he added restitution (velocity times -0.8):


In the second video, Simon also briefly talks about the force of friction (Frictio=µNv). He read about friction in the same chapter and became fascinated with it. Since he was telling me about it when we were outside today, I asked him to repeat it in the video.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s