/[cvs]/fract/koch.py
ViewVC logotype

Annotation of /fract/koch.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (hide annotations) (vendor branch)
Sat Feb 24 15:57:15 2001 UTC (23 years, 2 months ago) by teddy
Branch: masse, MAIN
CVS Tags: start, HEAD
Changes since 1.1: +0 -0 lines
File MIME type: text/x-python
Imported sources (take 2)

1 teddy 1.1 #!/usr/bin/python
2    
3     base = [(142,142), (426,142), (285,389), (142,142)]
4    
5     def normal(kord1,kord2):
6     x1,y1= kord1
7     x2,y2= kord2
8     x3= 0.5*(x2-x1+(y2-y1)*pow(3,0.5))+x1
9     y3= 0.5*(y2-y1-(x2-x1)*pow(3,0.5))+y1
10     return x3, y3
11    
12     def transform(inbase):
13     outbase= []
14     for it in range(len(inbase)-1):
15     (x1,y1)= inbase[it]
16     (x2,y2)= inbase[it+1]
17     xplus, yplus= (x2-x1)/3, (y2-y1)/3
18     outbase.append(inbase[it])
19     outbase.append((x1+xplus,y1+yplus))
20     outbase.append(normal((x1+xplus,y1+yplus),(x1+xplus*2,y1+yplus*2)))
21     outbase.append((x1+xplus*2,y1+yplus*2))
22     outbase.append(inbase[-1])
23     return outbase
24    
25     def draw(inbase):
26     print "#PLOT 2"
27     print "o"
28     print "e"
29     for it in range(len(inbase)-1):
30     x1,y1= inbase[it]
31     x2,y2= inbase[it+1]
32     print "l", x1, y1, x2, y2
33     print "x"
34    
35     for i in range(5):
36     base= transform(base)
37    
38     draw(base)

root@recompile.se
ViewVC Help
Powered by ViewVC 1.1.26