True if q lies on the axis-aligned segment p1→p2 (inclusive endpoints).
(p1: QPointF, p2: QPointF, q: QPointF)
| 11 | |
| 12 | |
| 13 | def _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 | |
| 28 | class _UF: |
no outgoing calls
no test coverage detected