top of page

#maya/scripts/gen_points1.py
import random
import math

#----------------------------------------------
def cubic(num, side):
   data = []
   n = 0
   while n < num:
       x = random.uniform(-side/2, side/2)
       y = random.uniform(-side/2, side/2)
       z = random.uniform(-side/2, side/2)
       data.append( (x,y,z) )
       n = n + 1
   return data
#----------------------------------------------
def box(num, width, height, depth):
   data = []
   n = 0
   while n < num:
       x = random.uniform(-width/2, width/2)
       y = random.uniform(-height/2, height/2)
       z = random.uniform(-depth/2, depth/2)
       data.append( (x,y,z) )
       n = n + 1
   return data
#----------------------------------------------
def spherical(num, radius):
   data = []
   n = 0
   while n < num:
       x = random.uniform(-radius, radius)
       y = random.uniform(-radius, radius)
       z = random.uniform(-radius, radius)
       dist = math.sqrt(x * x + y * y + z * z)
       if dist <= radius:
           data.append( (x,y,z) )
           n = n + 1
   return data
#----------------------------------------------    
def disk(num, radius):
   data = []
   n = 0
   while n < num:
       x = random.uniform(-radius, radius)
       y = 0
       z = random.uniform(-radius, radius)
       dist = math.sqrt(x * x + z * z)
       if dist <= radius:
           data.append( (x,y,z) )
           n = n + 1
   return data
#----------------------------------------------    
def cylinder(num, radius, height):    
   data = []
   n = 0
   while n < num:
       x = random.uniform(-radius, radius)
       z = random.uniform(-radius, radius)
       dist = math.sqrt(x * x + z * z)
       #----------------------------
       y = random.uniform(0, height)
       #rad_at_random_height = ??  y  ??
       #----------------------------
       if dist <= radius:
           data.append( (x,y,z) )
           n = n + 1
   return data
#----------------------------------------------    
def cone(num, radius, height):    
   data = []
   n = 0
   while n < num:
       x = random.uniform(-radius, radius)
       z = random.uniform(-radius, radius)
       dist = math.sqrt(x * x + z * z)
       #----------------------------
       y = random.uniform(0, height)
       rad_at_random_height = radius * (1 - y/height)
       #----------------------------
       if dist <= rad_at_random_height:
           data.append( (x,y,z) )
           n = n + 1
   return data
#---------------------------------------------------------
def torous(num, maxRadius, minRadius):
   data = []
   n = 0
   midRing = (maxRadius + minRadius)/2
   yRadius = (maxRadius - minRadius)/2
   while n < num:
       x = random.uniform(-maxRadius,maxRadius)
       y = random.uniform(-yRadius,yRadius)
       z = random.uniform(-maxRadius,maxRadius)
       vectorCheck = math.sqrt(((midRing-math.sqrt((x**2)+(z**2)))**2)+y**2)
       if vectorCheck <= yRadius:
           data.append( (x,y,z) )    
           n += 1
   return data
#---------------------------------------------------------

def ring(num, innerR, outerR):
   data = []
   n = 0
   while n < num:
       x = random.uniform(-outerR, outerR)
       y = 0
       z = random.uniform(-outerR, outerR)
       dist = math.sqrt(x * x + z * z)
       if dist >= innerR and dist <= outerR:
           data.append( (x,y,z) )
           n = n + 1
   return data

#------------------------------------------------------------

   
   
   

 
   
   
   
   

bottom of page