Gavity sorting?

  • Thread starter funkpun
  • Start date
  • #1
4
0
Hi all. I've been playing around with a simple gravity simulator I wrote in Processing. I have a version that impliments a second degree modified Euler integration scheme on particles in three dimensions. Attached is a screen strip of screen captures showing the first few moments of the simulation.

What I find interesting/weird is that the direction of rotation as the sheet collapses is always the same -- the top falls forward, the bottom falls back (particles become more and more cyan as they move forward).

I don't believe this is a programming issue, as the documentation for the randomize function says: "Each time the random() function is called, it returns an unexpected value within the specified range..."

I'm curious if there might be a physics or numerical reason for this tendency.

I'm happy to share my code, if you want to see it -- although it's still extremely messy and gnarly and such.

Cheers,
Fp.
 

Attachments

Answers and Replies

  • #2
30,150
6,616
If you seed the random number generator with the same seed each time then it will give exactly the same results each time. Try seeding with a different number.
 
  • #3
4
0
"If you seed the random number generator with the same seed each time then it will give exactly the same results each time. Try seeding with a different number."

I'm *not* using a seed. It's randomizing properly.

Fp
 
  • #4
30,150
6,616
All random number generators use a seed. If you are not explicitly setting it then it is probably using the same default seed each time resulting in the exact same simulation each time.

Set the seed explicitly and then change it and see what happens.
 
  • #5
4
0
It's not the random seed -- randomize is working correcly. There's also no bias in the way the sheet is constructed:

for (int i = 0; i <= bodies.length-1; i++) {
bodies = new Objects(random(w), random(h),random(0, 50), random(0,200));
}

create a particle w. random x,y and z between 0 and 50, with mass of 0 to 200.

Fp
 
  • #6
I didn't know I signed up for a coding forum ;]
 
  • #7
30,150
6,616

Related Threads on Gavity sorting?

  • Last Post
Replies
17
Views
3K
  • Last Post
2
Replies
28
Views
6K
Replies
5
Views
2K
  • Last Post
Replies
6
Views
2K
  • Last Post
Replies
4
Views
2K
Replies
1
Views
575
Replies
10
Views
2K
Replies
4
Views
1K
Replies
19
Views
3K
Replies
2
Views
682
Top