When you try to make a collision handling system, but just end up making a system that has no collisions at all... Technically, you've solved the problem.
@@kaidatong1704 The n in O(n) is a variable that means the number of items to be handled. If n is constant then it's not O(n) time, it's O(1) (constant time) because the time to run doesn't depend on the number of items. You don't set constant values for n. O(0) is just a joke, since in a collision-free system you wouldn't even implement the function and thus is it would never actually take any time at all.
Holy crap The precision in which these weren't coliding is insanely satisfying Hope you saved a version of your code with the "bug" and called it "art mode"
@@sirpsionics no they were not, it was just so close you would have to zoom a lot to see they actually don't touch. Cuz if they did it wouldn't be this smooth
@@alexstasko696 I also think they become red upon touch. But I think he's right, sometimes they touch ever so slightly but the hitbox is too imprecise, that's my guess anyway.
Especially at 2:27, seems like all their gravitational pulls have synchronised somehow. Search up Dyson Swarms, It's an idea where there are many orbiting solar panels around a star, which could provide enough energy for a type 1+ civilization (more advanced than our own). This technique could solve the problem of collisions between these panels. Sounds a bit crazy perhaps, but I think this technique could be very useful when implemented properly.
@@marzipug5439 Okay, but hear me out. The way this works is they keep crashing into each other until their orbits stabilize. I don't think that's viable to do with solar panels.
@@Shmill That's where this piece of software comes in handy to precalculate! 😁 Theoretically. Guess you'd prefer a bit of space between fast moving chunks of metal that won't keep their precise orbit in reality. 🤔
i can imagine that if someone wanted to create a system where given any radii and position parameters had the task to find a stable orbit relationship without any collisions, it would be really difficult without the use of a neural network (and probably still really tough), but the fact you got this behavior via a bug is just hilarious. and the concept has a lot of potential as a game too. with planets… or somethin haha
Well in this case there’s no gravitational interaction between the bodies, they just have a single attraction point that stay stable in position and magnitude over time
I'd love to see an in-depth video explaining the mechanics behind this behaviour. As collision avoidance has such wide reaching & valuable applications it seems almost certain that this has already been discovered & no doubt named.
They push each other with constant force until they stop colliding, which requires producing energy out of nowhere. He just messed up conservation of momentum in his calculations.
It's a sort of accidental evolutionary process, the orbits that don't have collisions survive while those that do get mutated into a different orbit where they get tested again. Very good example of emergence.
This feels like those videos of a city traffic stop that's full of pedestrians, bikers, and cars all moving right past one another, just barely skimming without any accidents
@@TH3RM4L You seem to have missed completely the quote by Isaac Asimov "The most exciting phrase to hear in science, the one that heralds new discoveries, is not 'Eureka!' but 'That's funny...'" The value isn't necessarily monetary, the value might be progress of humankind.
@@ehsnils idk why you talking about asimov, but when Ive looked at other comments, they talk about wanting to pay for this as a feature in some program. Ie, capitilaism has invaded even eureka moments like this
Also... Hmmmm... Yea I guess it is a bug... But you only forgot to add a slight friction, or loss of energy transferred on collision, haven't you? So colliding items will always end up using another trajectory until they don't collide anymore. It's a universe without energy loss to friction/deformation.
This is incredible! I can imagine somewhere someone wanted to intentionally set out to make something that looked like this, but the animation required to hand create something like this would take a quite a while! So cool to see something this beautiful come from coding.
He just forgot to add code to update the speed so the object move with 0 energy loss and eventually bounce off each other in a way that causes no new collisions quite simple and im sure most people that were trying to make a collision system have found a movement bug related to this exact bug, hes just probably the first to do it like this
@@nothingnothing1799 I think there must be a second error made as well. All of these take the same amount of time to complete their orbit, no matter how big their orbit is.
@@ekkehard8 I think that all the balls start moving at the same speed, and typically when they collide you would calculate the amount to slow them down by the balls mass (or aproximate it using their size) to have energy conservation.
@@ekkehard8 Not a physics error though, a test quirk. There is an inward force as part of the test, and it looks to be linear with respect to distance and mass, turning them into simple harmonic oscillators. This is the same physics that is used for almost all clocks. If anything it speaks to the accuracy of the physics code that an oscillator works accurately enough for this to be stable!
So I read the code, and I would summarize it like this: basically he didn't implement velocity update when collision happens. When collision is detected (with simple radius check), he just nudged both of the spheres back away from each other just enough that they touch. The end effect is that they slide off of each other, continuing on their original path. So its like inelastic collision with no friction? Anyway it's these unique ingredients that drive the system to a stable state with no collision. Very cool!
Thank you so much for an actual explanation from reading the code. There are so many comment trains here with wild speculations that I can't parse enough to figure out if they are valid or not. I was thinking I would have to grab the code myself and see, but you beat me too it.
Thats what I was thinking was going on, they are kind of acting like billiard-balls, where in reality some of the energy would dissipate as heat, here it simply perfectly transfers to the colliding objects.
@@xdlmaoooo No they aren't transferring energy to each other, that's the problem. They're ignoring each other's velocities, only slightly nudging each other enough to slide past without overlap.
is this right: the two colliding circles change each other's *positions* without changing either one's speed/direction/mass/etc? What happens in a near head on collision?
If I understand the code, each ball is attracted by the center through an elastic force, while collisions directly displace pairs of overlapping particles away from each other in such a way that they end up barely touching, without modifying either of the registered speed values. Each ball has the same mass, so the period of each orbit is essentially the same, as a result the whole dance will stay in sync once the particles trajectories have been tuned to avoid overlapping. As far as I can tell, the speed itself is never updated by anything but the force, only the time-step size changes, that part is confusing but I guess that the simulation slows down when particles collide. However that would result in infinite acceleration toward the center would the particles jam upon each other so I may have missed something.
I don’t think the simulation slows down when the particles collide. To me, it looks like the particles temporarily slow down while they are pushing each other, and once they are free, they go back to their old speed
My guess is that there's no velocity loss with any of the balls after they collide. So the balls fall to the centre and orbit around it and the collisions between each other are correcting their path until eventually, over time the balls develop paths that don't collide with any other ball or barely slide past one another. Cool bug.
@@LiraScarlet Like I said fully elastic collisions alone (which fully conserve energy) isn't enough to produce this system state - the balls would just keep bouncing randomly forever. And neither are elastic collisions that generate energy, that just increases"orbital eccentricity" with every bounce thus reducing density and by extension the odds of collision, but doesn't moves anything into specifically collisionless trajectory. I invite you to attempt to replicate such result in a properly written physics simulation engine using any parameters you want - this scenario won't happen, other forces than restitution adjusted impact normal are required to achieve this effect.
@@michaelbuckers I think I have a simple counter-argument for your claim here: The balls basically try out different trajectories. If the ball does not have a free trajectory, it will collide. This will change the trajectory, and the ball will try a slightly altered one. This process will continue until all balls have free trajectories. After that we will see the behavior demonstrated in the video. I can not see how the system would converge to a "random bouncing state" you are suggesting there. (Or at least that is higly improbable with randomish start state.) The free trajectory state is the only one that does not change itself, so I am pretty sure the system will converge to that one. Also, I challenge you to produce this random bouncing state you claim will occur.
@@IlariVallivaara You're talking out of your ass. It doesn't even looks like you ever seen the elastic collision equation in your life. Go take a look at it and point out literally anything about it that suggests that any system of moving bodies will converge to a collisionless state, you massive dunce. Your challenge has been already complete: molecules of air never stop bouncing, objects in the solar system never stop colliding.
I might be wrong but I think the reason this happens is that there's no loss of momentum when they collide just a change of the direction of momentum, so what happens is that they push each other out of the way but continue to move at the same speed, just in a different direction, which eventually causes the system to become stable.
came to the same conclusion, no velocity is lost. However, collisions don't change their direction, instead they just nudge eachother while keeping their original direction. The other essential condition is that their size don't impact their speed, so once two balls have moved out of each other's respective paths, they'll never collide again unless they're moved by other balls.
This simple principle has wider applications..... In cases bound by Newtonian physics, should you inject enough energy into a media to overcome friction, but not entropy, it will eventually systematize so as to obey physics in the most efficient manner, causing the media to be more orderly. An example would be the "Frito's Bag" which claims that the chips in the bag may have settled in shipping, causing the air gap in the bag. The result is that the chips are stacked more orderly in the bottom of the bag than they were originally filled at the factory. Call it the "Lays Bag Theorem" ; P. This can be useful in manufacturing, medicine, and .... I just realized that's the principle behind the electrotreatment my GF receives for her nerve damage. I mean, I should probably finish my degree so I can learn exactly what this is called because I doubt this is original.
I'm shocked. A few months back I decided to try to implement a collision system myself for fun, although the particles would look ahead, and if it saw the trails of any previous particles it would turn in a direction away from it. I randomly picked different wells of different strengths around the plane for the particles to have something to keep them from just bouncing against the walls, and the end result was basically this similar group weaving and bobbing, but the groups would collectively migrate to different parts of the screen. It wasn't what I was going for, but since I had written it where it could handle 10M particles, I loved what I ended up with that I never even considered "fixing it".
These happy accidents are my favourite thing in programming, you can get endless hours of fun just by playing around and exploring its details. It's like going on an unexpected adventure
@@DavidFong21 Their name is whispered is the hall of legends ;) But for real, Sebastian probably makes my favourite content on YT, mind-blowing every time!
@@ZLP-TM it may appear that they are touching because of the technical limitations of your display but if the calculations are correct, there should always be some space between the circles.
@@creampielover69 They definitelly touch and slow down, watch closely. Thats mostlikely because he didnt run his program for long enough, it takes time for them to settle in
You will see your share of weird shit, trust me. My funniest was a 200ish line function that I wrote while rather absent minded. I ran it, it worked perfectly. After running it for a really really long time it returned an answer that was obviously wrong. I thought the bug cant be that complicated as it otherwise did exactly what was expected. Looking at it I found many totally obviously wrong conditionals. Swapped AND's and OR's, < in stead of >, lookups in the wrong spot of an array. All easy to fix but in stead I sat there for some 30 min wondering how it ever produced a correct result. There was some mad unexpected recursion going on where n wrongs made a right. I couldn't figure it out. Probably the most complicated code I ever read. (I use to write machine code) It was all so obviously wrong my theory is that some higher entity took over my hand and made a joke.
This is amazing. It's almost like there is some "self-optimization" that is occurring. The first time they come into contact, they slide past each other and then orient themselves in such a way that they don't ever touch when they come back around. Pretty cool.
Well not the first time, in the big one it took like half an hour to happen. I suspect he forgot to implement some kind of friction to make things actually eventually stop, and then the can just keep bouncing until they reach some stable configuration where they slide just past each other
@@emptyptr9401 The wikipedia article "Gravitational Energy" shows the basics of the -1/R potential very compactly. Its consequences are explained in the article "Orbit" and probably in any youtube video about orbits. The r^2 potential on the other hand is known under the name "harmonic oscillator" and can be found everywhere in physics
I legitimately spent hours trying to find this video the other day, I thought the effect was so cool but I had absolutely no idea what it was called. Eventually gave up. Now here it is in my recommendations. The world is weird.
This would be the dopest looking main menu wallpaper of a futuristic space sci-fi game where traffic/travel is a thing, like in GTA or cyberpunk. You would see hundreds of spacecrafts just perfectly travelling through this portal intersection etc. (the tightest turn being the portal)
This is cool! I saw your initial upload two weeks ago. I downloaded your code and tried to understand what makes this effect emerge. There is a comment under your previous video explaining that this effect happened because you updated only the positions and not the velocities of the colliding sphere. This is true and I think it is indeed part of why the system is not chaotic (in the mathematical sense: small errors on the initial velocities are not amplified by the collision since you do not update them). I would like to add that there is something else that is very important for it to work. It is that you are using a force that is linear in the distance to the centre (like a spring). It has the nice property that all the particles will oscillate around the centre with oscillate with the same frequency and thus the trajectories can remain independent. If you add a small non-linear term in r (e.g. 1e-6*r^3) the oscillations are non synchronized and the particles end up colliding again. It is the collision code that forces the particles to follow independent trajectories but it is the specific nature of the force that let the particles keep their independence. This is indeed a nice "bug". It would be interesting to find an application for this, but I cannot think of any in physics because these collisions do not obey the conservation of momentum. Maybe it can still be used to find an suitable initial configuration for a physically correct simulation. Otherwise I saw requests for a screensaver, this is a good idea too :) PS: Happy to see another user of the SFML library!
I changed the code to make the attraction force proportionnal to the radius of the objects and in this case the orbits tend to become concentric circles. And yes I love SFML, I use it for all my projects :)
I was so excited about this for a few minutes before reading this comment. I thought it was an automatic many body problem solver, but then that requires simulated gravity to be a thing.
Hooray I was looking for the people who noticed this, I see you're all here. Concentric circles would make sense in that case, without the global periodicity imposed by the linear force, that would seem to be the most natural way to get a stable solution. I would be curious to see if that also happens if you use a Newtonian potential
I came here to quickly watch the results of a weird bug but what I got was 1h of reading through a thread of 2 guys forming a love-hate friendship over physics discussions. And all thanks to the yt algorithm. If I‘d have wanted to find this I wouldn‘t have... Thanks universe and thanks entropy!
@@mon4d I was more on emptyptr's side tbh. Far more likeable and honest approach to the whole discussion. Also the way he capitalizes words and writes "flat earthler" instead of "flat earther" gave me the impression he's German, so bonus sympathy points, haha.
@@ForgotMyStupidName Maybe it’s more a question of who is the protagonist and who is the antagonist in the whole thing. Because clearly emptyptr was the more friendly and also innocent one, so I would say he is the actual protagonist on his quest to bring justice to the comment section. Tbh, Ilari was the hidden hero though. Randomly coming back, talking about the actual source code, even doing some experiments with it!
This is pretty cool. I think what's happening here is, as the objects initially collide they are forced onto paths where other objects are not. Because you forgot to program the transfers of momentum they all continue on their paths at the same velocity, meaning they'll all return back to the center point at the same time, on their new free path that they were pushed into on the initial collision. This could have applications.
Some of the greatest things invented were accidents. Penicillin, Teflon, post it notes and corn flakes just to name a few. It happens from time to time and if it does it's just so satisfying. Glad that happened for you!
@Ezequiel Ciamparella nah just make it so that each collision is perfectly elastic, i think this behaviour would emerge Nvm i think they would just keep bouncing randomly
It looks like the inward force is linear with distance and mass, turning them all into simple harmonic oscillators. The orbital period is fixed, irrespective of orbital parameters. It is the same physics as a pendulum, that swings in the same time no matter how heavy the mass or distance of the swing.
Is it just me or do these circles look like electron orbiting around a nucleus? When the second example was shown sped up, it really looked like it lol.
The man tried to make a collision system, but instead made a chaotic orbit creator. Imagine if those dots were planets and how beautiful yet scary it would be to live there.
In 23 days mars will have a close approach of 5 meters over northern France. Due to this everything north of Béthune and Roubaix will be evacuated. Anyone Living in Belgium, Netherlands or north of Paris is advised to spend the day underground.
Would be very cool. Though it wouldn't work since this simulation doesn't include gravity between the bodies. Also, I don't think you would want to experience the tidal waves created by that! :) Another unfortunate thing is that gravity would (approximately) cancel out when the planets were at their closest. Lots of weird stuff would basically happen!
Lag, Ping, Cheaters, Shaky Hands, Monitor Turned Off Randomly, Windows Update Pop Up, Accidental AltF4, Brain Lag, Oriolois Farmonden Acumuladum Disabled, Tendromechiometric Defrangentanglement Of The Internal System Of Hatropentratum, Detrohavolentiopendletact Caused Fertadelopadoteagovelten Of Your Revampocelarnatianframatic Harnamentolengofunction To Candotendromentalidalinopagle... I Hate When These Happen >:(
This bug... this bug is something that could get you into some famous colleges for this unique characteristics- you could ask mathematicians to figure out how this is even possible! They would illicit so many responses- Your bugged program could become famous!
this is interesting, it looks like the balls have the same period of orbit but their positions never intersect. if im right, they all have the same acceleration towards the center, so they have the same velocity functions but are all parallel towards each other.. something is making them parallel...
I believe this is similar to planets clearing their orbits, except when planets collide they usually do a bit more than bounce into a different orbit. Less of a bug, more of a phenomenon
What you've managed to describe here might also be known as gravitational tensegrity. Nothing ever collides because it's always in perfect balance with everything else. Evidently, chaos tends toward order 😏😅
oh, I initially thought the objects are interacting with each other through a force of attraction, like gravity. that assumtion made the result look kind of groundbreaking :) now i see they are only attracted by the center point, which is still neat.
So is what’s happening the fact that there’s no friction so while being gravitated towards the center if they don’t stop after hitting something they keep that speed and get pulled back and eventually when nothing is hitting anything it no longer changes speeds or course
In your attempt to create a collision system, you created the coolest anti collision system ever.
When theres more it looked like an atom xD
Exactly! It really looks like a particle system, almost like electron's valence shell without the atoms at the core.
Must be some sign mistake...
System became what it swore to destroy
@@walterroche8192 Idk if any1 has done an animation of particle system be4 but he definitely should save that code.
When you try to make a collision handling system, but just end up making a system that has no collisions at all... Technically, you've solved the problem.
"How to write an O(0) collision engine"
Ah, technicality strikes again!
@@kaidatong1704 The n in O(n) is a variable that means the number of items to be handled. If n is constant then it's not O(n) time, it's O(1) (constant time) because the time to run doesn't depend on the number of items. You don't set constant values for n. O(0) is just a joke, since in a collision-free system you wouldn't even implement the function and thus is it would never actually take any time at all.
@@skipfred sry for spreading misinformation... I deleted my previous comment cuz too lazy to learn and make sure information accurate
vacuously true. didn't make any mistakes while processing collisions
TFW you are trying to implement a collision system and you end up solving self driving cars
Ain't that ironic
@Colin Berg People do that already though, so no big deal.
@Colin Berg 😆😆
@Colin Berg For real tho, just run the simulation until the particles stop colliding and then use the non-colliding paths.
Somebody call Elon
Holy crap
The precision in which these weren't coliding is insanely satisfying
Hope you saved a version of your code with the "bug" and called it "art mode"
Well of course he saved it. If he didn't, this video would probably not exist
Some were colliding slightly. They just weren't being affected when they were hit
@@sirpsionics no they were not, it was just so close you would have to zoom a lot to see they actually don't touch.
Cuz if they did it wouldn't be this smooth
@@alexstasko696 I also think they become red upon touch. But I think he's right, sometimes they touch ever so slightly but the hitbox is too imprecise, that's my guess anyway.
@@timangar9771 well maybe, it's just opinions and speculations anyway
Once a programmer was asked:
-- What are you coding now?
-- Let's compile and see.
Compiling? *coughs in Python*
@@saturnine. The two weirdos alive who've decided to program on punch cards: "AMATEUR"
Underrated comment
@@OatmealTheCrazy the two wierdos who r not alive and decided to program by literally using switches, "Rookie mistake"
@@PotatoPrem ah, the good old ENIAC days
"I don't know why but when I delete this line right here, this happens"
Deleting coconut.jpg be like
This happened to me yesterday, remove an int declaration and the whole program breaks, even tho that int is never used
@@BudgiePanic my programming experience in a nutshell
@@BudgiePanic lmfao. and then you go on stack overflow and nobody can help u. rip 😔🙏
This moe foe found a way to trace the shape of an atom using programmed circles
I feel like this has a lot of potential. Some of the greatest things were found by accident :) Keep it up
Only Problem, he has to figure Out how He did that in Order to continue it😐
@@bigsmoke6414 He fixed the bug, so he must've found the code and deduce the output, and then work from there on to develop the output intentionally.
Especially at 2:27, seems like all their gravitational pulls have synchronised somehow. Search up Dyson Swarms, It's an idea where there are many orbiting solar panels around a star, which could provide enough energy for a type 1+ civilization (more advanced than our own). This technique could solve the problem of collisions between these panels. Sounds a bit crazy perhaps, but I think this technique could be very useful when implemented properly.
@@marzipug5439 Okay, but hear me out. The way this works is they keep crashing into each other until their orbits stabilize. I don't think that's viable to do with solar panels.
@@Shmill That's where this piece of software comes in handy to precalculate! 😁
Theoretically. Guess you'd prefer a bit of space between fast moving chunks of metal that won't keep their precise orbit in reality. 🤔
i can imagine that if someone wanted to create a system where given any radii and position parameters had the task to find a stable orbit relationship without any collisions, it would be really difficult without the use of a neural network (and probably still really tough), but the fact you got this behavior via a bug is just hilarious. and the concept has a lot of potential as a game too. with planets… or somethin haha
I think you would be interested in the three body problem in physics (not the novel)
@@hapybratt8640 whats that?
@@hideousred once three or more objects attract each other, their orbits (in general) can't be predicted exactly.
hard to believe you're the same guy who poured mercury on his keyboard and sent a furry his address
Well in this case there’s no gravitational interaction between the bodies, they just have a single attraction point that stay stable in position and magnitude over time
*Makes code to detect collisions*
*Accidentally writes it to brute-force collisionless orbiting within a closed planetary system*
This guy: Hey, that's not what I meant to do
Bug: It would be a lot cooler if you did
I mean he’s not wrong...
...unless we get into string theory/spaghetti code
it would've been harder to get to this if it was not a mistake
"I was trying to make these balls collide, and ended up creating the universe" said God
Nice bug
Perv
@@comradesusiwolf1599 what?
But apparently the universe functions based on many collisions lol
Bethesda created our Universe
I'd love to see an in-depth video explaining the mechanics behind this behaviour.
As collision avoidance has such wide reaching & valuable applications it seems almost certain that this has already been discovered & no doubt named.
They push each other with constant force until they stop colliding, which requires producing energy out of nowhere. He just messed up conservation of momentum in his calculations.
preservation of angular momentum
What’s cool is you can use it to FIND a stable orbit for any number of objects
It's a sort of accidental evolutionary process, the orbits that don't have collisions survive while those that do get mutated into a different orbit where they get tested again. Very good example of emergence.
what how?
What is ur IQ, bro? Are you an alien?
@@StepanKorney the its kind of obvious if you really look at it and ignore the code.
Yeah, now that you mention it, it really does look like some alternate version of natural selection!
You mean that when they start they are actually colliding? I don't notice that from the video
This should be implemented as an animation plug-in for a composting software like AE.. I know Would pay for that.
Wait for it to blow up.
@@eletronnical1957 it'll go straight to your thighs..
@@exalented lmao i got that reference
@@myname1588 if a game had this as a loading screen, I would probably play it just for that
Or maybe a Visual VST for FL studio. Imagine that dancing at the speed of the music.
This feels like those videos of a city traffic stop that's full of pedestrians, bikers, and cars all moving right past one another, just barely skimming without any accidents
Yo this gives me nostalgia lmao
I'm gonna just search a video like this
Driving in india
This would be even more amazing if it were implemented into a 3D environment!
It's not a bug, it's a feature.
Never underestimate the value of unexpected discoveries.
-Ducancraft (It's a Minecraft ripoff that was FULL of bugs that was kinda popular at this one camp I went to.)
Really, we shouldn't be placing a value on unexpected discoveries, but capitalism tends to do that. :( Why do we have to assign value to everything?
@@TH3RM4L You seem to have missed completely the quote by Isaac Asimov "The most exciting phrase to hear in science, the one that heralds new discoveries, is not 'Eureka!' but 'That's funny...'"
The value isn't necessarily monetary, the value might be progress of humankind.
@@TH3RM4L Because if you want to trade your labor it has to have a value to someone else, simple as that :)
@@ehsnils idk why you talking about asimov, but when Ive looked at other comments, they talk about wanting to pay for this as a feature in some program. Ie, capitilaism has invaded even eureka moments like this
This is a reupload to fix a very bad typo
You have our forgiveness.
How bad??
Also... Hmmmm... Yea I guess it is a bug... But you only forgot to add a slight friction, or loss of energy transferred on collision, haven't you? So colliding items will always end up using another trajectory until they don't collide anymore. It's a universe without energy loss to friction/deformation.
@@enderarchery2153 Your profile picture is a gif!
This cant work
This looks like futuristic traffic where all automobiles are driverless thus driving perfectly without collisions
Looks like the traffic in the bee movie
And human will collapse all the program because Auto programs cant know how human work
cgp grey
Looks like traffic in India
They can use this guy algorithm...
How one man's bug solved the equations for the particles of an atom.
This is incredible! I can imagine somewhere someone wanted to intentionally set out to make something that looked like this, but the animation required to hand create something like this would take a quite a while! So cool to see something this beautiful come from coding.
Hi
You have a verified channel so i'm gonna comment here
@@geniusprime9795 agreed
@@geniusprime9795 same
"So I accidentally added a minus where there should've been a plus... This happened as a result"
He just forgot to add code to update the speed so the object move with 0 energy loss and eventually bounce off each other in a way that causes no new collisions quite simple and im sure most people that were trying to make a collision system have found a movement bug related to this exact bug, hes just probably the first to do it like this
@@nothingnothing1799 Yeah but we should take a moment to appreciate that guy's quote
@@nothingnothing1799
I think there must be a second error made as well. All of these take the same amount of time to complete their orbit, no matter how big their orbit is.
@@ekkehard8 I think that all the balls start moving at the same speed, and typically when they collide you would calculate the amount to slow them down by the balls mass (or aproximate it using their size) to have energy conservation.
@@ekkehard8 Not a physics error though, a test quirk. There is an inward force as part of the test, and it looks to be linear with respect to distance and mass, turning them into simple harmonic oscillators. This is the same physics that is used for almost all clocks. If anything it speaks to the accuracy of the physics code that an oscillator works accurately enough for this to be stable!
So I read the code, and I would summarize it like this: basically he didn't implement velocity update when collision happens. When collision is detected (with simple radius check), he just nudged both of the spheres back away from each other just enough that they touch. The end effect is that they slide off of each other, continuing on their original path. So its like inelastic collision with no friction? Anyway it's these unique ingredients that drive the system to a stable state with no collision. Very cool!
Thanks for the explanation!
Thank you so much for an actual explanation from reading the code. There are so many comment trains here with wild speculations that I can't parse enough to figure out if they are valid or not. I was thinking I would have to grab the code myself and see, but you beat me too it.
Thats what I was thinking was going on, they are kind of acting like billiard-balls, where in reality some of the energy would dissipate as heat, here it simply perfectly transfers to the colliding objects.
@@xdlmaoooo No they aren't transferring energy to each other, that's the problem. They're ignoring each other's velocities, only slightly nudging each other enough to slide past without overlap.
is this right: the two colliding circles change each other's *positions* without changing either one's speed/direction/mass/etc? What happens in a near head on collision?
If I understand the code, each ball is attracted by the center through an elastic force, while collisions directly displace pairs of overlapping particles away from each other in such a way that they end up barely touching, without modifying either of the registered speed values.
Each ball has the same mass, so the period of each orbit is essentially the same, as a result the whole dance will stay in sync once the particles trajectories have been tuned to avoid overlapping.
As far as I can tell, the speed itself is never updated by anything but the force, only the time-step size changes, that part is confusing but I guess that the simulation slows down when particles collide. However that would result in infinite acceleration toward the center would the particles jam upon each other so I may have missed something.
there is no drag or air force, and orbits are perfectly stable
so the simulation will always stablize after a certain amount of time
They wouldnt need to have the same mass if the force is gravity like right?
@@broor if the force is proportional to mass yes
I don’t think the simulation slows down when the particles collide. To me, it looks like the particles temporarily slow down while they are pushing each other, and once they are free, they go back to their old speed
My guess is that there's no velocity loss with any of the balls after they collide. So the balls fall to the centre and orbit around it and the collisions between each other are correcting their path until eventually, over time the balls develop paths that don't collide with any other ball or barely slide past one another. Cool bug.
Nah it's not that. This alone doesn't provide any force that would drive the system into collisionless state. Entropy doesn't reduce in its own.
@@LiraScarlet Like I said fully elastic collisions alone (which fully conserve energy) isn't enough to produce this system state - the balls would just keep bouncing randomly forever. And neither are elastic collisions that generate energy, that just increases"orbital eccentricity" with every bounce thus reducing density and by extension the odds of collision, but doesn't moves anything into specifically collisionless trajectory. I invite you to attempt to replicate such result in a properly written physics simulation engine using any parameters you want - this scenario won't happen, other forces than restitution adjusted impact normal are required to achieve this effect.
@@michaelbuckers I think I have a simple counter-argument for your claim here:
The balls basically try out different trajectories. If the ball does not have a free trajectory, it will collide. This will change the trajectory, and the ball will try a slightly altered one. This process will continue until all balls have free trajectories. After that we will see the behavior demonstrated in the video.
I can not see how the system would converge to a "random bouncing state" you are suggesting there. (Or at least that is higly improbable with randomish start state.) The free trajectory state is the only one that does not change itself, so I am pretty sure the system will converge to that one.
Also, I challenge you to produce this random bouncing state you claim will occur.
@@IlariVallivaara You're talking out of your ass. It doesn't even looks like you ever seen the elastic collision equation in your life. Go take a look at it and point out literally anything about it that suggests that any system of moving bodies will converge to a collisionless state, you massive dunce.
Your challenge has been already complete: molecules of air never stop bouncing, objects in the solar system never stop colliding.
@@michaelbuckers You are confusing ideal simulation with messy real world, sir. Have a nice day!
I might be wrong but I think the reason this happens is that there's no loss of momentum when they collide just a change of the direction of momentum, so what happens is that they push each other out of the way but continue to move at the same speed, just in a different direction, which eventually causes the system to become stable.
This makes a lot of sense.
Yep, looks like that. You just solved the mystery. Yet it's facinating!
came to the same conclusion, no velocity is lost.
However, collisions don't change their direction, instead they just nudge eachother while keeping their original direction.
The other essential condition is that their size don't impact their speed, so once two balls have moved out of each other's respective paths, they'll never collide again unless they're moved by other balls.
This simple principle has wider applications..... In cases bound by Newtonian physics, should you inject enough energy into a media to overcome friction, but not entropy, it will eventually systematize so as to obey physics in the most efficient manner, causing the media to be more orderly. An example would be the "Frito's Bag" which claims that the chips in the bag may have settled in shipping, causing the air gap in the bag. The result is that the chips are stacked more orderly in the bottom of the bag than they were originally filled at the factory. Call it the "Lays Bag Theorem" ; P. This can be useful in manufacturing, medicine, and .... I just realized that's the principle behind the electrotreatment my GF receives for her nerve damage. I mean, I should probably finish my degree so I can learn exactly what this is called because I doubt this is original.
@@jakefromspace4659 Wooow, nice tangent you went there. Got me captivated from start to end.
I feel like this is the type of thing that is gonna be recomended for me in 7 years.
Same
because it will
Your comment made me open the comments section just to check if you had commented this 7 years ago. I am now dissapointed lol
Yes
100%
I'm shocked.
A few months back I decided to try to implement a collision system myself for fun, although the particles would look ahead, and if it saw the trails of any previous particles it would turn in a direction away from it. I randomly picked different wells of different strengths around the plane for the particles to have something to keep them from just bouncing against the walls, and the end result was basically this similar group weaving and bobbing, but the groups would collectively migrate to different parts of the screen.
It wasn't what I was going for, but since I had written it where it could handle 10M particles, I loved what I ended up with that I never even considered "fixing it".
2:05 The ship that has the main character be like:
that's funny
Underrated
That's what Plot Armor looks like
This joke doesn't work because none of the objects are colliding
@@Dragnulls exactly, none of the objects are colliding so pointing one out serves no purpose
Why did this make me so ecstatic, the tension of them being pixels away from each other and the overall flow is immense yet powerful.
Because so little is happening in your life that the bar for "ecstatic" has become set very, very low.
@@TheEvilCheesecake Not really sure what you're on about kid but if you can't respect art don't say anything.
If you can't respect my opinions don't say anything
@@TheEvilCheesecake Your opinion is void of interest and reasoning therefore not worth respecting.
So is yours and I'm ecstatic that you understand that.
It's like watching the DVD screen. waiting for it to touch one
Except it actually can’t touch even though there is nothing that says is should’nt
1:24 that one teammate in dodgeball.
The website that hosts "Power Game" and "Power Game 2" has a planets game, and the physics works exactly like this
what is the link I cannot find it
@@WrinkledSkin4643 look for powder game or powder toy
@@WrinkledSkin4643 search for Powder game 2 danball in your browser or search Powder Game on play store
Congratulations Bluecore, you just misled someone with a double typo.
*Powder Game
"He's working perfectly in-sync with his parallel universe copies of himself!"
"HAYAAAAA"
Rick and Morty?
No jokes, this is solid sci-fi.
@@SU76M no, I referenced TerminalMontage's Speedrunner Mario VS Melee Fox
These happy accidents are my favourite thing in programming, you can get endless hours of fun just by playing around and exploring its details. It's like going on an unexpected adventure
It’s like painting with bob ross except more logical, more frustrating, and more exploratory
Your comment reminds me of Sebastian Lague, who has one of the most entertaining programming series on RUclips
@@DavidFong21 tssh, Sebastian's projects are child's play. I personally prefer ThaRemo's coding adventures
@@ThaRemo Sorry, who’s that? ;-P
@@DavidFong21 Their name is whispered is the hall of legends ;)
But for real, Sebastian probably makes my favourite content on YT, mind-blowing every time!
I mean, yeah. It solved collisions, after a manner of speaking
As a programmer I can confirm I had goose bumps watching this
Same!
Indeed! This is amazing! How is that even happening?
You weren't kidding. This is the most satisfying thing I've seen in a while
You should do this again but make the trail lines of each ball stay rather than fade away. You’ll probably get some cool patterns
It would result in a bunch of ovals
This is amazing! Holy heck!! This is better than when I was trying to shuffle an already shuffled list and instead got back a sorted one 😂
The fact that they dont touch each other is truly fascinating
Yes
They do Touch each other Sometimes. Watch closely
@@ZLP-TM it may appear that they are touching because of the technical limitations of your display but if the calculations are correct, there should always be some space between the circles.
It's almost as if that's the point of the video
@@creampielover69
They definitelly touch and slow down, watch closely.
Thats mostlikely because he didnt run his program for long enough, it takes time for them to settle in
an ancient chinese guy: best war is the one you dont have to fight.
this guy: best collision system is the one you don't collide.
Ohh now I know why them came up with "corona" so they don't have to fight
@@arvind31459 "came up with corona"
@@shlabedeshlub3334 kek
This is how I'd imagine traffic to look once every car is autonomous and connected to the same network
Until somebody manages to gain access to that network and then you end up with the first program
it would be a bit traumatic ... ^^
And then one random car have a slight bug who make it deviate slighty of it's trajectory and an enormous accident happen as the result.
Dystopia
THAT TRAFFIC SCENE FROM THE BEE MOVIE
1:15
This little one is dodging for his life
me as a computer science student would never think that a bug could be so gracious and majestic
You'd be surprised to see what people have done with bugs
Still can't believe someone ported smb1 into smw just via gameplay alone
Degree in computer science don’t mean you know shit.
@@lostmeme9862 but it means I understand it
You will see your share of weird shit, trust me.
My funniest was a 200ish line function that I wrote while rather absent minded. I ran it, it worked perfectly. After running it for a really really long time it returned an answer that was obviously wrong.
I thought the bug cant be that complicated as it otherwise did exactly what was expected. Looking at it I found many totally obviously wrong conditionals. Swapped AND's and OR's, < in stead of >, lookups in the wrong spot of an array. All easy to fix but in stead I sat there for some 30 min wondering how it ever produced a correct result. There was some mad unexpected recursion going on where n wrongs made a right. I couldn't figure it out. Probably the most complicated code I ever read. (I use to write machine code)
It was all so obviously wrong my theory is that some higher entity took over my hand and made a joke.
It happens, when things go in inverse,
This is amazing. It's almost like there is some "self-optimization" that is occurring. The first time they come into contact, they slide past each other and then orient themselves in such a way that they don't ever touch when they come back around. Pretty cool.
Well not the first time, in the big one it took like half an hour to happen. I suspect he forgot to implement some kind of friction to make things actually eventually stop, and then the can just keep bouncing until they reach some stable configuration where they slide just past each other
@@mennoltvanalten7260 yeah if the energy is conserved it's bound to happen at some point
i think you understand the Gravity of the situation!
Acshually, gravity has an -1/r potential and here we see an r^2 potential around the center 🤓
In -1/r the orbits would not have the same frequency so the balls would not meet so nice again
@@gigab0nus I have never heard of that before (-1/r potential I mean), where can i find more information regarding this?
@@emptyptr9401 The wikipedia article "Gravitational Energy" shows the basics of the -1/R potential very compactly. Its consequences are explained in the article "Orbit" and probably in any youtube video about orbits. The r^2 potential on the other hand is known under the name "harmonic oscillator" and can be found everywhere in physics
@@gigab0nus ok thx
I literally used to make these exact simulations with these exact bugs in QBASIC 30 years ago.
This is basically a simulation of my anti-social self doing my best to avoid human contact at every turn
Me, when I walk with my dog
And being extremely good at it
@@Mandor3 Lol, can relate.
@@marvinkohrt9581 uh no
Nobody:
The protagonist in an action movie during the shoot out: 2:03
Ga h , just what i was gonna put :oo
Narrowly avoiding everything? Sounds about right.
it is surprising how many cool things can happen with a "little" bug but this is so interesting great work
A single change can lead to huge differences, check out this new documentary to see the big picture ------> The Connections (2021)
This is a rare example. 95% of bugs will probably crash your app
yeah let me google stackoverflow for the answers on my cool little bug "Unexpected indent"
@@Adomas_B thats what makes these moments so cool
I legitimately spent hours trying to find this video the other day, I thought the effect was so cool but I had absolutely no idea what it was called. Eventually gave up. Now here it is in my recommendations. The world is weird.
have you ever considered making educational analysis on your work?Maybe an advanced tutorial for c++?Good job anyway!
Yes I am considering this, there seems to be a demand for it
@@PezzzasWork It would be awesome !
@@PezzzasWork cool
@@PezzzasWork please do this
@@PezzzasWork Please do it
This would be the dopest looking main menu wallpaper of a futuristic space sci-fi game where traffic/travel is a thing, like in GTA or cyberpunk. You would see hundreds of spacecrafts just perfectly travelling through this portal intersection etc. (the tightest turn being the portal)
Accidentally made a simulation of particles. Something that never collides by trying to make them collide. That is genuinely really cool
Bullet hell players be like:
This is cool! I saw your initial upload two weeks ago. I downloaded your code and tried to understand what makes this effect emerge.
There is a comment under your previous video explaining that this effect happened because you updated only the positions and not the velocities of the colliding sphere. This is true and I think it is indeed part of why the system is not chaotic (in the mathematical sense: small errors on the initial velocities are not amplified by the collision since you do not update them).
I would like to add that there is something else that is very important for it to work. It is that you are using a force that is linear in the distance to the centre (like a spring). It has the nice property that all the particles will oscillate around the centre with oscillate with the same frequency and thus the trajectories can remain independent. If you add a small non-linear term in r (e.g. 1e-6*r^3) the oscillations are non synchronized and the particles end up colliding again.
It is the collision code that forces the particles to follow independent trajectories but it is the specific nature of the force that let the particles keep their independence.
This is indeed a nice "bug". It would be interesting to find an application for this, but I cannot think of any in physics because these collisions do not obey the conservation of momentum. Maybe it can still be used to find an suitable initial configuration for a physically correct simulation. Otherwise I saw requests for a screensaver, this is a good idea too :)
PS: Happy to see another user of the SFML library!
I changed the code to make the attraction force proportionnal to the radius of the objects and in this case the orbits tend to become concentric circles.
And yes I love SFML, I use it for all my projects :)
@@PezzzasWork SFML is great :D
I was so excited about this for a few minutes before reading this comment. I thought it was an automatic many body problem solver, but then that requires simulated gravity to be a thing.
@@skaramicke the orbit here goes around the center if ellipse, instead of the focus of ellipse
also all objects has same periodic
Hooray I was looking for the people who noticed this, I see you're all here. Concentric circles would make sense in that case, without the global periodicity imposed by the linear force, that would seem to be the most natural way to get a stable solution. I would be curious to see if that also happens if you use a Newtonian potential
1:40 traffic in india
I came here to quickly watch the results of a weird bug but what I got was 1h of reading through a thread of 2 guys forming a love-hate friendship over physics discussions. And all thanks to the yt algorithm. If I‘d have wanted to find this I wouldn‘t have... Thanks universe and thanks entropy!
Totally just nerd sniped me. Whose side were you on? :D
@@ForgotMyStupidName I just love them both ❤️😂
@@mon4d I was more on emptyptr's side tbh. Far more likeable and honest approach to the whole discussion. Also the way he capitalizes words and writes "flat earthler" instead of "flat earther" gave me the impression he's German, so bonus sympathy points, haha.
@@ForgotMyStupidName Maybe it’s more a question of who is the protagonist and who is the antagonist in the whole thing. Because clearly emptyptr was the more friendly and also innocent one, so I would say he is the actual protagonist on his quest to bring justice to the comment section.
Tbh, Ilari was the hidden hero though. Randomly coming back, talking about the actual source code, even doing some experiments with it!
Well that was entertaining
This is pretty cool. I think what's happening here is, as the objects initially collide they are forced onto paths where other objects are not. Because you forgot to program the transfers of momentum they all continue on their paths at the same velocity, meaning they'll all return back to the center point at the same time, on their new free path that they were pushed into on the initial collision. This could have applications.
2:25 Humanity somehow surviving 2020
Watching this in slo-mo and waiting for them to collide is the new "DVD video" symbol hitting the corner.
you NEED to make an oddly satsfying compilation of this or something, its mesmerising, how does this even come to be!?
Wooow, You actually simulated an atom, or even the whole universe :D or it looks like the electrons in the atoms at least :D
Next week : "I have created an entire solar system and life by a nice bug"
Maybe our universe is only a bug in a simulation
@@alexisp-c379 This is the way
@@alexisp-c379
That a possibility and why I love the butterfly effect
The matrix all started with a bug
@@FredGlt
Well, don't have watched the lore of Matrix for now but that a possibility
It is just incredible, it looks like it makes everything in sync perfectly. A bug that happens to be a feature.
Some of the greatest things invented were accidents. Penicillin, Teflon, post it notes and corn flakes just to name a few. It happens from time to time and if it does it's just so satisfying. Glad that happened for you!
Teflon is poisonous.
@@Владислав-ы9м5у it only is if you heat it up too much or if you use metal cutlery to scrap out food of it
@@magicmerls291 have you ever heard of using oil?
@@Владислав-ы9м5у why don't do both?
Did you just accidentally solve the 3-body problem?
Wow, awesome bug! This is so satisfying to watch. And I agree - no idea how you'd actually *try* to do this!
@Ezequiel Ciamparella nah just make it so that each collision is perfectly elastic, i think this behaviour would emerge
Nvm i think they would just keep bouncing randomly
Dude, I'm studying particles right now and was trying to picture how chaotic it its, it would be awesome to have this on 3d
Cool accident
Woah this is super cool, its insane that all the orbits manage to find harmonics without any of them completely stopping!
It looks like the inward force is linear with distance and mass, turning them all into simple harmonic oscillators. The orbital period is fixed, irrespective of orbital parameters. It is the same physics as a pendulum, that swings in the same time no matter how heavy the mass or distance of the swing.
Is it just me or do these circles look like electron orbiting around a nucleus? When the second example was shown sped up, it really looked like it lol.
Every time I try to watch this video I get this cool loading screen with green circles instead
When the main goal is to collide them but you end up making them avoid each other
fnf boyfriend
"Failure"
The man tried to make a collision system, but instead made a chaotic orbit creator. Imagine if those dots were planets and how beautiful yet scary it would be to live there.
In 23 days mars will have a close approach of 5 meters over northern France. Due to this everything north of Béthune and Roubaix will be evacuated. Anyone Living in Belgium, Netherlands or north of Paris is advised to spend the day underground.
Would be very cool. Though it wouldn't work since this simulation doesn't include gravity between the bodies. Also, I don't think you would want to experience the tidal waves created by that! :) Another unfortunate thing is that gravity would (approximately) cancel out when the planets were at their closest. Lots of weird stuff would basically happen!
Oh I see you must have checked the "movie car chase down the wrong side of the road logic" box.
2:04 me shooting at other players in video games
HOW IN THE WORLD DID I MISS ALL OF THOSE
- You, probably
@@OrangeC7 the answer is my pc lag ping or a hacker
Lag, Ping, Cheaters, Shaky Hands, Monitor Turned Off Randomly, Windows Update Pop Up, Accidental AltF4, Brain Lag, Oriolois Farmonden Acumuladum Disabled, Tendromechiometric Defrangentanglement Of The Internal System Of Hatropentratum, Detrohavolentiopendletact Caused Fertadelopadoteagovelten Of Your Revampocelarnatianframatic Harnamentolengofunction To Candotendromentalidalinopagle...
I Hate When These Happen >:(
@@darwinnexus6925 same and nuclear fallout
This bug... this bug is something that could get you into some famous colleges for this unique characteristics- you could ask mathematicians to figure out how this is even possible! They would illicit so many responses-
Your bugged program could become famous!
...or it could be a straightforward example of some law of physics in a closed environment
@@WhatIsMyPorpoise probably this tbh
Tesla should implement this into their upcoming rickshaw models in India.
ah yes, autorickshaws
Underrated comment right here
70th like. Sorry.
Introducing: the model R (ickshaw). By Tesla.
@@improcrastinating8063 I'M A PICKLE HYPERDIMENSIONAL ANTI-NEWTON'S CRADLE RICKSHAW, MORTY!
this is interesting, it looks like the balls have the same period of orbit but their positions never intersect. if im right, they all have the same acceleration towards the center, so they have the same velocity functions but are all parallel towards each other.. something is making them parallel...
I believe this is similar to planets clearing their orbits, except when planets collide they usually do a bit more than bounce into a different orbit. Less of a bug, more of a phenomenon
I feel like this is gonna be one of those videos that just... Keep showing up in people's recommended forever and ever lol
Yeah like that buzzfeed video on candy trading on Halloween, idk why i get that every year in july
Let's hope!
this is the best bug ever
bugs in my stuff be like: "Segmentation fault (Core dumped)" or... "YOU FORGOT A FUCKING SEMICOLON"
Those arent bugs tho
@@darltrash ye, errors... but i wanted it to fit video title
@@random6033 makes sense
What you've managed to describe here might also be known as gravitational tensegrity. Nothing ever collides because it's always in perfect balance with everything else. Evidently, chaos tends toward order 😏😅
oh, I initially thought the objects are interacting with each other through a force of attraction, like gravity. that assumtion made the result look kind of groundbreaking :) now i see they are only attracted by the center point, which is still neat.
1:29 imagine drivers drive like this without crashing
Alternative title: Minecraft xp balls not touching each other for three minutes straight
Drivers in India be like, amateur. We don't need computers to do that.
i think i saw this before on the channel
There are no mistakes, just happy little accidents :)
1:10
Me dodging my responsibilities
So is what’s happening the fact that there’s no friction so while being gravitated towards the center if they don’t stop after hitting something they keep that speed and get pulled back and eventually when nothing is hitting anything it no longer changes speeds or course
_Stackoverflow:_ Weird bug causes creation of ancestor simulation?
_This question was marked as duplicate._
2:34 Me, as the last team member in the game, playing dodgeballs in middle school.
I literally had a :D face for 2/3 of this video, thank you for this happiness! ^^
If you render time as a third dimension you essentially have a very complicated braid!
The way the spheres so perfectly avoid each other is mesmerizing.
That is so inspiring, now I'm gonna start writing random codes until I invent something awesome like this.
Did you find anything yet?
As you can see, this occurs when your only handle depenetration.
for (uint32_t i(0); i
@@davidwarford3087 Is this c plus plsu
Man trying to make a collision system accidentally found out how our world works at an atomical level
i wanted a collision, i get an atom .-.
When you started writing this code, only God and you knew what you were doing. Now only God knows.