forked from JendaPlhak/math_in_python
/
sierpinski_relatives.py
executable file
·55 lines (41 loc) · 1.51 KB
/
sierpinski_relatives.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env python
from affine_transformation import *
def realtives(transforms, rec=8, a=400, title=""):
points = [ PointGroup(square(a)) ]
points = iterReductionCopy( points,
scaling(0.5, 0.5),
transforms,
rec)
drawPoints(points, "Sierpinski_relative_" + title)
if __name__ == '__main__':
a = 400
realtives( [identity(),
translation(a/2, 0),
translation(a/4, a/2)],
a=a,
title="triangle",
)
realtives( [identity(),
translation(a/2, 0),
translation(a/2, a/2)],
a=a,
title="right",
)
realtives( [identity(),
combine([ translation(a/2, 0), rotate( 90, x=3*a/4, y=a/4) ]),
combine([ translation(a/2, a/2), rotate(-90, x=3*a/4, y=3*a/4) ])],
a=a,
title="rotate"
)
realtives( [combine([rotate(-90, x=a/4, y=a/4) ]),
translation(a/2, 0),
combine([ translation(a/2, a/2), rotate(90, x=3*a/4, y=3*a/4) ])],
a=a,
title="pen"
)
realtives( [combine([rotate(180, x=a/4, y=a/4) ]),
translation(a/2, 0),
combine([ translation(a/2, a/2), rotate(180, x=3*a/4, y=3*a/4) ])],
a=a,
title="A"
)