MCPcopy Index your code
hub / github.com/SLiCAP/SLiCAP_python / _on_segment

Function _on_segment

SLiCAP/schematic/connectivity.py:13–25  ·  view source on GitHub ↗

True if q lies on the axis-aligned segment p1→p2 (inclusive endpoints).

(p1: QPointF, p2: QPointF, q: QPointF)

Source from the content-addressed store, hash-verified

11
12
13def _on_segment(p1: QPointF, p2: QPointF, q: QPointF) -> bool:
14 """True if q lies on the axis-aligned segment p1→p2 (inclusive endpoints)."""
15 if abs(p1.x() - p2.x()) < _TOL: # vertical
16 if abs(q.x() - p1.x()) > _TOL:
17 return False
18 lo, hi = min(p1.y(), p2.y()), max(p1.y(), p2.y())
19 return lo - _TOL <= q.y() <= hi + _TOL
20 if abs(p1.y() - p2.y()) < _TOL: # horizontal
21 if abs(q.y() - p1.y()) > _TOL:
22 return False
23 lo, hi = min(p1.x(), p2.x()), max(p1.x(), p2.x())
24 return lo - _TOL <= q.x() <= hi + _TOL
25 return False
26
27
28class _UF:

Callers 3

resolve_netsFunction · 0.85
_sync_port_net_namesMethod · 0.85
_wires_on_same_netMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected