No three in line: more than 1.5n points in the n × n grid
Construct, for arbitrarily large n, more than 1.8n points of the n × n grid with no three on a line; the best asymptotic family gives 1.5n.

+1 −0 cover.svg added View file
| @@ -0,0 +1 @@ | ||
| 1 | +<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 304" role="img"><title>n = 14 · 28 points, no three on a line</title><style>svg{--ink:#1f1f1f;--ink2:#3c4043;--faint:#9aa0a6;--line:#dadce0;--sand:#b8862c;--bg:#ffffff;--muted:#5f6368;--f:#4f6bed}@media (prefers-color-scheme: dark){svg{--ink:#e8eaed;--ink2:#c4c7c5;--faint:#6f7479;--line:#3c4043;--sand:#d9b26a;--bg:#1f2023;--muted:#9aa0a6;--f:#93a6ff}}.ink{fill:var(--ink)}.ink-s{stroke:var(--ink);fill:none}.ink2-s{stroke:var(--ink2);fill:none}.f{fill:var(--f)}.f-s{stroke:var(--f);fill:none}.f-soft{fill:var(--f);fill-opacity:.14}.sand{fill:var(--sand)}.sand-s{stroke:var(--sand);fill:none}.faint{fill:var(--faint)}.faint-s{stroke:var(--faint);fill:none}.ring{stroke:var(--bg);stroke-width:3}.bg{fill:var(--bg)}.soft{fill-opacity:.16}.lbl{fill:var(--muted);font:400 19px ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}line,path,polyline{stroke-linecap:round;stroke-linejoin:round}</style><circle class="faint" cx="199.1" cy="12" r="2"/><circle class="faint" cx="199.1" cy="30.6" r="2"/><circle class="faint" cx="199.1" cy="49.2" r="2"/><circle class="faint" cx="199.1" cy="67.8" r="2"/><circle class="faint" cx="199.1" cy="86.4" r="2"/><circle class="faint" cx="199.1" cy="105" r="2"/><circle class="faint" cx="199.1" cy="123.6" r="2"/><circle class="faint" cx="199.1" cy="142.2" r="2"/><circle class="faint" cx="199.1" cy="160.8" r="2"/><circle class="faint" cx="199.1" cy="179.4" r="2"/><circle class="faint" cx="199.1" cy="198" r="2"/><circle class="faint" cx="199.1" cy="216.6" r="2"/><circle class="faint" cx="199.1" cy="235.2" r="2"/><circle class="faint" cx="199.1" cy="253.8" r="2"/><circle class="faint" cx="217.7" cy="12" r="2"/><circle class="faint" cx="217.7" cy="30.6" r="2"/><circle class="faint" cx="217.7" cy="49.2" r="2"/><circle class="faint" cx="217.7" cy="67.8" r="2"/><circle class="faint" cx="217.7" cy="86.4" r="2"/><circle class="faint" cx="217.7" cy="105" r="2"/><circle class="faint" cx="217.7" cy="123.6" r="2"/><circle class="faint" cx="217.7" cy="142.2" r="2"/><circle class="faint" cx="217.7" cy="160.8" r="2"/><circle class="faint" cx="217.7" cy="179.4" r="2"/><circle class="faint" cx="217.7" cy="198" r="2"/><circle class="faint" cx="217.7" cy="216.6" r="2"/><circle class="faint" cx="217.7" cy="235.2" r="2"/><circle class="faint" cx="217.7" cy="253.8" r="2"/><circle class="faint" cx="236.3" cy="12" r="2"/><circle class="faint" cx="236.3" cy="30.6" r="2"/><circle class="faint" cx="236.3" cy="49.2" r="2"/><circle class="faint" cx="236.3" cy="67.8" r="2"/><circle class="faint" cx="236.3" cy="86.4" r="2"/><circle class="faint" cx="236.3" cy="105" r="2"/><circle class="faint" cx="236.3" cy="123.6" r="2"/><circle class="faint" cx="236.3" cy="142.2" r="2"/><circle class="faint" cx="236.3" cy="160.8" r="2"/><circle class="faint" cx="236.3" cy="179.4" r="2"/><circle class="faint" cx="236.3" cy="198" r="2"/><circle class="faint" cx="236.3" cy="216.6" r="2"/><circle class="faint" cx="236.3" cy="235.2" r="2"/><circle class="faint" cx="236.3" cy="253.8" r="2"/><circle class="faint" cx="254.9" cy="12" r="2"/><circle class="faint" cx="254.9" cy="30.6" r="2"/><circle class="faint" cx="254.9" cy="49.2" r="2"/><circle class="faint" cx="254.9" cy="67.8" r="2"/><circle class="faint" cx="254.9" cy="86.4" r="2"/><circle class="faint" cx="254.9" cy="105" r="2"/><circle class="faint" cx="254.9" cy="123.6" r="2"/><circle class="faint" cx="254.9" cy="142.2" r="2"/><circle class="faint" cx="254.9" cy="160.8" r="2"/><circle class="faint" cx="254.9" cy="179.4" r="2"/><circle class="faint" cx="254.9" cy="198" r="2"/><circle class="faint" cx="254.9" cy="216.6" r="2"/><circle class="faint" cx="254.9" cy="235.2" r="2"/><circle class="faint" cx="254.9" cy="253.8" r="2"/><circle class="faint" cx="273.5" cy="12" r="2"/><circle class="faint" cx="273.5" cy="30.6" r="2"/><circle class="faint" cx="273.5" cy="49.2" r="2"/><circle class="faint" cx="273.5" cy="67.8" r="2"/><circle class="faint" cx="273.5" cy="86.4" r="2"/><circle class="faint" cx="273.5" cy="105" r="2"/><circle class="faint" cx="273.5" cy="123.6" r="2"/><circle class="faint" cx="273.5" cy="142.2" r="2"/><circle class="faint" cx="273.5" cy="160.8" r="2"/><circle class="faint" cx="273.5" cy="179.4" r="2"/><circle class="faint" cx="273.5" cy="198" r="2"/><circle class="faint" cx="273.5" cy="216.6" r="2"/><circle class="faint" cx="273.5" cy="235.2" r="2"/><circle class="faint" cx="273.5" cy="253.8" r="2"/><circle class="faint" cx="292.1" cy="12" r="2"/><circle class="faint" cx="292.1" cy="30.6" r="2"/><circle class="faint" cx="292.1" cy="49.2" r="2"/><circle class="faint" cx="292.1" cy="67.8" r="2"/><circle class="faint" cx="292.1" cy="86.4" r="2"/><circle class="faint" cx="292.1" cy="105" r="2"/><circle class="faint" cx="292.1" cy="123.6" r="2"/><circle class="faint" cx="292.1" cy="142.2" r="2"/><circle class="faint" cx="292.1" cy="160.8" r="2"/><circle class="faint" cx="292.1" cy="179.4" r="2"/><circle class="faint" cx="292.1" cy="198" r="2"/><circle class="faint" cx="292.1" cy="216.6" r="2"/><circle class="faint" cx="292.1" cy="235.2" r="2"/><circle class="faint" cx="292.1" cy="253.8" r="2"/><circle class="faint" cx="310.7" cy="12" r="2"/><circle class="faint" cx="310.7" cy="30.6" r="2"/><circle class="faint" cx="310.7" cy="49.2" r="2"/><circle class="faint" cx="310.7" cy="67.8" r="2"/><circle class="faint" cx="310.7" cy="86.4" r="2"/><circle class="faint" cx="310.7" cy="105" r="2"/><circle class="faint" cx="310.7" cy="123.6" r="2"/><circle class="faint" cx="310.7" cy="142.2" r="2"/><circle class="faint" cx="310.7" cy="160.8" r="2"/><circle class="faint" cx="310.7" cy="179.4" r="2"/><circle class="faint" cx="310.7" cy="198" r="2"/><circle class="faint" cx="310.7" cy="216.6" r="2"/><circle class="faint" cx="310.7" cy="235.2" r="2"/><circle class="faint" cx="310.7" cy="253.8" r="2"/><circle class="faint" cx="329.3" cy="12" r="2"/><circle class="faint" cx="329.3" cy="30.6" r="2"/><circle class="faint" cx="329.3" cy="49.2" r="2"/><circle class="faint" cx="329.3" cy="67.8" r="2"/><circle class="faint" cx="329.3" cy="86.4" r="2"/><circle class="faint" cx="329.3" cy="105" r="2"/><circle class="faint" cx="329.3" cy="123.6" r="2"/><circle class="faint" cx="329.3" cy="142.2" r="2"/><circle class="faint" cx="329.3" cy="160.8" r="2"/><circle class="faint" cx="329.3" cy="179.4" r="2"/><circle class="faint" cx="329.3" cy="198" r="2"/><circle class="faint" cx="329.3" cy="216.6" r="2"/><circle class="faint" cx="329.3" cy="235.2" r="2"/><circle class="faint" cx="329.3" cy="253.8" r="2"/><circle class="faint" cx="347.9" cy="12" r="2"/><circle class="faint" cx="347.9" cy="30.6" r="2"/><circle class="faint" cx="347.9" cy="49.2" r="2"/><circle class="faint" cx="347.9" cy="67.8" r="2"/><circle class="faint" cx="347.9" cy="86.4" r="2"/><circle class="faint" cx="347.9" cy="105" r="2"/><circle class="faint" cx="347.9" cy="123.6" r="2"/><circle class="faint" cx="347.9" cy="142.2" r="2"/><circle class="faint" cx="347.9" cy="160.8" r="2"/><circle class="faint" cx="347.9" cy="179.4" r="2"/><circle class="faint" cx="347.9" cy="198" r="2"/><circle class="faint" cx="347.9" cy="216.6" r="2"/><circle class="faint" cx="347.9" cy="235.2" r="2"/><circle class="faint" cx="347.9" cy="253.8" r="2"/><circle class="faint" cx="366.5" cy="12" r="2"/><circle class="faint" cx="366.5" cy="30.6" r="2"/><circle class="faint" cx="366.5" cy="49.2" r="2"/><circle class="faint" cx="366.5" cy="67.8" r="2"/><circle class="faint" cx="366.5" cy="86.4" r="2"/><circle class="faint" cx="366.5" cy="105" r="2"/><circle class="faint" cx="366.5" cy="123.6" r="2"/><circle class="faint" cx="366.5" cy="142.2" r="2"/><circle class="faint" cx="366.5" cy="160.8" r="2"/><circle class="faint" cx="366.5" cy="179.4" r="2"/><circle class="faint" cx="366.5" cy="198" r="2"/><circle class="faint" cx="366.5" cy="216.6" r="2"/><circle class="faint" cx="366.5" cy="235.2" r="2"/><circle class="faint" cx="366.5" cy="253.8" r="2"/><circle class="faint" cx="385.1" cy="12" r="2"/><circle class="faint" cx="385.1" cy="30.6" r="2"/><circle class="faint" cx="385.1" cy="49.2" r="2"/><circle class="faint" cx="385.1" cy="67.8" r="2"/><circle class="faint" cx="385.1" cy="86.4" r="2"/><circle class="faint" cx="385.1" cy="105" r="2"/><circle class="faint" cx="385.1" cy="123.6" r="2"/><circle class="faint" cx="385.1" cy="142.2" r="2"/><circle class="faint" cx="385.1" cy="160.8" r="2"/><circle class="faint" cx="385.1" cy="179.4" r="2"/><circle class="faint" cx="385.1" cy="198" r="2"/><circle class="faint" cx="385.1" cy="216.6" r="2"/><circle class="faint" cx="385.1" cy="235.2" r="2"/><circle class="faint" cx="385.1" cy="253.8" r="2"/><circle class="faint" cx="403.7" cy="12" r="2"/><circle class="faint" cx="403.7" cy="30.6" r="2"/><circle class="faint" cx="403.7" cy="49.2" r="2"/><circle class="faint" cx="403.7" cy="67.8" r="2"/><circle class="faint" cx="403.7" cy="86.4" r="2"/><circle class="faint" cx="403.7" cy="105" r="2"/><circle class="faint" cx="403.7" cy="123.6" r="2"/><circle class="faint" cx="403.7" cy="142.2" r="2"/><circle class="faint" cx="403.7" cy="160.8" r="2"/><circle class="faint" cx="403.7" cy="179.4" r="2"/><circle class="faint" cx="403.7" cy="198" r="2"/><circle class="faint" cx="403.7" cy="216.6" r="2"/><circle class="faint" cx="403.7" cy="235.2" r="2"/><circle class="faint" cx="403.7" cy="253.8" r="2"/><circle class="faint" cx="422.3" cy="12" r="2"/><circle class="faint" cx="422.3" cy="30.6" r="2"/><circle class="faint" cx="422.3" cy="49.2" r="2"/><circle class="faint" cx="422.3" cy="67.8" r="2"/><circle class="faint" cx="422.3" cy="86.4" r="2"/><circle class="faint" cx="422.3" cy="105" r="2"/><circle class="faint" cx="422.3" cy="123.6" r="2"/><circle class="faint" cx="422.3" cy="142.2" r="2"/><circle class="faint" cx="422.3" cy="160.8" r="2"/><circle class="faint" cx="422.3" cy="179.4" r="2"/><circle class="faint" cx="422.3" cy="198" r="2"/><circle class="faint" cx="422.3" cy="216.6" r="2"/><circle class="faint" cx="422.3" cy="235.2" r="2"/><circle class="faint" cx="422.3" cy="253.8" r="2"/><circle class="faint" cx="440.9" cy="12" r="2"/><circle class="faint" cx="440.9" cy="30.6" r="2"/><circle class="faint" cx="440.9" cy="49.2" r="2"/><circle class="faint" cx="440.9" cy="67.8" r="2"/><circle class="faint" cx="440.9" cy="86.4" r="2"/><circle class="faint" cx="440.9" cy="105" r="2"/><circle class="faint" cx="440.9" cy="123.6" r="2"/><circle class="faint" cx="440.9" cy="142.2" r="2"/><circle class="faint" cx="440.9" cy="160.8" r="2"/><circle class="faint" cx="440.9" cy="179.4" r="2"/><circle class="faint" cx="440.9" cy="198" r="2"/><circle class="faint" cx="440.9" cy="216.6" r="2"/><circle class="faint" cx="440.9" cy="235.2" r="2"/><circle class="faint" cx="440.9" cy="253.8" r="2"/><circle class="f ring" cx="199.1" cy="179.4" r="6.5"/><circle class="f ring" cx="199.1" cy="235.2" r="6.5"/><circle class="f ring" cx="217.7" cy="12" r="6.5"/><circle class="f ring" cx="217.7" cy="123.6" r="6.5"/><circle class="f ring" cx="236.3" cy="105" r="6.5"/><circle class="f ring" cx="236.3" cy="179.4" r="6.5"/><circle class="f ring" cx="254.9" cy="123.6" r="6.5"/><circle class="f ring" cx="254.9" cy="160.8" r="6.5"/><circle class="f ring" cx="273.5" cy="12" r="6.5"/><circle class="f ring" cx="273.5" cy="49.2" r="6.5"/><circle class="f ring" cx="292.1" cy="67.8" r="6.5"/><circle class="f ring" cx="292.1" cy="216.6" r="6.5"/><circle class="f ring" cx="310.7" cy="198" r="6.5"/><circle class="f ring" cx="310.7" cy="235.2" r="6.5"/><circle class="f ring" cx="329.3" cy="30.6" r="6.5"/><circle class="f ring" cx="329.3" cy="67.8" r="6.5"/><circle class="f ring" cx="347.9" cy="49.2" r="6.5"/><circle class="f ring" cx="347.9" cy="198" r="6.5"/><circle class="f ring" cx="366.5" cy="216.6" r="6.5"/><circle class="f ring" cx="366.5" cy="253.8" r="6.5"/><circle class="f ring" cx="385.1" cy="105" r="6.5"/><circle class="f ring" cx="385.1" cy="142.2" r="6.5"/><circle class="f ring" cx="403.7" cy="86.4" r="6.5"/><circle class="f ring" cx="403.7" cy="160.8" r="6.5"/><circle class="f ring" cx="422.3" cy="142.2" r="6.5"/><circle class="f ring" cx="422.3" cy="253.8" r="6.5"/><circle class="f ring" cx="440.9" cy="30.6" r="6.5"/><circle class="f ring" cx="440.9" cy="86.4" r="6.5"/><text class="lbl" x="320" y="288" text-anchor="middle">n = 14 · 28 points, no three on a line</text></svg> | |
+71 −0 figure.py added View file
| @@ -0,0 +1,71 @@ | ||
| 1 | +"""2n points of the n x n grid with no three on a line, for n = 14: two in every row, the most there can be. | |
| 2 | + | |
| 3 | +Found here by a depth-first search over sets with quarter-turn symmetry (each choice adds a point and its three | |
| 4 | +rotations about the grid's centre), filling the rows in order and blocking every grid point on a line through two | |
| 5 | +chosen ones. Checked below by testing all triples. | |
| 6 | +""" | |
| 7 | +import math | |
| 8 | +from itertools import combinations | |
| 9 | +from pathlib import Path | |
| 10 | + | |
| 11 | +import kit | |
| 12 | + | |
| 13 | +N = 14 | |
| 14 | + | |
| 15 | + | |
| 16 | +def search(n): | |
| 17 | + block = [[0] * n for _ in range(n)] # how many lines through two chosen points pass through each grid point | |
| 18 | + rows, cols, pts = [0] * n, [0] * n, [] | |
| 19 | + | |
| 20 | + def mark(a, p, d): | |
| 21 | + dx, dy = p[0] - a[0], p[1] - a[1] | |
| 22 | + g = math.gcd(dx, dy); dx //= g; dy //= g | |
| 23 | + x, y = a | |
| 24 | + while 0 <= x < n and 0 <= y < n: | |
| 25 | + x, y = x - dx, y - dy | |
| 26 | + x, y = x + dx, y + dy | |
| 27 | + while 0 <= x < n and 0 <= y < n: | |
| 28 | + block[y][x] += d; x, y = x + dx, y + dy | |
| 29 | + | |
| 30 | + def add(p): | |
| 31 | + for a in pts: | |
| 32 | + mark(a, p, 1) | |
| 33 | + pts.append(p); rows[p[1]] += 1; cols[p[0]] += 1 | |
| 34 | + | |
| 35 | + def remove(): | |
| 36 | + p = pts.pop(); rows[p[1]] -= 1; cols[p[0]] -= 1 | |
| 37 | + for a in pts: | |
| 38 | + mark(a, p, -1) | |
| 39 | + | |
| 40 | + def fill(start): | |
| 41 | + row = next((y for y in range(n) if rows[y] < 2), None) | |
| 42 | + if row is None: | |
| 43 | + return True | |
| 44 | + for x in range(start if rows[row] else 0, n): | |
| 45 | + m = n - 1 | |
| 46 | + k, ok = 0, True | |
| 47 | + for q in sorted({(x, row), (m - row, x), (m - x, m - row), (row, m - x)}): | |
| 48 | + if block[q[1]][q[0]] or q in pts or rows[q[1]] == 2 or cols[q[0]] == 2: | |
| 49 | + ok = False | |
| 50 | + break | |
| 51 | + add(q); k += 1 | |
| 52 | + if ok and fill(x + 1 if rows[row] == 1 else 0): | |
| 53 | + return True | |
| 54 | + for _ in range(k): | |
| 55 | + remove() | |
| 56 | + return False | |
| 57 | + | |
| 58 | + assert fill(0) | |
| 59 | + return sorted(pts) | |
| 60 | + | |
| 61 | + | |
| 62 | +P = search(N) | |
| 63 | +assert len(P) == 2 * N and len(set(P)) == 2 * N | |
| 64 | +assert all((b[0] - a[0]) * (c[1] - a[1]) != (c[0] - a[0]) * (b[1] - a[1]) for a, b, c in combinations(P, 3)) | |
| 65 | + | |
| 66 | +STEP = 18.6 | |
| 67 | +X0, Y0 = (kit.W - STEP * (N - 1)) / 2, 12 | |
| 68 | +at = lambda x, y: (X0 + x * STEP, Y0 + y * STEP) | |
| 69 | +body = ''.join(kit.circle(*at(x, y), 2, 'faint') for x in range(N) for y in range(N)) | |
| 70 | +body += ''.join(kit.dot(*at(x, y), r=6.5, cls='f') for x, y in P) | |
| 71 | +kit.write(__file__, 'mathematics', body, label=f'n = {N} · {len(P)} points, no three on a line') | |
+124 −0 kit.py added View file
| @@ -0,0 +1,124 @@ | ||
| 1 | +"""The drawing kit for problem cards: one canvas, one palette, light and dark built in. | |
| 2 | + | |
| 3 | +It lives here only: tools/cards/kit.py in the catalog, which each problem folder links as kit.py. The Shoal site | |
| 4 | +serves no copy of it: a card's cover is the problem's poster (tools/cards/posters.py), and what this kit draws is kept | |
| 5 | +for the problem's own page. | |
| 6 | + | |
| 7 | +A figure.py at a problem's root, with this file beside it, imports it, draws the problem's object and writes cover.svg | |
| 8 | +next to itself (docs/cards.md says what a figure must be): | |
| 9 | + | |
| 10 | + import kit | |
| 11 | + body = kit.circle(320, 152, 40, 'f') | |
| 12 | + kit.write(__file__, 'mathematics', body, label='what is drawn') | |
| 13 | + | |
| 14 | +Classes (each colour means one thing on a figure; pick the meaning, then the class): | |
| 15 | + ink, ink-s the object itself (fill / stroke) | |
| 16 | + ink2-s secondary structure (edges, outlines) | |
| 17 | + f, f-s, f-soft the field's colour: the part the question is about (fill / stroke / pale fill) | |
| 18 | + sand, sand-s the one accent: a second colour class, an open or contested part | |
| 19 | + faint, faint-s context: grids, axes, ghosts | |
| 20 | + ring a halo in the page's colour, so dots read on top of lines | |
| 21 | + bg a fill in the page's colour, to hide what lies behind (front faces, occluding balls) | |
| 22 | + soft a pale fill of any class's colour: add it next to f, sand or ink (class="sand soft") | |
| 23 | + lbl the one label line | |
| 24 | +""" | |
| 25 | +import math | |
| 26 | +from pathlib import Path | |
| 27 | + | |
| 28 | +W, H = 640, 304 # shown at 320 x 152 on a card, larger on a featured card | |
| 29 | + | |
| 30 | +# the site's field colours (public/app.css, --f-*), light and dark | |
| 31 | +FIELD = { | |
| 32 | + 'mathematics': ('#4f6bed', '#93a6ff'), 'computer-science': ('#9b59d0', '#c9a2f3'), | |
| 33 | + 'physics-astronomy': ('#129d96', '#5fd0c8'), 'chemistry-materials': ('#d08a17', '#f2c063'), | |
| 34 | + 'life-health': ('#5a9e2c', '#a3d47a'), 'earth-environment': ('#2a8ccf', '#7cc4f2'), | |
| 35 | + 'engineering-energy': ('#d4533f', '#f29484'), 'social-economics': ('#c2448f', '#f09ac8'), | |
| 36 | +} | |
| 37 | +LIGHT = dict(ink='#1f1f1f', ink2='#3c4043', faint='#9aa0a6', line='#dadce0', sand='#b8862c', bg='#ffffff', muted='#5f6368') | |
| 38 | +DARK = dict(ink='#e8eaed', ink2='#c4c7c5', faint='#6f7479', line='#3c4043', sand='#d9b26a', bg='#1f2023', muted='#9aa0a6') | |
| 39 | + | |
| 40 | + | |
| 41 | +def _vars(c, f): | |
| 42 | + return (f'--ink:{c["ink"]};--ink2:{c["ink2"]};--faint:{c["faint"]};--line:{c["line"]};--sand:{c["sand"]};' | |
| 43 | + f'--bg:{c["bg"]};--muted:{c["muted"]};--f:{f}') | |
| 44 | + | |
| 45 | + | |
| 46 | +def style(field): | |
| 47 | + light, dark = FIELD[field] | |
| 48 | + return (f'<style>svg{{{_vars(LIGHT, light)}}}@media (prefers-color-scheme: dark){{svg{{{_vars(DARK, dark)}}}}}' | |
| 49 | + '.ink{fill:var(--ink)}.ink-s{stroke:var(--ink);fill:none}.ink2-s{stroke:var(--ink2);fill:none}' | |
| 50 | + '.f{fill:var(--f)}.f-s{stroke:var(--f);fill:none}.f-soft{fill:var(--f);fill-opacity:.14}' | |
| 51 | + '.sand{fill:var(--sand)}.sand-s{stroke:var(--sand);fill:none}.faint{fill:var(--faint)}.faint-s{stroke:var(--faint);fill:none}' | |
| 52 | + '.ring{stroke:var(--bg);stroke-width:3}.bg{fill:var(--bg)}.soft{fill-opacity:.16}' | |
| 53 | + '.lbl{fill:var(--muted);font:400 19px ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}' | |
| 54 | + 'line,path,polyline{stroke-linecap:round;stroke-linejoin:round}</style>') | |
| 55 | + | |
| 56 | + | |
| 57 | +def f1(n): | |
| 58 | + return f'{round(n, 1):g}' | |
| 59 | + | |
| 60 | + | |
| 61 | +def circle(x, y, r, cls, extra=''): | |
| 62 | + return f'<circle class="{cls}" cx="{f1(x)}" cy="{f1(y)}" r="{f1(r)}"{extra}/>' | |
| 63 | + | |
| 64 | + | |
| 65 | +def dot(x, y, r=6, cls='ink'): | |
| 66 | + """A point that stays readable on top of lines: filled, with a halo in the page's colour.""" | |
| 67 | + return circle(x, y, r, f'{cls} ring') | |
| 68 | + | |
| 69 | + | |
| 70 | +def line(x1, y1, x2, y2, cls='ink2-s', w=2, extra=''): | |
| 71 | + return f'<line class="{cls}" x1="{f1(x1)}" y1="{f1(y1)}" x2="{f1(x2)}" y2="{f1(y2)}" stroke-width="{w}"{extra}/>' | |
| 72 | + | |
| 73 | + | |
| 74 | +def path(d, cls='ink2-s', w=2, extra=''): | |
| 75 | + return f'<path class="{cls}" d="{d}" stroke-width="{w}"{extra}/>' | |
| 76 | + | |
| 77 | + | |
| 78 | +def polygon(pts, cls='f-soft', extra=''): | |
| 79 | + return f'<polygon class="{cls}" points="{" ".join(f"{f1(x)},{f1(y)}" for x, y in pts)}"{extra}/>' | |
| 80 | + | |
| 81 | + | |
| 82 | +def polyline(pts, cls='ink2-s', w=2, extra=''): | |
| 83 | + return f'<polyline class="{cls}" points="{" ".join(f"{f1(x)},{f1(y)}" for x, y in pts)}" stroke-width="{w}"{extra}/>' | |
| 84 | + | |
| 85 | + | |
| 86 | +DASH = ' stroke-dasharray="7 6"' # pass as `extra` for a dashed stroke | |
| 87 | + | |
| 88 | + | |
| 89 | +def polypath(pts, cls='ink2-s', w=2, closed=False, extra=''): | |
| 90 | + """Many points as one relative path: the same line as polyline, a fraction of the bytes.""" | |
| 91 | + (x0, y0), d, px, py = pts[0], [], pts[0][0], pts[0][1] | |
| 92 | + for x, y in pts[1:]: | |
| 93 | + d.append(f'{f1(x - px)} {f1(y - py)}'); px, py = x, y | |
| 94 | + return path(f'M{f1(x0)} {f1(y0)}l' + ' '.join(d) + ('z' if closed else ''), cls, w, extra) | |
| 95 | + | |
| 96 | + | |
| 97 | +def arrow(x1, y1, x2, y2, cls='ink2-s', w=2, head=10): | |
| 98 | + """A line ending in an open arrowhead at (x2, y2).""" | |
| 99 | + a = math.atan2(y2 - y1, x2 - x1) | |
| 100 | + tips = [(x2 - head * math.cos(a - s), y2 - head * math.sin(a - s)) for s in (0.45, -0.45)] | |
| 101 | + return line(x1, y1, x2, y2, cls, w) + polyline([tips[0], (x2, y2), tips[1]], cls, w) | |
| 102 | + | |
| 103 | + | |
| 104 | +def text(x, y, s, cls='lbl', anchor='middle'): | |
| 105 | + s = s.replace('&', '&').replace('<', '<').replace('>', '>') | |
| 106 | + return f'<text class="{cls}" x="{f1(x)}" y="{f1(y)}" text-anchor="{anchor}">{s}</text>' | |
| 107 | + | |
| 108 | + | |
| 109 | +def svg(field, body, label=None, title=''): | |
| 110 | + """The whole figure. `label` is the one line naming what is drawn, at the bottom; leave room for it (y < 262).""" | |
| 111 | + if field not in FIELD: | |
| 112 | + raise ValueError(f'unknown field {field!r}') | |
| 113 | + if label and len(label) > 50: | |
| 114 | + raise ValueError(f'label over 50 characters (more does not fit at card size): {label!r}') | |
| 115 | + t = f'<title>{title or label or ""}</title>' | |
| 116 | + tail = text(W / 2, H - 16, label) if label else '' | |
| 117 | + return f'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 {W} {H}" role="img">{t}{style(field)}{body}{tail}</svg>\n' | |
| 118 | + | |
| 119 | + | |
| 120 | +def write(figure_py, field, body, label=None, title=''): | |
| 121 | + """Writes cover.svg next to the figure.py that calls it.""" | |
| 122 | + out = Path(figure_py).resolve().parent / 'cover.svg' | |
| 123 | + out.write_text(svg(field, body, label, title)) | |
| 124 | + return out | |
+0 −0 poster.webp added View file
+6 −0 posters.json added View file
| @@ -0,0 +1,6 @@ | ||
| 1 | +{ | |
| 2 | + "poster.webp": { | |
| 3 | + "style": "poster", | |
| 4 | + "idea": "A handcrafted birch grid board densely studded with brass and ivory points, showing many points avoiding every three-point alignment." | |
| 5 | + } | |
| 6 | +} | |
+26 −3 scienceslack.json View file
| @@ -6,8 +6,7 @@ | ||
| 6 | 6 | ], |
| 7 | 7 | "type": "construction", |
| 8 | 8 | "cover": { |
| 9 | - "motif": "points", | |
| 10 | - "n": 10 | |
| 9 | + "file": "poster.webp" | |
| 11 | 10 | }, |
| 12 | 11 | "source": { |
| 13 | 12 | "key": "frontiermath-open", |
| @@ -20,5 +19,29 @@ | ||
| 20 | 19 | "catalog": "0521c19bbd38" |
| 21 | 20 | }, |
| 22 | 21 | "review": true, |
| 23 | - "approval": "first-time" | |
| 22 | + "approval": "first-time", | |
| 23 | + "card": { | |
| 24 | + "question": "How many points of a large n × n grid can you pick with no three of them on one line?", | |
| 25 | + "stake": "Nothing better than the 1975 construction's 1.5n is known for large n, though a heuristic predicts about 1.81n.", | |
| 26 | + "frontier": { | |
| 27 | + "shape": "bounds", | |
| 28 | + "what": "t(n)/n for large n", | |
| 29 | + "lower": { | |
| 30 | + "value": "1.5", | |
| 31 | + "x": 1.5, | |
| 32 | + "by": "Hall, Jackson, Sudbery and Wild", | |
| 33 | + "year": 1975 | |
| 34 | + }, | |
| 35 | + "upper": { | |
| 36 | + "value": "2", | |
| 37 | + "x": 2 | |
| 38 | + }, | |
| 39 | + "guess": { | |
| 40 | + "value": "1.814", | |
| 41 | + "x": 1.814, | |
| 42 | + "by": "Ellmann" | |
| 43 | + } | |
| 44 | + }, | |
| 45 | + "first": "Beat 1.5n points by a constant factor, for arbitrarily large n" | |
| 46 | + } | |
| 24 | 47 | } |