MCPcopy Create free account
hub / github.com/google-deepmind/alphageometry / draw_line

Function draw_line

numericals.py:969–991  ·  view source on GitHub ↗

Draw a line.

(
    ax: matplotlib.axes.Axes, line: Line, color: Any = 'white'
)

Source from the content-addressed store, hash-verified

967
968
969def 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
994def _draw_circle(

Callers 1

_drawFunction · 0.85

Calls 3

_draw_lineFunction · 0.85
neighborsMethod · 0.80
dotMethod · 0.45

Tested by

no test coverage detected