3.4: Pendulum Simulation – The Nature of Code

[ad_1]
Chapter: 3

Official book website:

Twitter:

This video walks through a simulation of a pendulum.

Read along:

Help us caption & translate this video!


Posted

in

by

Tags:

Comments

18 responses to “3.4: Pendulum Simulation – The Nature of Code”

  1. Raphael Kottakal Avatar

    You're right. You do need a script…

  2. Jithin K.S. Avatar

    I found that the amplitude of the pendulum seems to increase after each cycle when the code is tested. And I found out that the problem is that the velocity should be calculated before angle is calculated. It should be

    aVel+= aAcc;
    angle+=aVel; (at 14:53)

    instead of

    angle+=aVel;
    aVel+=aAcc;

    I'm not sure, but I think the problem is that if it were the other way, at the extreme position, instead of adding velocity value 0 (velocity at extreme positions) to the angle, the previous value of velocity is added which leads to increase in amplitude.

    And Thanks very much for the video….You are awesome….

  3. RRE Designs Avatar

    I'm using Processing 3.3.4 in Python mode and I had to do a translate and place the origin in the center for this to work. 😐

  4. MrLardax Avatar

    hey that's pretty good.

  5. Enriqe64 Avatar

    It's good that there are altruists like you walking on earth.

  6. Yakov Reznikov Avatar

    How would you extend this to more 2 or more pendulums

  7. matthew rice Avatar

    You and Bill Nye should work together in some way, shape or form. would be a dream come true.

  8. A A Avatar

    Im 100% sure i will see all your videos asap.

  9. MrSamisack Avatar

    What's up with the frame rate?

  10. Phis Avatar

    You meant Inception.^^

  11. ToutApprendre Avatar

    Hi, this is really nice tutorial !! However I think that something is missing in a formula. Fp = Fg * sin(teta) should be ||Fp|| = ||Fg|| * sin(teta). Am I wrong ? Have a nice day !

  12. Pierre N Avatar

    Hi nice video ! However something is confusing me : We have F = m*A and in this formula F is the resultant force (the combination of every forces at a certain time).
    If Fp = Fg * sin(teta) then Fp = G * mass * sin(teta) then
    mass * A = G * mass * sin(teta)
    so A= G * sin(teta).
    Does that means that Fp is the resultant force of the pendulum ?
    Another thing, Fg is a force, so how can we replace it only with a constant in our case ? How is the "down" direction of the gravity determined here ? Thank you in advance 🙂

  13. galalon2 Avatar

    Hello Dan, I tried to simulate the array of pendulums you showed in the previous videos, but the pendulums never seem to sync after the first period. It seems like the approximation done by the computer is accumulating a huge error over time. I tried to use doubles, but the trigonometric functions and the PVector class seems to work only with float, do you have any idea how to fix this?

  14. Joy Cowper Avatar

    Hi Dan, firstly I've learnt so much from your great videos! Processing tells me "PVector" is an "unexpected identifier" for this code – do you know what could be wrong?

  15. Jai Lopez Avatar

    have you covered how to change datatypes ? im using a function void update(intx, inty); and im trying to use the variables for the pendulum but it is a float type and i dont know how to convert datatypes, and im using serial because arduino is expecting a int type to come via serial

  16. Izzet SAHIN Avatar

    Hey;
    Dan,
    First, I want to say that it is amazing work. You're teaching so much, You are very productive and I can not imagine how much it motivates you.
    As a physicist, I wrote down a different algorithm to define a simple pendulum. a solution of the differential equation of motion for angular form the angle is changing in time with an expression for simple pendulum:

    "angle= angle_max* sin((gravity/armLength)*frameCount)" it can be write as update function.

    and I applied this motion expression in display function of the pendulum object. here

    "location.set(armlength*sin(angle), armlength*cos(angle));
    location.add (origin)"
    And I found very simple code to define a pendulum. con you think about it?

  17. SIMuTech Avatar

    dani i need help finding one of your videos and i just cant seem to come across it! in this video you came up with a formula that reverses the values i believe it was for when a formula define something going forward a opposite formula can let that something reverse back it was something like 10 * -10 i cant even conceive the actual formula but it was not the one i just gave example of because thats -100 and i think there was 3 problems equating to one answer where one was a negative number

Leave a Reply

Your email address will not be published. Required fields are marked *