aboutsummaryrefslogtreecommitdiff
path: root/coord.py
diff options
context:
space:
mode:
Diffstat (limited to 'coord.py')
-rwxr-xr-xcoord.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/coord.py b/coord.py
new file mode 100755
index 0000000..6fe33f9
--- /dev/null
+++ b/coord.py
@@ -0,0 +1,32 @@
1#!/usr/bin/python
2
3from math import sqrt, sin, cos
4
5phi = (1.0+sqrt(5.0))/2.0
6
7def projcoord(P, alpha, beta):
8 x, y, z = P
9 xnew = x*cos(alpha) + y*sin(alpha)
10 ynew = x*sin(alpha)*sin(beta) - y*cos(alpha)*sin(beta) + z*cos(beta)
11 return xnew, ynew
12
13def printtikz(shape, alpha, beta):
14 for i in range(len(shape)):
15 x, y = projcoord(shape[i], alpha, beta)
16 print("\coordinate (P" + str(i) + ") at (" + str(x) + ", " + str(y) + ");")
17
18tetrahedron = [(1,1,1), (1,-1,-1), (-1,1,-1), (-1,-1,1)]
19
20octahedron = [(1,0,0), (-1,0,0), (0,1,0), (0,-1,0), (0,0,1), (0,0,-1)]
21
22cube = [(1,1,1), (1,1,-1), (1,-1,1), (1,-1,-1), (-1,1,1), (-1,1,-1), (-1,-1,1), (-1,-1,-1)]
23
24dodecahedron = cube + [(0,1/phi,phi), (0,1/phi,-phi), (0,-1/phi,phi), (0,-1/phi,-phi),
25 (1/phi,phi,0), (1/phi,-phi,0), (-1/phi,phi,0), (-1/phi,-phi,0),
26 (phi,0,1/phi), (-phi,0,1/phi), (phi,0,-1/phi), (-phi,0,-1/phi)]
27
28icosahedron = [(0,1,phi), (0,1,-phi), (0,-1,phi), (0,-1,-phi),
29 (1,phi,0), (1,-phi,0), (-1,phi,0), (-1,-phi,0),
30 (phi,0,1), (-phi,0,1), (phi,0,-1), (-phi,0,-1)]
31
32printtikz(icosahedron, 0.2, 0.2)

Generated with cgit - Back to sebastiano.tronto.net