Help With Particle System Shape

Yonathan Zenebe's icon

Hello friendly coders!

I am using a jit.world to make a particle system and am following Federico's Amazing Max Stuff tutorial.
Currently, my particles are contained in a cube shape. Can you help me figure out how to contain them within a sphere shape instead?

Particle_example_forum_post.maxpat
text/plain 36.63 KB


Federico-AmazingMaxStuff's icon

Hey hey,

they are a cube because they are initially placed using random numbers evenly spaced between -1 and 1.
You could normalise their initial position vector to get a position placed always at 1 unit from the centre.
Then you could use a random number to randomise it and so get it inside the sphere.

Here's the patch

Max Patch
Copy patch and select New From Clipboard in Max.

Holland Hopson's icon

And adding [sqrt] in the jit.gen just after [in 1] will generate an even distribution of particles. See https://programming.guide/random-point-within-circle.html for an explanation of why