Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / [DBP] - cool thingy from elastic collision

Author
Message
noobnerd
13
Years of Service
User Offline
Joined: 30th Nov 2010
Location:
Posted: 16th Apr 2012 22:48 Edited at: 16th Apr 2012 22:57
Okey so i was doing a function to handle elastic collision between 2 balls of the same mass, a task which i think i accomplished. (the momentum of the system drops by about 2-5% which it shouldnt, but after that it levels out and stays at aproximately the same momentum after that as it should) I used vector projection as the main part of my function which can be found in the snippet.

okay but as i realised there already was a cool, more realistic, and faster gas simulator here i decided to post a cool "bug" i accidentially stumbled uppon while coding this.

If 2 balls are placed so that they overlap initially, they will now be "entagled" together (its just a name i came up with, not the real thing ) which means that they always stay at the same distance from each other ( it seems actually that they behave like there was a pole between them ). they will then because of the different starting vectors i gave the 2 balls start to move eratically, but not completely randomly. It will appear random at first but it isnt it seems after a while.

check it out:

oh and it uses a2plugin for the graphics (can be replaced with other stuff but wont be even 1% as cool)

oh and you may wonder why i have a for loop for 2 items, well its because i was lazy and just copied the code from my 200 ball version

the lower one is the same but with 25 "ball pairs" and easier graphics. it forms a nice spiderweb if you let it run. For some reason it seems thatsome of the pairs are able to disconnect forming normally beahving balls. press spacekey every now and then to reset tehm back to starting positions.



Login to post a reply

Server time is: 2024-04-18 07:33:26
Your offset time is: 2024-04-18 07:33:26