GRASP Python (16)
GRASP Python (16)
analyze_structure)
def redraw_structure(self):
"""Redraw the structure with all components"""
self.ax.clear()
# Draw nodes
for node_id, node in self.nodes.items():
self.ax.plot(node['x'], node['y'], 'bo')
self.ax.text(node['x'], node['y'], f'N{node_id}', color='blue')
# Draw forces
if node_id in self.forces:
fx = self.forces[node_id]['fx']
fy = self.forces[node_id]['fy']
self.ax.arrow(node['x'], node['y'], fx/1000, fy/1000,
head_width=0.2, head_length=0.3, fc='red',
ec='red')
# Draw supports
if node_id in self.supports:
support_type = self.supports[node_id]
if support_type == 'fixed':
self.draw_fixed_support(node['x'], node['y'])
elif support_type == 'pinned':
self.draw_pinned_support(node['x'], node['y'])
elif support_type == 'roller':
self.draw_roller_support(node['x'], node['y'])
# Draw elements
for elem_id, elem in self.elements.items():
node1 = self.nodes[elem['nodes'][0]]
node2 = self.nodes[elem['nodes'][1]]
P a g e 2 | 62