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

Method check_eqangle

graph.py:1995–2047  ·  view source on GitHub ↗

Check if two angles are equal.

(self, points: list[Point])

Source from the content-addressed store, hash-verified

1993 return False
1994
1995 def check_eqangle(self, points: list[Point]) -> bool:
1996 """Check if two angles are equal."""
1997 a, b, c, d, m, n, p, q = points
1998
1999 if {a, b} == {c, d} and {m, n} == {p, q}:
2000 return True
2001 if {a, b} == {m, n} and {c, d} == {p, q}:
2002 return True
2003
2004 if (a == b) or (c == d) or (m == n) or (p == q):
2005 return False
2006 ab = self._get_line(a, b)
2007 cd = self._get_line(c, d)
2008 mn = self._get_line(m, n)
2009 pq = self._get_line(p, q)
2010
2011 if {a, b} == {c, d} and mn and pq and self.is_equal(mn, pq):
2012 return True
2013 if {a, b} == {m, n} and cd and pq and self.is_equal(cd, pq):
2014 return True
2015 if {p, q} == {m, n} and ab and cd and self.is_equal(ab, cd):
2016 return True
2017 if {p, q} == {c, d} and ab and mn and self.is_equal(ab, mn):
2018 return True
2019
2020 if not ab or not cd or not mn or not pq:
2021 return False
2022
2023 if self.is_equal(ab, cd) and self.is_equal(mn, pq):
2024 return True
2025 if self.is_equal(ab, mn) and self.is_equal(cd, pq):
2026 return True
2027
2028 if not (ab.val and cd.val and mn.val and pq.val):
2029 return False
2030
2031 if (ab.val, cd.val) == (mn.val, pq.val) or (ab.val, mn.val) == (
2032 cd.val,
2033 pq.val,
2034 ):
2035 return True
2036
2037 for ang1, _, _ in gm.all_angles(ab._val, cd._val):
2038 for ang2, _, _ in gm.all_angles(mn._val, pq._val):
2039 if self.is_equal(ang1, ang2):
2040 return True
2041
2042 if self.check_perp([a, b, m, n]) and self.check_perp([c, d, p, q]):
2043 return True
2044 if self.check_perp([a, b, p, q]) and self.check_perp([c, d, m, n]):
2045 return True
2046
2047 return False
2048
2049 def _get_ratio(self, l1: Length, l2: Length) -> tuple[Ratio, Ratio]:
2050 for r in self.type2nodes[Ratio]:

Calls 3

_get_lineMethod · 0.95
is_equalMethod · 0.95
check_perpMethod · 0.95

Tested by 2