-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathground.py
More file actions
203 lines (164 loc) · 7.97 KB
/
ground.py
File metadata and controls
203 lines (164 loc) · 7.97 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
import shared
# Temel ölçüler
house_width = 4 # X yönü (metre)
house_length = 3 # Y yönü (metre)
veranda_length = 2
veranda_front_y = house_length + veranda_length
post_height = 3.5
def draw_ground(ax, slope_deg, max_leg_height):
# Eğim hesaplama
slope_rad = shared.np.radians(slope_deg)
height_diff = shared.np.tan(slope_rad) * veranda_front_y # Zemindeki yükseklik farkı
force_leg_height = slope_deg * 10
if max_leg_height < force_leg_height:
max_leg_height = force_leg_height / 100
else:
max_leg_height = max_leg_height / 100
# Alan sınırını çizen fonksiyon (zeminde)
z_offset = max_leg_height + 0.05
x_positions = [0, 1.5, 3, 4]
# Her y noktasına göre ayak yüksekliği
def leg_height(y):
return max_leg_height - (y / veranda_front_y) * height_diff
def draw_area_outline(ax, x0, y0, width, length, color='red', z_offset=z_offset):
corners = [
(x0, y0),
(x0 + width, y0),
(x0 + width, y0 + length),
(x0, y0 + length),
(x0, y0)
]
xs, ys = zip(*corners)
zs = [z_offset] * len(xs) # z koordinatını yükseltmek için z_offset kullanıyoruz
ax.plot(xs, ys, zs, linestyle='dashed', color=color, linewidth=1.5, zorder=50)
# Direk çizen fonksiyon
def draw_post(ax, x, y, height, color='sienna', zorder=-1):
ax.plot([x, x], [y, y], [0, height], color=color, linewidth=4, zorder=zorder)
# Direğe paralel yazı fonksiyonu
def draw_post_label(ax, x, y, height, text="10x10cm", color='sienna', zorder=-1):
ax.text(x, y, height + 0.3, text, fontsize=12, color=color,
ha='center', va='bottom', rotation=90, zorder=zorder)
# Direkler arasındaki mesafeyi hesaplayan fonksiyon
def calculate_distance(x1, y1, x2, y2):
return shared.np.sqrt((x2 - x1)**2 + (y2 - y1)**2)
if slope_deg > 0:
fig_title = shared.txt("text_sloping_ground", value=slope_deg)
else:
fig_title = shared.txt("text_flat_ground")
ax.set_title(fig_title, fontsize=14)
try:
fig.canvas.manager.set_window_title(fig_title)
except Exception:
pass
platform_z = max_leg_height # Tüm platform yüksekliği sabit
# Platform köşeleri
platform_corners = [
[0, 0, platform_z],
[house_width, 0, platform_z],
[house_width, veranda_front_y, platform_z],
[0, veranda_front_y, platform_z]
]
# Platform yüzeyi
ax.add_collection3d(shared.Poly3DCollection([platform_corners], facecolors='lightgray', edgecolors='black', zorder=999))
# Zemin köşeleri
ground_corners = [
[0, 0, platform_z - leg_height(0)],
[house_width, 0, platform_z - leg_height(0)],
[house_width, veranda_front_y, platform_z - leg_height(veranda_front_y)],
[0, veranda_front_y, platform_z - leg_height(veranda_front_y)]
]
# Kenar yüzeyleri (dört yan)
for i in range(4):
ni = (i + 1) % 4
verts = [ground_corners[i], ground_corners[ni], platform_corners[ni], platform_corners[i]]
ax.add_collection3d(shared.Poly3DCollection([verts], facecolors='peru', edgecolors='black', alpha=0.9, zorder=999))
# Ev Arka taraf (Y = 0) - 4 direk eşit aralıklarla
for i, x in enumerate(x_positions):
draw_post(ax, x, 0, post_height)
if i < len(x_positions) - 1:
distance = calculate_distance(x_positions[i], 0, x_positions[i+1], 0)
ax.text((x + x_positions[i+1]) / 2, -0.2, max_leg_height + 0.5, f"{distance:.2f}m", color='black', fontsize=8, ha='center')
# X=0 düzlemindeki direklerin Y koordinatlarını belirleyelim
y_positions_x0 = [0, house_length / 2, house_length, veranda_front_y]
for i, y in enumerate(y_positions_x0):
draw_post(ax, 0, y, post_height) # X=0, Y farklı konumlar
if i < len(y_positions_x0) - 1:
# Y=0 düzlemindeki direkler arasındaki mesafeyi hesapla
distance = calculate_distance(0, y_positions_x0[i], 0, y_positions_x0[i+1])
ax.text(0.2, (y + y_positions_x0[i+1]) / 2, max_leg_height + 1, f"{distance:.2f}m", color='black', fontsize=8, ha='center')
# Ev Orta Sırası (Y = house_length / 2)
# Sağ Taraf
draw_post(ax, 4, house_length / 2, post_height, zorder=10)
# Orta Zemin Altı
draw_post(ax, 1.5, house_length / 2, max_leg_height, color='dimgray', zorder=10)
draw_post(ax, 3, house_length / 2, max_leg_height, color='dimgray', zorder=10)
# Sol Taraf
draw_post(ax, 0, house_length / 2, post_height, zorder=10)
# Ev Ön taraf (Y = house_length) - 4 direk
for i, x in enumerate(x_positions):
draw_post(ax, x, house_length, post_height, zorder=10)
if i < len(x_positions) - 1:
distance = calculate_distance(x_positions[i], house_length, x_positions[i+1], house_length)
ax.text((x + x_positions[i+1]) / 2, house_length + 0.3, 0.9, f"{distance:.2f}m", color='black', fontsize=8, ha='center')
# Veranda Orta Zemin Altı (Y = veranda_front_y -1 ) - 4 direk
for i, x in enumerate(x_positions):
draw_post(ax, x, veranda_front_y - 1, max_leg_height, color='dimgray', zorder=10)
# Veranda Ön taraf (Y = veranda_front_y) - 4 direk
for i, x in enumerate(x_positions):
draw_post(ax, x, veranda_front_y, post_height, zorder=10)
# Alt desteği (zemin ile platform arası hacim)
bottom_support_faces = [
[ground_corners[0], ground_corners[1], platform_corners[1], platform_corners[0]],
[ground_corners[1], ground_corners[2], platform_corners[2], platform_corners[1]],
[ground_corners[2], ground_corners[3], platform_corners[3], platform_corners[2]],
[ground_corners[3], ground_corners[0], platform_corners[0], platform_corners[3]],
]
for face in bottom_support_faces:
ax.add_collection3d(shared.Poly3DCollection([face], facecolors='saddlebrown', edgecolors='black', alpha=0.6))
# Bilgilendirme - En yüksek ayak
max_leg_x = house_width / 2
max_leg_y = 0.8
max_leg_z = platform_z - 0.2
ax.text(
max_leg_x, max_leg_y, max_leg_z,
shared.txt("text_long_leg", value=max_leg_height),
fontsize=9, ha='center', zorder=10
)
# En kısa ayak
short_leg_x = house_width / 0.8
short_leg_y = veranda_front_y + -0.3
short_leg_z = platform_z - leg_height(veranda_front_y) - 0.5
ax.text(
short_leg_x, short_leg_y, short_leg_z,
shared.txt("text_short_leg", value=(max_leg_height - height_diff) * 100),
fontsize=9, ha='center', zorder=20
)
# Evin zemin alanı çerçevesi (z ekseninde yukarı kaydırılmış)
draw_area_outline(ax, x0=0, y0=0, width=house_width, length=house_length, color='red')
house_text_x = 2 # 2.5 ile 4 arası orta nokta
house_text_y = house_length - 1.5 # biraz aşağıda
ax.text(house_text_x, house_text_y, z_offset, shared.txt("text_room"), color='red', fontsize=12, ha='center', zorder=999)
# Veranda zemin alanı çerçevesi (z ekseninde yukarı kaydırılmış)
draw_area_outline(ax, x0=0, y0=house_length, width=house_width, length=veranda_length, color='purple')
veranda_text_x = 2 # 2.5 ile 4 arası orta nokta
veranda_text_y = veranda_front_y - 1.25 # biraz aşağıda
ax.text(veranda_text_x, veranda_text_y, z_offset, shared.txt("text_veranda"), color='purple', fontsize=12, ha='center', zorder=999)
draw_post_label(ax, -1, 0, post_height + 0.5, zorder=10)
draw_post_label(ax, -0.5, 0.5, post_height + 0.5, zorder=10, color='dimgray')
# Eksenler ve görünüm
ax.set_xlim(-1, 5.5)
ax.set_ylim(0, 5.5)
ax.set_zlim(0, 5.5)
ax.set_xlabel(shared.txt("text_axis_x"))
ax.set_ylabel(shared.txt("text_axis_y"))
ax.set_zlabel(shared.txt("text_axis_z"))
# Kenar boşluklarını sıfıra yaklaştır
ax.margins(0)
# Figure içi boşlukları kaldır
ax.figure.subplots_adjust(
left=0.0,
right=1.0,
bottom=0.0,
top=0.9
)
ax.view_init(elev=50, azim=55)