Accept Merge Request #321: (wqy/region -> master)

Merge Request: Fix slope calculation

Created By: @王琼钰
Accepted By: @王琼钰
URL: https://tjwater.coding.net/p/tjwatercloud/d/TJWaterServer/git/merge/321?initial=true
This commit is contained in:
王琼钰
2023-09-16 15:48:33 +08:00
committed by Coding

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)