Particles Script

#particles.py
  
import random
import os.path
import math
import maya.cmds as cmds
  
#----------------------------------------------------
def Dome(num_particles, inner_rad, outer_rad):
    positions = []
    counter = 0
    while counter < num_particles:
        x = random.uniform(-float(outer_rad), float(outer_rad))
        y = random.uniform(0, float(outer_rad))
        z = random.uniform(-float(outer_rad), float(outer_rad))
        dist = math.sqrt(x*x + y*y + z*z)
        if dist <= outer_rad and dist >= inner_rad:
            positions.append( (x,y,z) )
            counter += 1
    return cmds.particle(p=positions)
#----------------------------------------------------
def Shell(num_particles, inner_rad, outer_rad, height, depth):
    positions = []
    counter = 0
    while counter < num_particles:
        x = random.uniform(-float(outer_rad), float(outer_rad))
        y = random.uniform(-float(outer_rad), float(outer_rad))
        z = random.uniform(-float(outer_rad), float(outer_rad))
        dist = math.sqrt(x*x + y*y + z*z)
        if dist <= outer_rad and dist >= inner_rad:
            if y <= height and y >= depth:
                positions.append( (x,y,z) )
                counter += 1
    return cmds.particle(p=positions)
#----------------------------------------------------
def Wavey(num_particles, radius, frequency, thickness):
    positions = []
    counter = 0
    while counter < num_particles:  
        x = random.uniform(-radius, radius)
        y = math.sin(x * frequency) * thickness
        z = random.uniform(-radius, radius)
        dist = math.sqrt(x*x + z*z)
        if dist <= radius:
            positions.append( (x,y,z) )
            counter += 1
    return cmds.particle(p=positions)[0]
#----------------------------------------------------
def Tubular(num_particles, radius, height, thickness):
    positions = []
    counter = 0
    while counter < num_particles: 
        x = random.uniform(-radius, radius)
        y = random.uniform(0, height) 
        z = random.uniform(-radius, radius)
        dist = math.sqrt(x*x + z*z)
        if dist <= radius and dist >= radius - thickness:
            positions.append( (x,y,z) )
            counter += 1
    return cmds.particle(p=positions)[0]
#----------------------------------------------------