2.6: Gravitational Attraction - The Nature of Code

Поділитися
Вставка
  • Опубліковано 8 лют 2025

КОМЕНТАРІ • 71

  • @blackpilledbuddha4944
    @blackpilledbuddha4944 5 років тому +72

    there was a period in my life when I was extremely depressed and almost end it, then I discovered coding (it seemed very intimidating almost non achievable that I could learn to code, my personality and perhaps my nature was and is constantly provoking me to give it up), im into my second month of programming , about a week back I came across your channel .... every one of your video that I watch it increments my will to succeed, I sincerely thank you for the knowledge that you have so generously shared with the likes of myself

    • @TheCodingTrain
      @TheCodingTrain  5 років тому +33

      I am sorry to hear about your depression and thrilled to know that my channel might be helping you even if in a small way. You can succeed, you will succeed, I know it!

    • @giv123
      @giv123 5 років тому +2

      @@TheCodingTrain I first came across this programming tutorial on Kahn Academy but you explain the topic extremely intuitively (albeit you are extremely quirky as well!)

    • @lovetant9307
      @lovetant9307 4 роки тому

      Deaf dog what platform is he coding on

    • @artemlyubchenko3022
      @artemlyubchenko3022 4 роки тому

      @@lovetant9307 Processing

  • @NerdMusician
    @NerdMusician 6 років тому +9

    I think that your channel is already the channel that I've spent the most time in my life. I'm learning so much here. Thank you!

  • @neillunavat
    @neillunavat 4 роки тому +4

    For all those who aren't getting an orbital feel of this simulation, he has also applied a constant velocity of (1, 0) to the movers.

  • @ythalorossy
    @ythalorossy 3 роки тому +1

    I guess that I never had the opportunity to see how those kinds of stuff are magical.
    Thank you very much for sharing.

  • @marcotaurino5877
    @marcotaurino5877 7 років тому +2

    Your video it's amazing Daniel!
    You've brought back the passion for physics and spawned a passion for the coding.
    I'm really glad to have bought your books!

  • @staticvoidsolutions4998
    @staticvoidsolutions4998 5 років тому

    Such a great series - your explanations give me the confidence to move forward into more advanced material.

  • @AndrewB_NNA
    @AndrewB_NNA 6 років тому +3

    I've been trying to create a little gravity simulation in Java and was wondering why my orbits had the shape of a spirograph picture instead of being elliptical. Came here and found out I had to normalize the force before applying the gravitational formula...then it took me another half hour to realize WHY it was necessary -.- Thank you so much for your videos.

    • @valshaped
      @valshaped 6 років тому

      Precession of orbit is totally a thing, and would produce spirograph-like patterns
      EDIT: It's called "axial precession", where the axis of orbit precesses around the center

  • @MarkusBurrer
    @MarkusBurrer 8 років тому +17

    I watched the first two chapters and learned more then in one year in school. The for that

  • @25dnorric
    @25dnorric 8 років тому +6

    Thankyou for all your hard work. Really enjoying

  • @WisperedShouts
    @WisperedShouts 8 років тому +31

    Great series so far, but I have to say, when you used constrict it made me feel really uneasy. You could have just increased the gravitational constant, or the masses of the objects. If for some reason that would have caused some strange behavior because of the objects moving too fast, constricting the maximum velocity of the movers would have been a better option, because that at least has an analog in the real world, while forces that stop getting weaker, don't.

    • @justingolden21
      @justingolden21 5 років тому

      Would've also meant that if the object got too far away it wouldn't come back at any reasonable rate, so probably for demonstration purposes. I was also thinking he should just change G, or maaaaaaybe just divide the distance by a constant to make it less influential.

  • @nano7586
    @nano7586 6 років тому +8

    I really hate mechanics if written on a paper, but just seeing results of such equations in a program is stunning. If we could only do these sorts of things in our science studies.

  • @mousey17
    @mousey17 9 років тому +1

    Great videos, Daniel! You are clear, detailed and hilarious, so keep the vids coming!

  • @paulosimoes1891
    @paulosimoes1891 7 років тому

    Dan, these videos are great, they really have helped me a lot.

  • @sweethomes674
    @sweethomes674 Рік тому

    Excellent explanations 😊

  • @Ditmaros1
    @Ditmaros1 4 роки тому

    I love your work, it is very inspiring

  • @17colosal
    @17colosal 6 років тому

    I love how you teach. I really like your videos, but I would like to see more on IOT apps. Thx

  • @AlexCio
    @AlexCio 4 роки тому

    awesome tutorial! 🙂👌🏿

  • @cunningham.s_law
    @cunningham.s_law 8 років тому

    you are one of the good guys thx

  • @PTM1008
    @PTM1008 5 років тому +6

    1:17 -> Dan checking if he's recording. It's just a Dan thing. :P

    • @takiko337
      @takiko337 3 роки тому

      For some reason i laughed so hard thank you

  • @katrix422
    @katrix422 8 років тому

    Although the lesson is very much explanatory, I feel I should learn this section form the book.

  • @RonaldModesitt
    @RonaldModesitt 8 років тому

    Dan,
    I really enjoy the "physics" approach in these videos. Do you have a favorite Physics book, other than NOC?

  • @nagesh007
    @nagesh007 2 роки тому

    Awesome

  • @dinogunjaca4273
    @dinogunjaca4273 3 роки тому

    Daniel: *sees a constant*
    also Daniel: ah yes 1
    every time he sets a constant to 1 i can't stop laughing
    great lessons tho helped me a lot :-)

  • @manhalalqaisy1448
    @manhalalqaisy1448 4 роки тому

    Have you applied Gravity distribution model on python ?

  • @bishan_8617
    @bishan_8617 6 років тому

    When I use attraction I didn't think about it this much ha. I just use - velocity.add( (pos2.x - pos1.x )/dist(pos2.x,pos2.y,pos1.x,pos2.y), (pos2.y - pos1.y )/dist(pos2.x,pos2.y,pos1.x,pos2.y))

  • @andydedu5884
    @andydedu5884 6 років тому

    If attractors attract then do tractors track

  • @AxialPrecessionist
    @AxialPrecessionist 5 років тому

    Is there an email address I could find this speaker at? I have an interesting project and I have a couple of questions. We are writing an academic paper on how the Mayans tracked Venus with their base-260 Tzolk’in calendar.

  • @MrOdammy
    @MrOdammy 8 років тому

    what is the point of normalizing? doesnt it change the magnitude to 1? if so why not just set the mag to 1?

    • @misode
      @misode 8 років тому

      Damilola Olagundoye Setting the magnitude using setMag() actually does the same thing. it normalizes the vector first and then it scales it using mult()

  • @ruonanchang1996
    @ruonanchang1996 7 років тому

    Why are all the links to github not working here?

  • @blinzi69
    @blinzi69 5 років тому

    can you explain how to apply a gravitational vector in a 2D game envionment - im struggling with it :-(

    • @kevnar
      @kevnar 5 років тому

      Check out Keith Peters' Coding Math Channel. He creates an entire physics simulation from the ground up, with explanations every step of the way. Coding Train is more general principles.

    • @flueepwrien6587
      @flueepwrien6587 5 років тому

      How do you apply the force

    • @neillunavat
      @neillunavat 4 роки тому

      It is the same concept bro

  • @oscantes
    @oscantes 6 років тому

    Where is that episode 2.8 ? Is it deleted or never recorded? I can't tell by 2019.

  • @brokenrobotgames2577
    @brokenrobotgames2577 7 років тому

    Universal Gravitational Constant = 6.67408 × 10^-11 m^3 kg^-1 s^-2

  • @swaralipisangeet8398
    @swaralipisangeet8398 6 років тому

    Thanks for physics engine.but can I do it in #c?

  • @yahia1355
    @yahia1355 5 років тому

    Genius!

  • @kevnar
    @kevnar 5 років тому

    "My pancreas attracts every other
    Pancreas in the universe
    With a force proportional
    To the product of their masses
    And inversely proportional
    To the distance between them
    Woo woo woo woo!"
    -Weird Al Yankovic, "Pancreas"

  • @capitalr8018
    @capitalr8018 6 років тому

    I hope to use these lessons learned to create a BeyBlade simulator! :D

  • @nmanca55
    @nmanca55 6 років тому

    I wrote this in Delphi:
    vel.X:= -sqrt(k *d);
    k:= force.Mag();
    force:= ApplyUGF(sun, jupiter)
    function ApplyUFG(S: TBall; var P: TBall): TVector;
    const
    G = 6.67 *10E-11;
    var
    f, d: real;
    begin
    force.Assign(P.loc);
    force.Sub(S.loc);
    d:= force.Mag;
    force.Norm;
    // dim.Z contains the mass
    f:= (G *P.dim.Z *S.dim.Z) /(d *d);
    force.Mult(-f);
    result:= force;
    end;

  • @fatalrapid1160
    @fatalrapid1160 6 років тому

    I was just wondering how to make objects repulse in code instead of attracting.

    • @fatalrapid1160
      @fatalrapid1160 6 років тому

      Great video though!

    • @TheCodingTrain
      @TheCodingTrain  6 років тому

      This video covers repulsion! ua-cam.com/video/OAcXnzRNiCY/v-deo.html (But the short answer is just multiply the attraction force by -1 to reverse direction!)

  • @Phi1618033
    @Phi1618033 5 років тому

    6.67408 × 10^-11 m^3 kg^-1 s^-2

  • @FredoCorleone
    @FredoCorleone 6 років тому

    How do you deal multiple objects? I mean what attracts what?
    The computation with just 100 objects is HUGE!

    • @TheCodingTrain
      @TheCodingTrain  6 років тому +3

      Look for my tutorial on QuadTrees and collisions!

  • @matiaszzz
    @matiaszzz 4 роки тому

    calling Mover -> Particle would be better I think

  • @danae3300
    @danae3300 8 років тому +2

    Excelent, I didn't undestand a sheep from my class. :(

  • @greatgamegal8193
    @greatgamegal8193 6 років тому

    "And I also wouldn't be so lonely" Poor boyo..

  • @Phi1618033
    @Phi1618033 5 років тому

    A Normal Vector is always normalized, but a normalized vector is always a Normal Vector(?)

  • @ramseshendriks2445
    @ramseshendriks2445 6 років тому

    Who made that freaking dislike!!

  • @jjaeei
    @jjaeei 4 роки тому

    !!!! W O w

  • @Bunglay
    @Bunglay 7 років тому +1

    i guess 1 person watched it upside down :/

  • @MrOdammy
    @MrOdammy 8 років тому

    your github does not exist.

  • @yannepomnyashi4566
    @yannepomnyashi4566 7 років тому

    Github not working, we can't find the code. Please, help.

    • @TheCodingTrain
      @TheCodingTrain  7 років тому

      Apologies, see: github.com/shiffman/The-Nature-of-Code-Examples/tree/master/chp02_forces