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

Function check_eqangle

numericals.py:749–786  ·  view source on GitHub ↗

Check if 8 points make 2 equal angles.

(points: list[Point])

Source from the content-addressed store, hash-verified

747
748
749def check_eqangle(points: list[Point]) -> bool:
750 """Check if 8 points make 2 equal angles."""
751 a, b, c, d, e, f, g, h = points
752
753 ab = Line(a, b)
754 cd = Line(c, d)
755 ef = Line(e, f)
756 gh = Line(g, h)
757
758 if ab.is_parallel(cd):
759 return ef.is_parallel(gh)
760 if ef.is_parallel(gh):
761 return ab.is_parallel(cd)
762
763 a, b, c, d = bring_together(a, b, c, d)
764 e, f, g, h = bring_together(e, f, g, h)
765
766 ba = b - a
767 dc = d - c
768 fe = f - e
769 hg = h - g
770
771 sameclock = (ba.x * dc.y - ba.y * dc.x) * (fe.x * hg.y - fe.y * hg.x) > 0
772 if not sameclock:
773 ba = ba * -1.0
774
775 a1 = np.arctan2(fe.y, fe.x)
776 a2 = np.arctan2(hg.y, hg.x)
777 x = a1 - a2
778
779 a3 = np.arctan2(ba.y, ba.x)
780 a4 = np.arctan2(dc.y, dc.x)
781 y = a3 - a4
782
783 xy = (x - y) % (2 * np.pi)
784 return close_enough(xy, 0, tol=1e-11) or close_enough(
785 xy, 2 * np.pi, tol=1e-11
786 )
787
788
789def check_eqratio(points: list[Point]) -> bool:

Callers 1

test_sketch_eqangle3Method · 0.85

Calls 4

is_parallelMethod · 0.95
bring_togetherFunction · 0.85
close_enoughFunction · 0.85
LineClass · 0.70

Tested by 1

test_sketch_eqangle3Method · 0.68