Lost Adventurer, Aleks Kirilenko (3D)
LC #42 Pipers Alley

View Full Version : Distribute particles evenly on a disk.

11-04-2009, 01:51 PM
Hi All,
Quick question: I'm working on a particle setup where I have to distribute particles evenly over a disk like surface. The problem is in the fact the amount of particles positioned needs to change based on the perimeter (the goalV value). It has to become a kind of tiling pattern....
In row #1 of for example 20 rows I have 8 particles, row #2 has 12 particles, row #3 has 18 particles etc. Does anyone have an idea of how to approach this?


11-07-2009, 09:57 AM
Could you post a quick sketch of what you want? I'm pretty sure I know what you mean, but would like to make sure.

11-07-2009, 12:49 PM
Hey, Thanks for your reply.
Attached a quick sketch.
I'm going to need more circles, but that's just a matter off splitting up the V value a bit more. The problem is in the relation between radius and amount of particles (the bigger de radius, the more particles).


11-08-2009, 08:30 AM
import maya.cmds as m
from math import *

particles = []
centre = [0, 0, 0]
particleWidth = 0.05
radius = 0.5
for row in range(1, 20, 1):
numPnts = int((2 * (radius * row) * pi) / particleWidth)
if numPnts:
angleGap = (2 * pi) / numPnts
for i in range(numPnts):
x = centre[0] + ((radius * row) * cos(i * angleGap))
y = centre[1]
z = centre[2] + ((radius * row) * sin(i * angleGap))
particles.append((x, y, z))

m.particle(p = particles)

This script should help you, I don't know what system you're using to generate the input data, but you should be patch it into anything. If it needs to be an expression, it's all convertable to MEL easily enough.

If the disk the particles lie on, is of an arbitrary rotation and the particles need to be calculated 'in-place', it will probably be easiest to create a locator (or anything else with a transform), then multiply the final coordinate vector by its transformation matrix.

11-09-2009, 10:45 AM
Hi Camden!,
Superb, this is the trick!
Thanks a lot!

11-09-2009, 11:47 AM
A friend at work pointed out that it gets VERY slow when dealing with large sums of particles, I'm not sure how you're using this, but it could be tuned for the implementation to be much quicker. I'm not a fan of Python when it comes to anything even remotely heavy.

CGTalk Moderation
11-09-2009, 11:47 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.