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

Function sketch_trisect

numericals.py:1888–1915  ·  view source on GitHub ↗

Sketch two trisectors of an angle.

(args: tuple[gm.Point, ...])

Source from the content-addressed store, hash-verified

1886
1887
1888def sketch_trisect(args: tuple[gm.Point, ...]) -> tuple[Point, Point]:
1889 """Sketch two trisectors of an angle."""
1890 a, b, c = args
1891 ang1 = ang_of(b, a)
1892 ang2 = ang_of(b, c)
1893
1894 swap = 0
1895 if ang1 > ang2:
1896 ang1, ang2 = ang2, ang1
1897 swap += 1
1898
1899 if ang2 - ang1 > np.pi:
1900 ang1, ang2 = ang2, ang1 + 2 * np.pi
1901 swap += 1
1902
1903 angx = ang1 + (ang2 - ang1) / 3
1904 angy = ang2 - (ang2 - ang1) / 3
1905
1906 x = b + Point(np.cos(angx), np.sin(angx))
1907 y = b + Point(np.cos(angy), np.sin(angy))
1908
1909 ac = Line(a, c)
1910 x = line_line_intersection(Line(b, x), ac)
1911 y = line_line_intersection(Line(b, y), ac)
1912
1913 if swap == 1:
1914 return y, x
1915 return x, y
1916
1917
1918def sketch_trisegment(args: tuple[gm.Point, ...]) -> tuple[Point, Point]:

Callers

nothing calls this directly

Calls 5

ang_ofFunction · 0.85
line_line_intersectionFunction · 0.85
cosMethod · 0.80
PointClass · 0.70
LineClass · 0.70

Tested by

no test coverage detected