• Welcome to League Of Reason Forums! Please read the rules before posting.
    If you are willing and able please consider making a donation to help with site overheads.
    Donations can be made via here

Self made gravity simulator

CupOfWater

New Member
arg-fallbackName="CupOfWater"/>
Hi!

I've made a simulator for the gravitational pull between objects in space! It's made with the Xpresso module for Cinema 4D (a 3D program). It's still at a very early stage, but I've got the basics in place. Particles attract each other with the formula F=mm/r^2, and larger objects also attract the particles. The particles cannot crash in each other though, so they sometimes gets flung out of the camera view because they get so close to each other... The particles are literally shape-less.

Here's a quick animation. The particles are placed in a sphere shape, and a planet moves towards them. Notice how the particles starts interacting with each other in the beginning! Then they are sucked towards the planet, and most of them crash, but some moves into an elliptic trajectory.



I am trying to work out a way to make the particles die when they are close enough to another particle, and have another particle born just where the other two died.... That way it will look as if the particles merged. That would solve the problem with some of the particles getting flung out of the camera view

Here's a screenshot of the systems behind what you see in the video, edited to make it more understandable:
 
arg-fallbackName="Zylstra"/>
am trying to work out a way to make the particles die when they are close enough to another particle, and have another particle born just where the other two died.... That way it will look as if the particles merged. That would solve the problem with some of the particles getting flung out of the camera view

what if they, upon hitting under certain conditions, stuck together?
 
arg-fallbackName="scalyblue"/>
Zylstra said:
am trying to work out a way to make the particles die when they are close enough to another particle, and have another particle born just where the other two died.... That way it will look as if the particles merged. That would solve the problem with some of the particles getting flung out of the camera view

what if they, upon hitting under certain conditions, stuck together?

That would still take up the same amount of processing power..he needs to die both of the objects and create a third one with the combined mass and calculated trajectory...the concept is simple but in execution it's a bit more complex.
 
arg-fallbackName="aeroeng314"/>
That would still take up the same amount of processing power..he needs to die both of the objects and create a third one with the combined mass and calculated trajectory...the concept is simple but in execution it's a bit more complex.

I've done this before, but it's always simpler in a procedural language. Granted I didn't do anything fancy with the collision detection; it was just an O(n,²) brute-force check. Creating something similar in block diagram form is a little less trivial.
 
arg-fallbackName="CupOfWater"/>
aeroeng314 said:
That would still take up the same amount of processing power..he needs to die both of the objects and create a third one with the combined mass and calculated trajectory...the concept is simple but in execution it's a bit more complex.

You're right... The xpresso setup for finding the medium distance from both particles, calculating combined velocities, spin and mass, and then emitting this particle at the correct time, is enormous!

It was areal headache to find the medium distance from both particles...
1. Get the positions of the particles from a vector to XYZ.
2. Subtract one particles XYZ values from another particle.
3. Get these new coordinates into a vector.
4. Have this vector tell the computer where to emit the new particle.
 
arg-fallbackName="scalyblue"/>
If it's object oriented, why not assign the "planetoids" the same attributes you assign the planet. The routine that dies objects that hit the planet could most certainly do the same for your smaller objects...why have different classes for them, anyway. Make all of your object classes identical to the planet, with the only differences being the value for mass..and see what happens?

Aside from that--and your efforts are impressive--why don't you try your hand at a pre-established physics API, like http://www.thephysicsengine.com/

Aside aside from that, you might be interested in a computer game called osmos.
 
Back
Top