From cdb37db2a2cf4d9fa5dc4d3a9a65d51f6ae544bd Mon Sep 17 00:00:00 2001 From: wqy Date: Sat, 16 Sep 2023 15:47:50 +0800 Subject: [PATCH] Fix slope calculation --- api/s32_region_util.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/api/s32_region_util.py b/api/s32_region_util.py index 3830776..d95862b 100644 --- a/api/s32_region_util.py +++ b/api/s32_region_util.py @@ -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)