View Full Version : Distribute particles evenly on a disk.
Cycone 11042009, 12: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....
So:
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?
Thanks!


cbamber85
11072009, 08: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.
Cycone
11072009, 11:49 AM
Hey, Thanks for your reply.
Attached a quick sketch.
http://www.blisstic.com/circlePattern.jpg
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).
thanks!
cbamber85
11082009, 07: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 'inplace', 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.
Cycone
11092009, 09:45 AM
Hi Camden!,
Superb, this is the trick!
Thanks a lot!
cbamber85
11092009, 10: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
11092009, 10: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.
vBulletin v3.0.5, Copyright ©20002015, Jelsoft Enterprises Ltd.