Welcome to Natural Simulations
About this video
This course uses JavaScript, ProcessingJS and some maths to program simulations of the natural world. It covers randomness and noise, vectors and forces, trigonometry for rotation, pendulums and waves, and particle systems for things like water, fire and smoke. It is based on Daniel Shiffman's CC-licensed book, The Nature of Code.
You'll be able to
- explain why a simulation never has to be a 100% copy of nature.
- list the main topics of the natural simulations course in order.
- describe what a particle system models.
Key words
- simulation
- A program that models how something in the real world behaves.
- noise
- A more sophisticated, smoother form of randomness.
- vector
- A quantity used with forces to move and accelerate objects in code.
- force
- A push, pull or repel that makes an object accelerate.
- particle system
- Many objects moving together by their own properties and the system's properties.
Transcript
Voiceover: The world is a beautiful place. Sometimes we walk outside and just revel in it, but other times, because we're programmers and we like to program everything, we walk outside, get inspired by it and then run home to program a simulation of the world around us.
Be it's a leaf falling, spinning to the ground or maybe it's a fire burning in a dry forest. We can program simulations of all those things and we can do it here on Khan Academy using JavaScript, ProcessingJS, and a bit of math. In this course on natural simulations, we'll think about how and why things work the way they do in the real world, and then figure out how we can translate into code.
We'll make many simple [cases] because the real world is filled with complexity and we don't always need to model that complexity in order to achieve a [machine] simulation. Of course our computers can only handle so much. Whenever a programmer simulates nature we'll always have to fall short of a 100% copy.
Hey, I think you'll be really impressed with what we can do, especially in the browser. We'll start off by talking about randomness. A technique you've probably already used in your programs. Then noise, a more sophisticated form of that. We can use those to model motion of objects in the world, like somebody lost in the woods but most objects don't move randomly.
Next we'll introduce vectors and forces, which you might have covered in physics class and figure out how to programmatically apply forces or objects so they can accelerate. Based on being pushed, and pulled, and repelled by everything around them. To make it so our objects can spin on their own axis while they're moving, we'll brush up on trigonometry and come up with formulas for angle acceleration.
We can also use trigonometry to model things like pendulums and waves, which can really get pretty hypnotic. Finally, we'll create particle systems. Many objects moving together according to their own properties and the systems properties. That will let us model a natural phenomena like water, fire, smoke.
Okay, so doesn't that sound awesome? Are you pumped? Are you throwing confetti in the air thinking about how soon you'll be able to program that confetti? I know the feeling and you're almost ready to dive in. First we want to give a huge shout out to Daniel Shiffman.
Daniel's an NYU professor that teaches a course on natural simulations. He wrote NatureofCode.com, a whole book about it. Since he CC licensed that book we were able to put it over to JavaScript and bring it over here on Khan Academy, so that all of you can learn it here.
Plus do coding challenges along the way. Without Daniel's book, we wouldn't have this exciting course. Now, ready, set, simulate!
Video © Khan Academy, used under CC BY-NC-SA. Watch on Khan Academy. Puzzicle is not affiliated with Khan Academy.