Planet Simulation In Python - Tutorial

  Рет қаралды 511,850

Tech With Tim

Tech With Tim

Күн бұрын

Пікірлер: 449
@TechWithTim
@TechWithTim 2 жыл бұрын
Hey guys! Glad so many of you are enjoying this topic. Just wanted to note that I made a bunch of small physics/math errors in this video and I am by no means a physicist. Some people have politely pointed out the flaws in the simulation and that it is indeed a very rough approximation. Regardless, I think there is still a ton of value here and you can tweak/fix some parts to make it more accurate 👍
@randomdude7386
@randomdude7386 2 жыл бұрын
I dont think I could spot any major errors on either the maths or physics side in your explanations, but some times I as a physics major felt like you had no idea how to bring it accross as you seemed frightened of the possibility of saying something factually incorrect as the important part in this is, to bring the fundamental concept accross to those who came here not knowing how any of this worked. TLDR: Next time you do something like this, maybe try to be more relaxed and think less about the possibility of details being of in the grand scheme of things, as this has not stopped you from building this audience, as mistakes are human and it matters how we address them
@HypnosisBear
@HypnosisBear 2 жыл бұрын
The thumbnail is click bait.😑 I thought you are gonna make a 3D simulation.
@mr.whiteboard6357
@mr.whiteboard6357 2 жыл бұрын
@@HypnosisBear Yeah me too
@Hiyouri005
@Hiyouri005 2 жыл бұрын
HEY CAN YOU POST CODE TOO//
@rafigasparyan6584
@rafigasparyan6584 2 жыл бұрын
@@Hiyouri005 the code, along with all of the resources he used and credited, are in the description (press SHOW MORE, the button is under the channel name and subscribe line/section).
@lissankoirala
@lissankoirala 2 жыл бұрын
It's not the first time so pretty sure it's not just a coincidence. I was thinking about this project and here you go 3 days later posting the exact thing I want. You really seem to know what your audience needs, thanks Tim!
@harshmirdhwal
@harshmirdhwal 2 жыл бұрын
It's called manifestation bro
@heelercs
@heelercs 2 жыл бұрын
@@harshmirdhwal Lol, sure bro
@ryanchowdhary965
@ryanchowdhary965 2 жыл бұрын
Ai maybe??
@harshmirdhwal
@harshmirdhwal 2 жыл бұрын
@@ryanchowdhary965 force greater than ai
@speedybenzedrex6786
@speedybenzedrex6786 2 жыл бұрын
tim hacked u and used alll your data to create the perfect video for you
@vishsinghania
@vishsinghania 2 жыл бұрын
amazing tutorial 👍 just a correction at 45:00 F = m times a (not m/a)
@joseph2073
@joseph2073 2 жыл бұрын
@Harsh 🤣
@hxdx6950
@hxdx6950 2 жыл бұрын
or F = Mg
@gillesphilippedeboissay109
@gillesphilippedeboissay109 2 жыл бұрын
@@hxdx6950 no it's true en Earth only sometimes
@Mickymauserius
@Mickymauserius Жыл бұрын
But why does "self.x_vel += total_fx / self.mass * self.TIMESTEP" work. Shouldnt it be "self.x_vel += self.mass / total_fx * self.TIMESTEP"?
@rohan9739
@rohan9739 Жыл бұрын
@@Mickymauserius The formula is F = m * a, so a = F / m ; therefore self.x_vel += total_fx / self.mass * self.TIMESTEP works
@matheotrouille9085
@matheotrouille9085 2 жыл бұрын
Physics modeling is so interesting, look forward to see more like this !
@DevilisshDan
@DevilisshDan 2 жыл бұрын
I think it's important to mention that what you're doing is just an approximate solution. When using the acceleration from the force and multiplying it with the timestep, you're taking a shortcut and calculating the average speed over a timestep. Since it's a many body problem, you can't get an "exact" solution.
@arkie87
@arkie87 2 жыл бұрын
yeah, it is also not energy conserving, as demonstrated when running without a vertical velocity component-- the planets just approached the sun and launched off to infinity.
@felicytatomaszewska
@felicytatomaszewska 2 жыл бұрын
We really look forward to your "exact solution"
@exar6765
@exar6765 2 жыл бұрын
@@felicytatomaszewska He literally said : "You CAN'T get an exact solution". He's not saying it's a bad simulation, just an approximation
@mastershooter64
@mastershooter64 2 жыл бұрын
@@felicytatomaszewska I think you can mathematically prove that it's impossible to get an analytic solution for a n-body problem
@aurelia8028
@aurelia8028 2 жыл бұрын
There's literally no other way to do it. I don't get what you mean by "shortcut". This method is forward euler integration, but yes there are more complex integration schemes like runge-kutta or verlet integration, but I don't think he knows anything about that
@hyphenbruh7376
@hyphenbruh7376 2 жыл бұрын
That was awesome! I love and appreciate how you explained the logic behind each line of code and the concepts behind the physics of the orbits :D
@renegadezed
@renegadezed 2 жыл бұрын
f = ma .. NOT f = m/a .. force equals mass multiplied by acceleration
@TechWithTim
@TechWithTim 2 жыл бұрын
Great catch! Big brain fart from me
@renegadezed
@renegadezed 2 жыл бұрын
@@TechWithTim no big deal! you still promote Kyte? that auto complete coding help thing?
@Mohd_Zaid_khan
@Mohd_Zaid_khan 2 жыл бұрын
Funny thing is f ≠ ma, rather it's always dp/dt where p is linear momentum. for mass rate = 0, you can say net force along a line = mass multiplied by acceleration along that line
@jackyisking
@jackyisking Жыл бұрын
But is gravity a force at all?
@youber3200
@youber3200 Жыл бұрын
​@jackyisking gravity is a field and gravitational force is a force :>
@NishantCosmos
@NishantCosmos 2 жыл бұрын
there's a great guy, explains the science behind planets in simplest way, claims we're confused like NO PROBLEM.
@kevinbacon8716
@kevinbacon8716 2 жыл бұрын
You’re about to hit a million subs. Congrats man. Your videos are great and as someone that’s new to python
@xdaniels13
@xdaniels13 2 жыл бұрын
Awesome project Tim. I love physics and astronomy this is the perfect project to increase my skills in python :)
@_xiliam_7708
@_xiliam_7708 11 ай бұрын
If u love physics how u didn't notice f= m/a? I don't even mean that his planets make rotation around the sun in 1 sec while timestep is only 1 day?
@Heisenberg_99101
@Heisenberg_99101 2 жыл бұрын
This is just pure level genius, great help for a python project. Loving it 🙌
@annajuliagiza5916
@annajuliagiza5916 Жыл бұрын
Thank you for the wonderful tutorial. You do an excellent job of showing and explaining each of the steps, what you're using in Python, and what each part of the program does. I just completed the CS50 Intro to Python course and was looking for a project to practice the skills taught. I have an avid interest in space so coming across this tutorial was excellent.
@_xiliam_7708
@_xiliam_7708 11 ай бұрын
He did mistakes, but the idea and basic explanation is very good for the project
@emirhanu8655
@emirhanu8655 2 жыл бұрын
You are awesome, bro. Every time producing different ideas.. Keep going Tim
@amaarquadri
@amaarquadri 2 жыл бұрын
Nice tutorial! The x and y variables are shadowing each other at you suspected at the end. The reason that it doesn't break the program is because x and y ended up being the last values in the orbit array, which happens to be the same.
@fun-damentals6354
@fun-damentals6354 Жыл бұрын
this was a really informational video. to all new programmers, let me teach a way to partially escape tutorial hell. if you want to learn a language, but dont wanna worry about the logistics of a project, follow along with a tutorial in another language. i am learning c++, and it is about as far from python as it gets, and it helped me learn the language while still following along with the video
@PayneMaximus
@PayneMaximus Жыл бұрын
A more realistic simulation would be somewhat more complex than what you've done, since it would depend on the relative positions of each body and their velocities in a single instant, so you can use it as a starting point for the calculations. Still, good job! 😊
@Greatbob-qu2ip
@Greatbob-qu2ip Жыл бұрын
Coming from a physicist your explanation is by no means perfect but it's good enough for what you want to accomplish and that's more than enough keep up the good work
@phase0400
@phase0400 2 жыл бұрын
I would really enjoy seeing a 3D version of this. Nice video.
@NickHanson
@NickHanson 11 ай бұрын
This was a great introduction to the pygame library with a helpful foray into authentic simulation. Thank you for putting this together!
@flashypepo
@flashypepo 9 ай бұрын
Thanks, Tim. It is a very nice tutorial and introduction to astronomy, physics and Python, despite some minor flaws. I've made it, add the name of planet/sun to it and re-factored it in classes PlanetSimulation and Planet (which goes beyond your tutorial). It gave me a nice step up to go further in astronomy and astrophysics (when I was as young as you, I studied astronomy, years ago). kind regards, Peter.
@universodacomputacao
@universodacomputacao Жыл бұрын
This is so awesome that made me understand more about Space Engine, the best Universe Simulator that I've ever seen. Thank you so much
@philosopherPsy
@philosopherPsy Жыл бұрын
While watching your lecture, I immediately entered the code and tried it out on my computer. It is perfect and beautiful. You have been a great inspiration to me. I will also try Earth's satellite, the Moon, the asteroid belt and other large outer planets. It was a really fun weekend. Thank you!!!!
@danadasachan7208
@danadasachan7208 Жыл бұрын
Thank Tim. I really enjoyed this project. I remember studying these planetary equations when I was in my undergraduate mechanical engineering program back in 1985 and I remember coding the orbit of a planet in Turbo Pascal. Crazy.
@lissankoirala
@lissankoirala 2 жыл бұрын
45:00 - you made an error here, F = m / a [supposed to be F = m*a]
@Stl71
@Stl71 2 жыл бұрын
No surprise you have so many subscribers. Lots of interesting stuff in that channel, although I am not a python guy.
@danielkursitis9031
@danielkursitis9031 2 жыл бұрын
Really enjoy this type of content, keep it up
@bobmorone461
@bobmorone461 Жыл бұрын
Five Star! Excellent. Thank you for providing detailed explanations as you are introducing the code. Simulations like this offer a good way to learn and provide a platform upon which to build more interesting simulations.
@marcrindermann9482
@marcrindermann9482 2 жыл бұрын
when you want to express 1 AU in metres, just increase the exponent by 3: 1 AU = 149.6e9 metres; rather than 149.6e6 km × 1000 m/km
@nadeeshani
@nadeeshani Жыл бұрын
You are amazing, Tim! Thank you so much for this project and for the way you explained it.
@quyennguyen6725
@quyennguyen6725 2 жыл бұрын
Honestly, I love videos like this. this is a 2d model, can you upgrade it to a 3d model. I look forward to it. Thank you for your contribution to the community.
@domingezu4687
@domingezu4687 2 жыл бұрын
Very nice video TIM!
@googldeed
@googldeed 2 жыл бұрын
I can finally get into data simulation now that you made the perfect introduction for me.
@devbites77
@devbites77 2 жыл бұрын
Great! A fascinating simulation. I would love to see some more physics simulations using forces.
@GregoryCarnegie
@GregoryCarnegie 2 жыл бұрын
I played around with this and realised a slight simplification you can make. Since all objects feel the same acceleration regardless of their mass, you can write this script in terms of acceleration rather than force. e.g. velocity self.x_vel += total_ax * self.TIME_STEP
@aurelia8028
@aurelia8028 2 жыл бұрын
Yup using force is a rather "naive" way of doing it. division is also expensive for computers, so by calculating the acceleration directly, you can save the computer from doing quite a lot of unecessary work.
@timbeard8457
@timbeard8457 2 жыл бұрын
Super project! Have just bookmarked it for reference. Excellent that you included the interplanetary gravity too (from a coding and physics perspective). I agree that it was probably best not to use the general relativity description of gravity. The maths would have been hell! Newtonian physics was also good enough to get to the moon (I think) Questions: - Is there a way to only refresh / move just the changed items and not redraw everything? If there were lots of static objects, wouldn't that have a big performance impact? It would also mean that the complete history of the orbits wouldn't need redrawing each time, just the last point. - How would you approach having multiple sections in the app? Example: the canvas WIN on the left and some kind of control panel on the right for user input, plus a title / description area above both. - Would it be possible with pygame to dynamically change the window size, e.g. by the user grabbing the corner of the window? Please point me to any other videos or projects on GitHub you've done that address any of the points above.
@Burdiga_memes
@Burdiga_memes 2 жыл бұрын
I really enjoyed the tutorial I am 12 years coder and I understood very thing eaisly thanks to you
@AstroBene
@AstroBene 2 жыл бұрын
*sees the title, screams:* HELL YESS! Thanks!
@Sk8erMorris
@Sk8erMorris 2 жыл бұрын
ok this is sick, thanks for this one !
@wowgodz-5349
@wowgodz-5349 2 жыл бұрын
ngl i've been waiting for this
@si8915
@si8915 2 жыл бұрын
some day, tim will do "Filosophically Functional Life Forms In Python - Tutorial"
@shubhaggarwall
@shubhaggarwall 2 жыл бұрын
well the thumbnail helped me revising the force formula thanksss
@toul100
@toul100 2 жыл бұрын
YOUR OPINION IS VALUED I LOVE THIS
@Ansh-Adonis
@Ansh-Adonis 11 ай бұрын
ill take this a step and a half further, thank you!
@LeonardRibeiro25
@LeonardRibeiro25 2 ай бұрын
Appreciate this being available !
@malibaturhan
@malibaturhan Жыл бұрын
it was really satisfying even by copying you step by step, thank you
@lupamo_Arnold
@lupamo_Arnold 2 жыл бұрын
Loved this project. Thanks Tim
@ddavid1414
@ddavid1414 2 жыл бұрын
fortunately i knew the math before hand otherwise this would be a lot harder ;D greate video
@vfx7t
@vfx7t 2 жыл бұрын
Good job ! And thanks from Algeria !
@jacobjohnson7125
@jacobjohnson7125 5 ай бұрын
Thanks so much. I followed your tutorial and finally got it working. Funny thing was that I had the most minor errors in my copy (I was typing it in as I watched the video) and didn't get it fully working until the end and after I downloaded from the github then did a diff between that and what I'd typed. That was so weird that you could put in a y velocity only and then the update_position method would have the rest fall into place such that it maintained orbit.
@leonellg3167
@leonellg3167 9 ай бұрын
The way the logic of the orbits is implemented means the orbit (and updated_points) lists will keep growing without end if the simulation is kept running. A slight modification to add a max number of points, and then an if statement to remove older points once the list has reached this max number would mean the simulation can run forever without issues.
@yudianimations
@yudianimations 2 жыл бұрын
great tutorial! thanks tim :D this also made me understand classes and stuff
@efschannel3043
@efschannel3043 2 жыл бұрын
Omg I was thinking about this for a long time
@absar_ahmad
@absar_ahmad 2 жыл бұрын
This man have magical powers to know what we are thinking, believe me.
@bvg129
@bvg129 2 жыл бұрын
You can use strings for common colors in pygame now. Since 2.0
@NeonsStyleHD
@NeonsStyleHD 3 ай бұрын
Excellent video, I learned a lot. Subbed.
@趙重茂趙重茂
@趙重茂趙重茂 2 жыл бұрын
amazing, you're really a genius
@reubenthomas1033
@reubenthomas1033 2 жыл бұрын
Awesome! Please do more of these!
@J_GB
@J_GB 2 жыл бұрын
this was awesome! very cool idea for a simulation
@tobik2047
@tobik2047 Жыл бұрын
hi, in min 6:15, why didnt you just do a while True-loop and if the user wanted to quit you just return or break out of the main-function/while-loop? just want to know why since im pretty new to python
@professor_ozzy
@professor_ozzy 2 жыл бұрын
Ty for the hard work. I learned a lot from this tutorial! :D
@jessysavard2133
@jessysavard2133 2 жыл бұрын
your vid help me a lot no matter if some shit false, that give us something to fix and keep going lil watch and like every vid !
@gidartsproduction5439
@gidartsproduction5439 2 жыл бұрын
Wow, high quality information...
@TAP7a
@TAP7a 2 жыл бұрын
Skip involving trigonometry, do it all component by component! Force_x = (other.x - self.x) * Planet.G * self.mass * other.mass / distance ** 3 Force_y = (other.y - self.y) * Planet.G * self.mass * other.mass / distance ** 3 No need for expensive atan calcs, just needs another 2 factors to multiply! Also would recommend either Verlet or RK-4 integration schemes rather than Euler ;)
@lp2045
@lp2045 2 жыл бұрын
Now let's see uranus' simulation lol Great vid btw
@martin-xq7te
@martin-xq7te 2 жыл бұрын
Great tutorial Tim. Thankyou
@ykslooper
@ykslooper 2 жыл бұрын
i love you so much tim your videos are amazing. I hope you clsoe time you will 1 millon subs
@feelsadgeman
@feelsadgeman 2 жыл бұрын
I had the same idea, i was going to make this on my final project
@MilkenGamer42
@MilkenGamer42 2 жыл бұрын
This was a really fun tutorial to follow! I just started to learn Python and I found this video very informative. My problem with my code is that even though I was following this video, for some reason no matter what resolution I set the window, it would only do full screen and now windowed, so I'd have to hit window then X to close the program. You did an excellent job explaining how everything worked 😊
@itz_ronatime7527
@itz_ronatime7527 2 жыл бұрын
did u find a fix? my python doesnt run in windowed mode and its annoying..
@ddavid1414
@ddavid1414 2 жыл бұрын
love you'r videos :D they are great I learn so much
@novidtoshow
@novidtoshow 8 ай бұрын
Just a little nit: the gravitational force weakens as the inverse square of the distance. It doesn't weaken "exponentially". The word, "exponentially", has a very specific mathematical meaning. You're gonna want to have that meaning available to you one day when you really need it.
@Felix-wo7qz
@Felix-wo7qz 2 жыл бұрын
cool tutorial, has been fun to program it!
@ayushmaanyadav4069
@ayushmaanyadav4069 2 жыл бұрын
I have my exams rn, i am gonna make this some day, probably gonna add a feature to see the simulation of objects around the planet, and also a feature to add an object in this system, like any object of a given mass, moving with a particular velocity in some direction. Gonna be difficult but can be done
@ConsultingjoeOnline
@ConsultingjoeOnline 2 жыл бұрын
Amazing video. Freaking sweet!
@frankhaug1517
@frankhaug1517 2 жыл бұрын
15 minutes in. great video so far, i just hit all the buttons. however, you can do AU = 149.6e9 instead, same effect. edit: and since you mentioned consistency: 1*10**X = 1eX
@trevorelvis1355
@trevorelvis1355 2 жыл бұрын
MY HEART LITERALLY SKIPPED A BEAT WHEN I SAW THIS VIDEO. I WAS SOOOOOOO EXCITED. KEEP 'EM COMING
@muhammadmz8791
@muhammadmz8791 2 жыл бұрын
thank you tim 🙏
@raymondmichael4987
@raymondmichael4987 2 жыл бұрын
Thanks for this Tim, consider a 3D version of this too. Also as someone mentioned, relax you’re doing such a wonderful and we appreciate it Greetings from Tanzania 🇹🇿
@tusharpatel2003
@tusharpatel2003 2 жыл бұрын
It's amazing 😀🤩 bro Thank you for this ❤️
@paaritoshjain
@paaritoshjain 2 жыл бұрын
please do a rocket simulation too!!!
@Andbovi
@Andbovi Жыл бұрын
I understood the force vector better in this video than in physics class... Although who knows, maybe I'm just smarter now and more interested in more things.
@satyadev2011
@satyadev2011 Жыл бұрын
Great tut man.
@risveyhasan8931
@risveyhasan8931 2 жыл бұрын
Great work man.
@chrisdanny5180
@chrisdanny5180 2 жыл бұрын
This is a brilliant idea
@hovardlee
@hovardlee 2 жыл бұрын
Nice really :) My comments: 1. Formula should be F = m * a not F = m / a 2. There was a nice place for a list comprehension with updated_points 3. When you adding a point to self.orbit isn't it growing infinitely? If you run it for a couple of seconds it should be fine. But if you run it for a couple of hours wouldn't it slow down ?
@fjoralbismolli3490
@fjoralbismolli3490 2 жыл бұрын
I guess one possible solution to your third comment would be to round the points you append to self.orbit, and do not append if the pair is in the list. However, checking existence in a list is O(n), so you would better use a set. Beware, set() is not ordered, so you might want to use an ordered set instead.
@Birsic98
@Birsic98 2 жыл бұрын
@@fjoralbismolli3490 Smooth
@GordonFreeman69
@GordonFreeman69 Жыл бұрын
Thanks for the tutorial.
@ANNGUYEN-cw7lw
@ANNGUYEN-cw7lw Жыл бұрын
Your tutorial is very awesome. I hope you will create many other tutorial in the future ?.
@TechWithTim
@TechWithTim Жыл бұрын
That's the plan!
@DSCuber-28-01-2019
@DSCuber-28-01-2019 2 жыл бұрын
Hey Tim, how can we add the Moon to this simulation, can we do the exact same thing we did to the planets but centering from not the sun but earth?
@Djellowman
@Djellowman 2 жыл бұрын
Yes, but it will be so close to the earth that you can't display it at this scale
@DSCuber-28-01-2019
@DSCuber-28-01-2019 2 жыл бұрын
@@Djellowman i tried to do it using real values but it just went through a straight line and out of the screen
@dirtboi8792
@dirtboi8792 2 жыл бұрын
@@DSCuber-28-01-2019 Same :( if you figure it up tell me
@lamedev1342
@lamedev1342 2 жыл бұрын
@@DSCuber-28-01-2019 ya same
@xyy2861
@xyy2861 2 жыл бұрын
I also added the moon but it was immediately catched by the sun and kicked out of the system. What's wrong here?
@tiagosolano9728
@tiagosolano9728 Жыл бұрын
Maybe someone already pointed this out, but the distance from the center of mass of the earth to astronauts in orbit IS NOT the reason why they do not experience the force of gravity. The reason is that they are on orbit around the earth, which is equivalent to being on free fall. Earth's gravitational field goes way beyond low earth orbit, as you can reason from the fact that the moon is in orbit around the earth at a far greater distance.
@carldavidson-desbiens138
@carldavidson-desbiens138 2 жыл бұрын
Hey, nice examples. try this. Make a ball of 24000 miles. Make water stick to it. To validate your code, use earth code calculator. At what distance should we stop beeing able to be able to see statue of liberty and replicate in your model. This will be the most challenging coding session you will ever create. Have fun.
@manisho7695
@manisho7695 2 жыл бұрын
Tim is the best tutor out there for teaching coding
@dimahome544
@dimahome544 Жыл бұрын
1. The problem is in the code - infinite growth of points in the "orbit" array 2. The initial distances of the planets must be taken from the apogee, and not the average. And accordingly, take the lowest initial speed (at apogee). Then you will get the correct ellipses. 3. Due to the quantum nature of calculations over time, an error accumulates in the momentum of the system of objects. The closer the objects are, the greater the error. It is necessary to check each step so that the total momentum of the two interacting bodies does not change after changing speeds.
@dymonn
@dymonn 2 жыл бұрын
bro u a alien, damnn👽
@bidam224
@bidam224 Жыл бұрын
hey man I just realized that at 29:36 , you are using MS Whiteboard in Turkish. Are you trying to learn Turkish or maybe one of your parents moved to different country from Turkey?
@josephrios4437
@josephrios4437 2 жыл бұрын
awesome tutorial 👍
@gerrymarshall4784
@gerrymarshall4784 2 жыл бұрын
the Sun also orbits the centre of mass of the solar system. A point known as a barycenter (there is one between any masses Earth-Moon). Whilst this may not seem significant I understand that this centre of mass can be up to 2MKm from the centre of the Sun. If the velocity of the sun is unknown I suppose you could start at zero.
@natyacodes
@natyacodes 2 жыл бұрын
guy teaches almost a million programmers, but doesn't know the difference between star and planet 😂😂 Nice Video! learned a lot of stuff
@playerscience
@playerscience 2 жыл бұрын
That's because he is not a nerd LoL.
@mohammadshahbaz296
@mohammadshahbaz296 2 жыл бұрын
Hello Tim, in your video you said that we could look at the math to understand why you chose the scale the way you did. However, the turtle code you took inspiration from did not explain this either. Could you please explain why 250/ AU maps to 100 pixels?
@alperkama6798
@alperkama6798 2 жыл бұрын
I think there is a mis explanation there. It should be 1 AU = 250px
@boseongcho62
@boseongcho62 2 жыл бұрын
I think so with alper kama
@The007038
@The007038 2 жыл бұрын
Resolving the attraction force into x and y components can more simply be done by using similar triangles (also doesn't require calls to the math library so I believe it wod be faster also) For 2 similar triangles with sides Fx, Fy, F and Distx, Disty and Dist have consistent ratios between similar side lengths You can say Fx / F = Distx / Dist As such Fx = Distx * F / Dist Simarly Fy = Disty * F / Dist A little neater and a little faster but equally as accurate :)
@ImNotActuallyChristian
@ImNotActuallyChristian 2 жыл бұрын
while simpler, i wonder if it actually is faster. Calculations done in python can be 100s of times slower than the C based libraries. I'll try go and do some benchmarks.
@The007038
@The007038 2 жыл бұрын
@@ImNotActuallyChristian I'm very interested to see how this turns out! I simply assumed since the implementation of sine requires some amount logic for bounds checking and range reduction as well as then generally computing a Taylor series and some correction. (as far as I understand from the c standard library as cpython simply implements many c math) Meanwhile the similar triangles method is 2 basic math operations.
@The007038
@The007038 2 жыл бұрын
@@ImNotActuallyChristian Hey mate. I was so curious I ran some tests myself. I ran both methods on 100,000 random sets of numbers Using the trig method took between 5.83 and 6.05s (depending on the run) While the triangle method took between 4.92 and 5.18s So the trig method is roughly 20% slower than the triangle method. The more you know!
@tiagosolano9728
@tiagosolano9728 Жыл бұрын
Alternatively you don't need to compute the square root of the distance, since what you really need to compute the force is the distance squared.
@lucidjuice101
@lucidjuice101 Жыл бұрын
The reason why the value of y_vel of venus is negative is because of the fact that venus' orbit is titled to 180 degrees. So unlike all other planets, it orbits clockwise around the sun.
@PDsChannel0112
@PDsChannel0112 Жыл бұрын
The planets are not orbiting but after taking a little curve they just start moving straight what should I do?
@PDsChannel0112
@PDsChannel0112 Жыл бұрын
I checked the code from your code on github but after fixing some mistakes it was still not working what should I do?
How to use the Obsidian Dataview plugin
16:11
Nicole van der Hoeven
Рет қаралды 225 М.
"يعني إيه GitHub وإزاي يسهل حياتك كمبرمج؟"
10:58
اتعلم ببساطة
Рет қаралды 108 М.
Thank you mommy 😊💝 #shorts
0:24
5-Minute Crafts HOUSE
Рет қаралды 33 МЛН
Counter-Strike 2 - Новый кс. Cтарый я
13:10
Marmok
Рет қаралды 2,8 МЛН
Mastering Python - Everything You Need To Know To Become a Python Master
16:02
Coding Adventure: Simulating Fluids
47:52
Sebastian Lague
Рет қаралды 2 МЛН
The Genius Way Computers Multiply Big Numbers
22:04
PurpleMind
Рет қаралды 232 М.
Python Simulation Tutorial - Conway's Game of Life
41:13
Tech With Tim
Рет қаралды 37 М.
I Scraped the Entire Steam Catalog, Here’s the Data
11:29
Newbie Indie Game Dev
Рет қаралды 802 М.
Coding Adventure: Solar System
12:12
Sebastian Lague
Рет қаралды 874 М.
C++ vs Rust: which is faster?
21:15
fasterthanlime
Рет қаралды 410 М.
Teaching myself C so I can build a particle simulation
11:52
Gradience
Рет қаралды 333 М.
Thank you mommy 😊💝 #shorts
0:24
5-Minute Crafts HOUSE
Рет қаралды 33 МЛН