Showing posts with label Masha. Show all posts
Showing posts with label Masha. Show all posts

Sunday, July 12, 2009

Masha - Assignment 03B



import maya.cmds as cmds
import random
import math

def magnitude (v):
x= v[0]
y= v[1]
z= v[2]
m = math.sqrt ((x*x)+(y*y)+(z*z))
return m

def distance (p1, p2):
#substract both vectors
x1 = p1[0]
y1 = p1[1]
z1 = p1[2]
x2 = p2[0]
y2 = p2[1]
z2 = p2[2]
x = x1-x2
y = y1-y2
z = z1-z2
m = magnitude ([x,y,z])
return m

def unit(v):
#returns unit vector of v
#first get magnitude
m = magnitude(v)
x = v[0]
y = v[1]
z = v[2]
#devide each element by magnitude
x = x/m
y = y/m
z = z/m
vu = [x,y,z]
return vu

def move (v, amount):
"Move by certaine amount in directio v"
x = v[0]
y = v[1]
z = v[2]
x = x+amount
y = y+amount
z = z+amount
newP = [x,y,z]
return amount

def vectorBetweenPoints (p1, p2):
"Returns vector between p1 and p2"
#substract both vectors
x1 = p1[0]
y1 = p1[1]
z1 = p1[2]
x2 = p2[0]
y2 = p2[1]
z2 = p2[2]
x = x1-x2
y = y1-y2
z = z1-z2
newV = [x,y,z]
return newV

def moveVert (allCvs):
selLoc = cmds.filterExpand (sm = 22)
xs = 0
ys = 0
zs = 0
for i in allCvs:
pos = cmds.pointPosition(i)

posLoc = cmds.pointPosition (selLoc)
dd = distance ([centerX, centerY, centerZ], posLoc)
print dd
cmds.polyExtrudeVertex( l =dd, w=3, d=4 )


def moveVertice (allCvs):
selLoc = cmds.filterExpand (sm = 22)
allCvs1 = cmds.ls("nurbsPlane2.cv[:][:]", fl=1)
#d=1000
dist =1000
allDist =[]
print selLoc
for i in allCvs1:
pos = cmds.pointPosition(i)
for j in selLoc:
posLoc = cmds.pointPosition (j)
dd = distance (pos, posLoc)
if dd

Sunday, July 5, 2009

Assignment_03A






import maya.cmds as cmds
import random
import math

def moveVertRandomly (allCvs, minimum, maximum):
if minimum>= maximum:
print "Find new variables!"
else:
for i in allCvs:
rx = random.uniform(minimum, maximum)
ry = random.uniform(minimum, maximum)
rz = random.uniform(minimum, maximum)
cmds.move (rx,ry,rz,i,r=1)

def moveVerticeRandomly (allCvs, minimum, maximum, x,y,z):
if minimum>= maximum:
print "Find new variables!"
else:
for i in allCvs:

z = random.uniform(minimum, maximum)
cmds.move (x,y,z,i,r=1)

def extrudeFacesRandomly(allFaces, minimum, maximum):
if minimum>= maximum:
print "Find new variables!"
else:
for i in allFaces:
rz = random.uniform(minimum, maximum)
cmds.polyExtrudeFacet(i, ltz = rz)

def polygonVertices (allVert, minimum, maximum):
if minimum>= maximum:
print "Find new variables!"
else:
for i in allVert:
rx = random.uniform(minimum, maximum)
ry = random.uniform(minimum, maximum)
rz = random.uniform(minimum, maximum)
cmds.move (rx,ry,rz,i,r=1)


allCvs = cmds.ls("curve1.cv[:]", fl=1)
moveVertRandomly (allCvs, 0, 10)

allCvs1 = cmds.ls("nurbsPlane1.cv[:][:]", fl=1)
moveVerticeRandomly (allCvs, 0, 10, 0,0,5)

extrudeFacesRandomly(allFaces, 0, 5)
allFaces = cmds.ls ("pPlane1.f[:]", fl = 1)

allVert = cmds.ls("pPlane2.vtx[:]", fl=1)
polygonVertices (allVert, 0, 5)

Monday, June 15, 2009

week05_assignment_Masha















import maya.cmds as cmds
import random
import math
from random import *
from math import *


def Curve(numPoints):
#create an empty list to store the point
points = []
#loop and gather point information
for i in range (1, numPoints, 1):
amplitude = randint(0,3)
amp = randint(0,3)
#function for the spiral curve
a=i*0.3
x = cos(a)*amplitude
y = 0

z =-i
myPoint = (x,y,z)
#store the point in the list
points.append(myPoint)

#create the curve
myCurve = cmds.curve (d = 3, p=points) #degree 3
return myCurve

def Curve2(numPoints):
#create an empty list to store the point
points = []
#loop and gather point information
for i in range (1, numPoints, 1):
amplitude = randint(0,3)
amp = randint(0,3)
#function for the spiral curve
a = i*0.3
x = sin(a)*amplitude
y = i
z = amp*4
myPoint = (x,y,z)
#store the point in the list
points.append(myPoint)

#create the curve
myCurve = cmds.curve (d = 3, p=points) #degree 3
return myCurve

def tubulize (path, radius, tubeSections = 8):
"Function to create tubes out of curve"
#position on end of curve where i will put the circle profile
pos = cmds.pointOnCurve (path, position = 1, pr = 0.001, top = 1)
#get tangent of this point
tan = cmds.pointOnCurve (path, tangent = 1, pr = 0.001, top = 1)

#create the profile circle
profile = cmds.circle (c=pos, r = radius, normal = tan, s= tubeSections, ch = 1)
#center of circle pivot
cmds.xform (cp = 1)
#extrude the circle along path
tube =cmds.extrude (profile [0], path, ucp =1, upn=1,et=1,rb=1,dl=3,ch=1, n ="spiralTube" )
#returne values
return [tube[0],radius,profile]

radius = 6
numCurves = 200
myCrv = []
y1 = 0
angle = 360/numCurves
x1 = radius
z1 = 10

for i in range (0, numCurves+1, 1):
rad = randint(3,8)
r = rad/10.0

if i%2 == 0:
curve1 = Curve(50)

else:
curve1 = Curve2(50)

#cmds.move (0,0,10, curve1)
#cmds.rotate( 0, 0, 90, curve1, pivot=(0,0,0))
#curve1= Curve(30)
cmds.rotate( 0, 0, angle*i+i,curve1, pivot=(x1,y1,z1))
crv1 = tubulize (curve1, r, tubeSections = 8)
#cmds.move (j,j,0, curve1)
myCrv.append (curve1)

Sunday, June 7, 2009

02B - Masha - Loft












import maya.cmds as cmds
from random import *
from math import *

#numPoints = 60
numCurves = 40.0
radius = 10

def Curve(numPoints):

#create an empty list to store the point
points = []
#loop and gather point information
for i in range (1, numPoints, 1):
amplitude = 1
#function for the spiral curve
x = sin(i)*amplitude
y = 0
z = i
myPoint = (x,y,z)
#store the point in the list
points.append(myPoint)

#create the curve
myCurve = cmds.curve (d = 3, p=points) #degree 3
return myCurve

def Curve2(numPoints):

#create an empty list to store the point
points = []
#loop and gather point information
for i in range (1, numPoints, 1):
amplitude = 1
#function for the spiral curve
x = (cos(i)*amplitude)
y = 0
z = i
myPoint = (x,y,z)
#store the point in the list
points.append(myPoint)

#create the curve
myCurve = cmds.curve (d = 3, p=points) #degree 3
return myCurve

myCrv = []
y1 = 0
angle = 360/numCurves
x1 = radius
z1 = 10
for i in range (0, numCurves+1, 1):
if i%2 == 0:
curve1 = Curve(50)
else:
curve1 = Curve2(50)
#cmds.move (0,0,10, curve1)
#cmds.rotate( 0, 0, 90, curve1, pivot=(0,0,0))
cmds.rotate( 0, 0, angle*i,curve1, pivot=(x1,y1,z1))

#cmds.move (j,j,0, curve1)
myCrv.append (curve1)
print myCrv

cmds.loft(myCrv)

Sunday, May 24, 2009



import maya.cmds as cmds
from math import *
from random import *

radius = 50
numCirc = 10
amplitude = 2

def curves(amplitude):
numPoints = 10
points = []
#loop and gather point information
for i in range (1, numPoints, 1):
#function for the spiral curve
x = sin(i)*amplitude
y = cos(i)*amplitude
z = i*(i+1)
myPoint = (x,y,z)
#store the point in the list
points.append(myPoint)

#create the curve
myCurve = cmds.curve (d = 3, p=points) #degree 3
return myCurve

numCol = 10
numRows = 10

def array(numCol):
#create empty list of curvs
numCurvs = []
for j in range (0, 360/numCirc, 1):
#create curve and then rotate
crv = curves (j)
cmds.rotate( 0, 10*j, 0, crv )
#store the point in the list
numCurvs.append (crv)
cmds.select (numCurvs)# select the number of created curvs
cmds.group (numCurvs, r=True)

#loop which made copies of created curvs in 2 directions
for m in range (0, numRows, 1):
for n in range (0, numCol, 1):
ar = array (1)
s = randint(0,3)
cmds.move (n*200, 0, m*200)
#change the size of group of curvs
cmds.scale (s,s,s)

squareINsquare (3)

Friday, May 15, 2009

# create cylinder with nonuniform density of points

import maya.cmds as cmds
from math import *

from random import *

radius = 10
numCirc = 10

for n in range (0, numCirc, 1):
y = n #Number Of Elements By Y Axis
for i in range (0, 36, 1):
cmds.rotate( 0, 10*i, 0, pivot=(1, 0, 0) )
x = radius #create circle
z = randint (0,2)
myPoint = [x, y, z]
cmds.spaceLocator (p
= myPoint)

Thursday, May 14, 2009

numColumns = 10
numRows = 10
numHeights = 10

for k in range (0, numHeights,1):
z = k
for i in range (0, numColumns,1):
x=i
print i
for j in range(0,numRows, 1):
y = j

myPoint = [x,y,z]
cmds.spaceLocator (p=myPoint)

Saturday, April 25, 2009