Fix slope calculation

This commit is contained in:
wqy
2023-09-16 15:47:50 +08:00
parent 6c3e500eb3
commit cdb37db2a2

View File

@@ -142,7 +142,10 @@ def _angle_of_node_link(node: str, link: str, nodes, links) -> float:
n2 = links[link]['node1'] if n1 == links[link]['node2'] else links[link]['node2']
x1, y1 = nodes[n1]['x'], nodes[n1]['y']
x2, y2 = nodes[n2]['x'], nodes[n2]['y']
v = _normal((x2 - x1, y2 - y1))
if y1 == y2:
v = ((x2 - x1) / abs(x2 - x1), 0.0)
else:
v = _normal((x2 - x1, y2 - y1))
return _angle(v)