gak / gravit

A gravity simulator
http://gravit.slowchop.com/
GNU General Public License v2.0
66 stars 15 forks source link

Wrappable Universe mode #95

Open gak opened 10 years ago

gak commented 10 years ago

My suggestion has two parts, the first could be an interesting type of simulation, and both parts joined would be the full idea.

  1. To restrict a certain area of the simulation within a cube (or rectangular prism) where when a particle exits the area, it is teleported to the other end of the cube. The teleportation should be a subtraction of the width, rather than teleporting exactly to the edge.
  2. Each force calculation is done an extra 6 times with a "copied" universe in the adjacent sides of the cube. Initially I was considering 27 (3^3) which includes the diagonal edges (i.e. 45 degrees to the edges and corners), which may cause the simulation to be much slower without much extra accuracy added*.

This will slow down the simulation by a factor of 6, but might give a very different, interesting simulation. The aim is to make the universe not have a centre point of gravity where all particles tend to go towards, which is more like our current universe.

Initially this could be a variable called boundary_mode to be 0 by default and 1 as the first point above, and 2 as the two points above. These would mean "No Wrapping", "Position Wrapping", "Position + Gravity Wrapping".

*Not sure how to determine how much more accurate it is.

gak commented 10 years ago

From a quick Google search, it appears the idea of that universe a three-dimensional torus shape.

http://en.wikipedia.org/wiki/Doughnut_theory_of_the_universe

FrMo commented 10 years ago

Very interesting idea! I think that step 2 could even be optimized a bit, because the "twin universes" have some symetries:

.. I'm curious to see how our simulations will look like in the "wrapped universe".

gak commented 10 years ago

Great optimisation ideas!

There's an experimental branch with lots of hard coded values. I created a "uniform" spawn script which is just randomly placed particles. I was expecting particles to only be interacting with their local area, but instead they started moving towards the centre. This happened even when I removed any calculations towards the middle universe. This could very well be a bug in my modifications, because to me, it doesn't make sense for this to happen! I found a video of someone else doing similar, with many more neighbours, and the same thing happens: https://www.youtube.com/watch?v=KkgyKQantbg

There is a rendering problem when particles wrap around. The particle tails create a long line from one edge to the other. Not a big deal to solve it though. Either keep a ledger of wraps so gfx knows to skip that render, or detect if the position difference is very similar to the width and skip it.

I'll play with it some more today.

FrMo commented 10 years ago

hmmm...