Draw a line.
(
ax: matplotlib.axes.Axes, line: Line, color: Any = 'white'
)
| 967 | |
| 968 | |
| 969 | def draw_line( |
| 970 | ax: matplotlib.axes.Axes, line: Line, color: Any = 'white' |
| 971 | ) -> tuple[Point, Point]: |
| 972 | """Draw a line.""" |
| 973 | points = line.neighbors(gm.Point) |
| 974 | if len(points) <= 1: |
| 975 | return |
| 976 | |
| 977 | points = [p.num for p in points] |
| 978 | p1, p2 = points[:2] |
| 979 | |
| 980 | pmin, pmax = (p1, 0.0), (p2, (p2 - p1).dot(p2 - p1)) |
| 981 | |
| 982 | for p in points[2:]: |
| 983 | v = (p - p1).dot(p2 - p1) |
| 984 | if v < pmin[1]: |
| 985 | pmin = p, v |
| 986 | if v > pmax[1]: |
| 987 | pmax = p, v |
| 988 | |
| 989 | p1, p2 = pmin[0], pmax[0] |
| 990 | _draw_line(ax, p1, p2, color=color) |
| 991 | return p1, p2 |
| 992 | |
| 993 | |
| 994 | def _draw_circle( |
no test coverage detected