##############################################
# File: Xiang/Ccurve0.py
# C-curve page 52
#
from math import * # for sqrt() and cos(), sin()
import math
ANGLE = math.pi/4 # angle=45 in radians
def ccurve (x,y,len,alpha,n):
print " x= ",x," y= ",y," len= ",len," alpha= ",alpha," n= ", n
if n > 0 :
len = len / sqrt(2)
ccurve(x,y,len,alpha + ANGLE,n-1)
x = x + len * cos(alpha + ANGLE)
y = y + len * sin(alpha + ANGLE)
ccurve(x,y,len,alpha-ANGLE,n-1)
else:
x1= x
y1= y
x2= x + len * cos(alpha)
y2= y + len * sin(alpha)
print " x1= ",x," y1= ",y1," x2= ",x2," y2= ",y2
#linea=line(Point(x,y),Point(x2,y2))
#linea.draw(win)
def main():
ccurve(100,100,30,0,3)
main()