Tuesday, July 28, 2009

Assignment 01B, fianl, Liu

















#######################################################
# Assignment 01B Recursion
# Editted by Liu, Ko-cheng
# Logic:
# Step1: Set up initial conditions
# setup01): Create Biggest and smallest circles
# setup02): Make these two circles tangent
# Step2: Define the principles of how to get the next cirlce tangent with previous two
# Step3: Start the recursion by the loop
###########################################################



import maya.cmds as cmds

#Step1:Define the biggest and smallest circles
BigRadius=30
SmallRadius=2
Minus= BigRadius-SmallRadius

# Create these two circles which are tangent to each other
cmds.circle(c=(0,0,0),r=30)
cmds.circle(c=(0,-28,0),r=2)

#Step2:Generate two circles which follow the tangent princples
#2.1)r1+r2=D
NextRadius=SmallRadius+1
D= NextRadius+SmallRadius
cmds.circle(n="Mcircle",c=(0,-28,0),r=D)

#2.2)offset the outmost circle based on the radius of next circle
cmds.circle(n="Moffset",c=(0,0,0), r=BigRadius-NextRadius)
#2.3)Get the intersection point at the right side and as the center point of the new circle
# which is tangent with previous two circles

inters = cmds.curveIntersect('Mcircle','Moffset')
inters = inters.split()
print inters
inters1 = inters[1:2]
for i in inters1:
u = float(i)
pos1=cmds.pointOnCurve("Mcircle", p=1, pr=u)
myCircle=cmds.circle(c=pos1,r=3)
cmds.delete('Mcircle','Moffset')

#Step3: Loop through it based on previous steps
for i in range(1,BigRadius-3,1):
cmds.circle(n="myOffset"+str(i),c=(0,0,0),r=Minus-i-1)
cmds.rotate
radius=2+i
r1= radius
r2= radius+1
D=r1+r2

cmds.circle(n="mycircle"+str(i),c=pos1,r=D)
cmds.rotate(0,0,20*i,cp=u)
myInters= cmds.curveIntersect('mycircle'+str(i),'myOffset'+str(i))
myInters= myInters.split()
print myInters

myInters= myInters[0:2]
for j in myInters:
u=float(j)
if 4 < pos2="cmds.pointOnCurve(" p="1,pr="u)" mycircle="cmds.circle(c="pos2,r="i+3)" pos1="pos2">

No comments:

Post a Comment