Based on the code it seems you are only applying force to [j] particle and not to [i] particle at the same time.
Haven't you been calculating force between two particle once and then applying that force to both of your particles at once?
Based on the code it seems you are only applying force to [j] particle and not to [i] particle at the same time.
Haven't you been calculating force between two particle once and then applying that force to both of your particles at once?
If i set NUM_TOTAL = 2; and 2 opposite particles, they start pushing eachother away in opposite direction, as should. Same code as before, i just commented Z-related lines. "with star[i] do" on second quoted line refers to "i" particle.
I didn't do the math before, i was thinking it might still be relatively same effect.
sqrt(4)*sqrt(4)*sqrt(4)
= 2*2*2 = 8
= sqrt(4*4*4)
= sqrt(64) = 8
X/Sqrt(Y)
= (X*X)/Y , if Y>=0
my projects https://github.com/dpethes
Oh crap... this is how it actually goes:
X / Sqrt(Y)
= (X*Sqrt(Y)) / Y
which puts us back to square 1... on why doesn't it work, or works like that even when using sqrt? I have tried decreasing, but also increasing the G_FORCE to compensate lack of particle density in depth direction. But at the same time there is a more uniform force pulling every direction, from the overall system.
If you scratch one dimension, you have to reduce the divisor - scratch one multiplication. Then it could be reduced further, this should work nicely:Code:d = G_FORCE / d
Last edited by imcold; 21-06-2013 at 05:57 AM.
my projects https://github.com/dpethes
Remember there were originally 2 multiplications in optimized version, so now it becomes 1 and that looks like working well
I still want to give boundaries to the world though, and see what it'd be like. Kind of like how subsection would settle, and i expect a little plasma-like effect. Some days later perhaps.Code:d:=G_FORCE/(d*d);
edit: Decided to code them straight away. (No plasma, but something more boring )
Code:// Rectangular collision {if v.x<-10 then movement.x:=abs(movement.x) else if v.x>10 then movement.x:=-abs(movement.x); if v.y<-10 then movement.y:=abs(movement.y) else if v.y>10 then movement.y:=-abs(movement.y); } // Circular collision if v.x*v.x+v.y*v.y>100 then movement:=reflect(movement, vector2f(-v.x*0.1,-v.y*0.1));
Last edited by User137; 21-06-2013 at 07:25 AM.
Here is interesting proposal for simulation scenario:
After creating particles in the first place give them initial velocity as if tey would be orbiting some point in the center of your simulation world.
I think it could make some more interesting results since particles won't simply split into positive and negative group so fast. And if you give particles which are closer to the center a bit more speed you might even get some swirl effects from particle movments.
Bookmarks