Main content
Course: Unlisted resources area > Unit 3
Lesson 1: Pixar simulations articlesStep 1 (particle under gravity)
This program simulates a particle falling due to gravity. Try changing the initial settings.
What do you think will happen if you...
- Increase gravity?
- Change the mass of the particle?
- Make the time step negative?
To save your code press the Spin-off button below the the code. You will then be able to change the name of your program and Save it to your profile.
Want to join the conversation?
- why don't you (anyone) use
ellipse(200, positionY, mass, mass)
instead ofellipse(200,positionY,20,20);
?
it would make more life-like in my opinion, higher mass = bigger shape, and visa-versa.
thanks for reading :)
- J A S(13 votes)- Mass does not necessarily vary directly to size. Volume varies directly to/is size. Assuming the ball's volume is constant, the mass would vary directly to the ball's density. Or, if the ball's density is constant, then the mass would vary directly to volume/size. But I do see what you mean. That could look better, but it could be messy and distract from the initial purpose of the program.(5 votes)
- Which coding language is being used here?(2 votes)
- its js javascript althou i already finish the basic now im doing python css and js hard even thouh i am p4 only at hk(1 vote)
- Is there any difference when we put a negative sign before timeStep(5 votes)
- The particle will have the same behavior even if you add a negative sign in front of the timeStep value (e.g. timeStep = 0.02 and timeStep = -0.02 will have the same behavior).
I made a spin-off of the exercise, which shows two particles falling: one with 0.02 for the timeStep and one with -0.02 for the timeStep. You'll notice that both fall down at the same rate. https://www.khanacademy.org/pixar/particles-falling/5467199435472896
If you're curious, you can also do the algebra or plug in test values to see that the particle position changes at the same rate regardless of whether your timeStep is positive or negative.(4 votes)
- How is it that you can make an actual animated character like a disney film?(4 votes)
- as u go through the diffrent courses t will soon be easy(3 votes)
- I managed to add some X-axis motion after some fiddling with the programming:
// INITIAL SETTINGS
var gravity = 100;
var mass = 30;
var wind = 100;
var positionY = 3;
var positionX = 3;
var velocityY = 0;
var velocityX = 0;
var timeStep = 0.02;
// DRAW FUNCTION
draw = function() {
// FORCE CALCULATIONS
var forceY = mass * gravity;
var forceX = mass * wind;
var accelerationY = forceY/mass;
var accelerationX = forceX/mass;
velocityY = velocityY + accelerationY * timeStep;
velocityX = velocityX + accelerationX * timeStep;
positionY = positionY + velocityY * timeStep;
positionX = positionX + velocityX * timeStep;
// DRAW PARTICLE
background(200, 200, 200);
ellipse(positionX, positionY, 30, 30);
};(4 votes) - ¿dónde encuentro el código?(2 votes)
- What does this coding do to a computer?(2 votes)
- see the lessons on computer science/ how computers work.
basically, a computer language like javascript turns readable code into a LOT of bits(1 or 0) which enter computer circuits as signal on or off. then the computer spits out a lot of bits, and saves them as data, and sometimes puts them on the screen as images, text and such.(1 vote)
- Guys, I am currently on my third lesson of Pixar In A Box. However, I dont know if it would better for me to go to the Computer Programming lesson, or just continue with other lessons of Pixar In A Box?(2 votes)
- Wait, am I missing something? What does changing the mass do? And what does the time step thing do?(1 vote)
- What will happen if it is either to high, to low when you do a spin off will mess it up in the process.(1 vote)