Skip to content

Commit 76bd95f

Browse files
committed
dome template
1 parent e1cbf60 commit 76bd95f

1 file changed

Lines changed: 87 additions & 2 deletions

File tree

  • src/compas_assembly/geometry

src/compas_assembly/geometry/dome.py

Lines changed: 87 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,24 @@
22
from __future__ import absolute_import
33
from __future__ import division
44

5+
from math import cos, sin, pi
6+
from compas.datastructures import Mesh
57
from ._geometry import Geometry
68

79

10+
def geom_dome(ro, theta, phi):
11+
x = ro * sin(theta) * cos(phi)
12+
y = ro * sin(theta) * sin(phi)
13+
z = ro * cos(theta)
14+
point = [x, y, z]
15+
return point
16+
17+
18+
def radius(r_i, r_f, theta_upper, theta_lower, theta):
19+
r = r_i + (r_f - r_i) / (theta_upper - theta_lower) * theta
20+
return r
21+
22+
823
class Dome(Geometry):
924
"""Create voussoirs for a spherical dome geometry with given rise and span.
1025
@@ -13,8 +28,27 @@ class Dome(Geometry):
1328
1429
"""
1530

16-
def __init__(self):
31+
def __init__(
32+
self,
33+
meridians=40,
34+
hoops=20,
35+
oculus=pi / 30,
36+
spring=pi / 2,
37+
r_i=3.9,
38+
r_f=3.2,
39+
R_i=4,
40+
R_f=3.5,
41+
):
1742
super(Dome, self).__init__()
43+
self.meridians = meridians
44+
self.hoops = hoops
45+
self.oculus = oculus
46+
self.spring = spring
47+
48+
self.r_i = r_i
49+
self.r_f = r_f
50+
self.R_i = R_i
51+
self.R_f = R_f
1852

1953
def blocks(self):
2054
"""Compute the blocks.
@@ -30,4 +64,55 @@ def blocks(self):
3064
to create an assembly "from geometry".
3165
3266
"""
33-
pass
67+
step_phi = (2 * pi - 0) / (2 * self.meridians)
68+
phi_delta = (2 * pi - 0) / self.meridians
69+
theta_delta = (self.spring - self.oculus) / self.hoops
70+
71+
phi = []
72+
for i in range(self.meridians + 1):
73+
phi.append(0 + i * phi_delta)
74+
75+
theta = []
76+
for i in range(self.hoops + 1):
77+
theta.append(self.oculus + i * theta_delta)
78+
79+
blocks = []
80+
81+
for j in range(self.meridians):
82+
for i in range(self.hoops):
83+
if i % 2 == 0:
84+
step = 0
85+
else:
86+
step = step_phi
87+
88+
vertices = []
89+
90+
r = radius(self.r_i, self.r_f, self.spring, self.oculus, theta[i])
91+
R = radius(self.R_i, self.R_f, self.spring, self.oculus, theta[i])
92+
93+
vertices.append(geom_dome(r, theta[i], phi[j] + step))
94+
vertices.append(geom_dome(R, theta[i], phi[j] + step))
95+
vertices.append(geom_dome(R, theta[i], phi[j + 1] + step))
96+
vertices.append(geom_dome(r, theta[i], phi[j + 1] + step))
97+
98+
r = radius(self.r_i, self.r_f, self.spring, self.oculus, theta[i + 1])
99+
R = radius(self.R_i, self.R_f, self.spring, self.oculus, theta[i + 1])
100+
101+
vertices.append(geom_dome(r, theta[i + 1], phi[j] + step))
102+
vertices.append(geom_dome(R, theta[i + 1], phi[j] + step))
103+
vertices.append(geom_dome(R, theta[i + 1], phi[j + 1] + step))
104+
vertices.append(geom_dome(r, theta[i + 1], phi[j + 1] + step))
105+
106+
faces = [
107+
[0, 4, 5, 1],
108+
[1, 5, 6, 2],
109+
[0, 1, 2, 3],
110+
[0, 3, 7, 4],
111+
[5, 4, 7, 6],
112+
[6, 7, 3, 2],
113+
]
114+
115+
block = Mesh.from_vertices_and_faces(vertices, faces)
116+
blocks.append(block)
117+
118+
return blocks

0 commit comments

Comments
 (0)