Main content
Computer programming
Course: Computer programming > Unit 5
Lesson 1: Intro to Natural SimulationsWelcome to Natural Simulations
Created by Pamela Fox.
Want to join the conversation?
- what if we did not learn it in physics class??(42 votes)
- From the author:As Wrath says, there are many videos here on related topics. I try to link to them in various places throughout the course, but if I haven't, you can try searching on Khan or the internet for the given topic.(61 votes)
- Ison the screen an attempt to model someone lost in the woods? 1:10(15 votes)
- That is a random walk simulation (covered in more depth in the next section).
If you watch the Cryptography videos, you will see how random walks can be used to demonstrate the difference between random and pseudo-random numbers.
Here's an example: https://www.khanacademy.org/computing/computer-science/cryptography/crypt/p/random-walk-exploration
You may need to watch a few videos to work out how to use it.(13 votes)
- I am in 8th grade... this will not go well will it?(8 votes)
- So am I, and I'm afraid to say, although it is not impossible, I found it extremely difficult. Then again, you could be ten times smarter than I am, but I strongly advise waiting a year or so or doing extra research. Just dive in and enjoy all you can.
Good luck! :)(9 votes)
- For this course... what level of knowledge about JS i need? I have a basis of C and python. Thanks!(6 votes)
- If you have no basic knowledge of it, you should do the Intro to JavaScript first before attempting this.(7 votes)
- What if we have never taken a physics class?(6 votes)
- Peter, see https://www.khanacademy.org/computing/cs/programming-natural-simulations/intro-natural-simulations/v/welcome-natural-simulations?qa_expand_key=ag5zfmtoYW4tYWNhZGVteXJkCxIIVXNlckRhdGEiQXVzZXJfaWRfa2V5X2h0dHA6Ly9nb29nbGVpZC5raGFuYWNhZGVteS5vcmcvMTA3MTA5ODA0MTQ5NTU3ODMxMjk0DAsSCEZlZWRiYWNrGICAgMCEzb4KDA for pamela's response to Claire on the same question.(5 votes)
- Can i continue this course without learning complete js course??(4 votes)
- You can, but it might get pretty difficult. A lot of the concepts you will use here were taught in the Intro to JS course, so if you don't understand those then it will be hard for you to progress here.(5 votes)
- Just out of the box,l is there a way that you can make your canvas larger like 700,700 or 800,800(3 votes)
- If you type into the URL ?height=800 or ?width=800 you will get a bigger canvas. You change the width and height around.(6 votes)
- Is there a way to control the width only of text? Not textSize();, not height, just width.(3 votes)
- For the width, try scaling horizontally only. This will make the text appear wider. (Really, only your co-ordinates get wider). This can be found in the Games and Visualisations course.(5 votes)
- Can this unit help with making game physics?(4 votes)
- so, Im in middle school, and I've never done trigonometry in my life. Do I have to know trigonometry in order to complete this course?(3 votes)
- No, but it would be useful to learn Trigonometry, because it's used. But not really necessary. You can learn Trigonometry here:
https://www.khanacademy.org/math/trigonometry(2 votes)
Video 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!