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

Function match_eqangle_eqangle_eqangle

dd.py:96–140  ·  view source on GitHub ↗

Match eqangle a b c d m n p q, eqangle c d e f p q r u => eqangle a b e f m n r u.

(
    g: gh.Graph,
    g_matcher: Callable[str, list[tuple[gm.Point, ...]]],
    theorem: pr.Theorem,
)

Source from the content-addressed store, hash-verified

94
95
96def match_eqangle_eqangle_eqangle(
97 g: gh.Graph,
98 g_matcher: Callable[str, list[tuple[gm.Point, ...]]],
99 theorem: pr.Theorem,
100) -> Generator[dict[str, gm.Point], None, None]:
101 """Match eqangle a b c d m n p q, eqangle c d e f p q r u => eqangle a b e f m n r u."""
102 for m1 in g.type2nodes[gm.Measure]:
103 for m2 in g.type2nodes[gm.Measure]:
104 angs1 = []
105 for ang in m1.neighbors(gm.Angle):
106 d1, d2 = ang.directions
107 if d1 is None or d2 is None:
108 continue
109 angs1.append((d1, d2))
110
111 angs2 = []
112 for ang in m2.neighbors(gm.Angle):
113 d1, d2 = ang.directions
114 if d1 is None or d2 is None:
115 continue
116 angs2.append((d1, d2))
117
118 pairs = []
119 for (d1, d2), (d3, d4) in utils.cross(angs1, angs2):
120 if d2 == d3:
121 pairs.append((d1, d2, d4))
122
123 for (d1, d12, d2), (d3, d34, d4) in utils.comb2(pairs):
124 if (d1, d12, d2) == (d3, d34, d4):
125 continue
126 if d1 == d2 or d3 == d4:
127 continue
128 if d1 == d12 or d12 == d2 or d3 == d34 or d4 == d34:
129 continue
130 # d12 - d1 = d34 - d3 = m1
131 # d2 - d12 = d4 - d34 = m2
132 # => d2 - d1 = d4 - d3
133 a, b = g.two_points_on_direction(d1)
134 c, d = g.two_points_on_direction(d12)
135 m, n = g.two_points_on_direction(d3)
136 p, q = g.two_points_on_direction(d34)
137 # eqangle a b c d m n p q
138 e, f = g.two_points_on_direction(d2)
139 r, u = g.two_points_on_direction(d4)
140 yield dict(zip('abcdefmnpqru', [a, b, c, d, e, f, m, n, p, q, r, u]))
141
142
143def match_perp_perp_npara_eqangle(

Callers

nothing calls this directly

Calls 3

neighborsMethod · 0.80
crossMethod · 0.80

Tested by

no test coverage detected