#!/usr/bin/env python3 """Generate figs.tex: all figures of the paper as TikZ, from exact coordinates. Every point is computed from the formulas of the paper; nothing is traced from an earlier drawing. Run: python3 genfigs.py > figs.tex """ from math import sqrt OUT = [] def emit(s=""): OUT.append(s) def c(pt): return f"({pt[0]:.4f},{pt[1]:.4f})" def meet(p1, d1, p2, d2): """Intersection of p1 + a d1 and p2 + b d2.""" det = d1[0] * (-d2[1]) - d1[1] * (-d2[0]) rx, ry = p2[0] - p1[0], p2[1] - p1[1] a = (rx * (-d2[1]) - ry * (-d2[0])) / det return (p1[0] + a * d1[0], p1[1] + a * d1[1]) PRE = r"""% Generated by genfigs.py -- all coordinates computed from the formulas of the paper. \usepackage{tikz} \usetikzlibrary{calc,arrows.meta,decorations.pathreplacing} \definecolor{supp}{RGB}{20,90,160} \definecolor{trans}{RGB}{30,130,60} \definecolor{acc}{RGB}{205,95,10} \definecolor{chainc}{RGB}{150,150,150} \definecolor{chainp}{RGB}{190,120,120} \tikzset{ rect/.style={line width=0.9pt}, chain/.style={line width=0.4pt,chainc}, chainpar/.style={line width=0.4pt,chainp}, support/.style={line width=1.5pt,supp}, transport/.style={line width=1.1pt,trans}, accent/.style={line width=1.2pt,acc}, aux/.style={line width=0.5pt,densely dashed,black!60}, pt/.style={circle,fill=black,inner sep=1.4pt}, lab/.style={font=\small,inner sep=2pt}, ttl/.style={font=\small\bfseries,anchor=west}, dim/.style={line width=0.5pt,{Latex[length=4pt]}-{Latex[length=4pt]}}, } """ class Rect: """Pandrosion rectangle with the triangle power stage and transport.""" def __init__(self, W, H, p, X, s): self.W, self.H, self.p, self.X, self.s = W, H, p, X, s self.t = X * s**p self.O, self.A, self.C, self.B = (0, H), (W, H), (0, 0), (W, 0) self.M = (0, H * (1 - 1 / X)) self.E = (W, H * (1 - s**p)) self.P = (W, H * (1 - s)) self.sigma = (self.E[1] - self.M[1]) / W def base(self, chain=True): W, H, p, s = self.W, self.H, self.p, self.s if chain: emit(rf"\draw[chain] {c(self.O)}--{c(self.B)};") L1 = (0, H * (1 - s)) emit(rf"\draw[chain] {c(L1)}--{c(self.B)};") for j in range(1, p + 1): y = H * (1 - s**j) emit(rf"\draw[chain] (0,{y:.4f})--({W},{y:.4f});") for j in range(1, p): Bj = (W * s**j, H * (1 - s**j)) Lj1 = (0, H * (1 - s ** (j + 1))) emit(rf"\draw[chainpar] {c(Bj)}--{c(Lj1)};") emit(rf"\draw[rect] {c(self.C)} rectangle {c(self.A)};") def step(self, a0, d0): """Support through a0 with direction d0; returns T and P_+.""" T = meet(a0, d0, self.P, (1, self.sigma)) Pp = (self.W, T[1]) return T, Pp def transport(self, T, Pp): emit(rf"\draw[transport] {c(self.M)}--{c(self.E)};") emit(rf"\draw[transport] {c(self.P)}--{c(T)};") emit(rf"\draw[transport,line width=1.5pt] {c(T)}--{c(Pp)};") def corners(self, cl="below left", bl="below right", al="above right"): emit(rf"\node[lab,above left] at {c(self.O)} {{$O$}};") emit(rf"\node[lab,{al}] at {c(self.A)} {{$A$}};") emit(rf"\node[lab,{cl}] at {c(self.C)} {{$C$}};") emit(rf"\node[lab,{bl}] at {c(self.B)} {{$B$}};") def points(self, T, Pp, tl="below left", pl="above right", ppl="below right"): for q in (self.O, self.A, self.C, self.B, self.M, self.E, self.P, T, Pp): emit(rf"\node[pt] at {c(q)} {{}};") emit(rf"\node[lab,left] at {c(self.M)} {{$M$}};") emit(rf"\node[lab,right] at {c(self.E)} {{$E$}};") emit(rf"\node[lab,{pl}] at {c(self.P)} {{$P$}};") emit(rf"\node[lab,{ppl}] at {c(Pp)} {{$P_+$}};") if tl: emit(rf"\node[lab,{tl}] at {c(T)} {{$T$}};") def zoom(R, T, Pp, at, mag, extra=None, pad=0.14, pady=0.2): """Magnified inset of the window around P, T, P_+; `at` is its lower-left corner.""" x0, x1 = T[0] - pad, R.W + 0.6 * pad y0, y1 = min(R.P[1], Pp[1]) - pady, max(R.P[1], Pp[1]) + pady emit(rf"\draw[aux] ({x0:.4f},{y0:.4f}) rectangle ({x1:.4f},{y1:.4f});") emit(rf"\node[lab,left] at ({x0:.4f},{T[1]:.4f}) {{$T$}};") sx, sy = at[0] - mag * x0, at[1] - mag * y0 emit(rf"\begin{{scope}}[shift={{({sx:.4f},{sy:.4f})}},scale={mag}]") emit(rf"\begin{{scope}}") emit(rf"\clip ({x0:.4f},{y0:.4f}) rectangle ({x1:.4f},{y1:.4f});") emit(rf"\fill[white] ({x0:.4f},{y0:.4f}) rectangle ({x1:.4f},{y1:.4f});") emit(rf"\draw[rect] ({R.W},{y0 - 1:.4f})--({R.W},{y1 + 1:.4f});") if extra: extra() far = (R.P[0] - 5, R.P[1] - 5 * R.sigma) emit(rf"\draw[transport] {c(R.P)}--{c(far)};") emit(rf"\draw[transport,line width=1.6pt] {c(T)}--{c(Pp)};") for q in (R.P, T, Pp): emit(rf"\node[pt] at {c(q)} {{}};") emit(r"\end{scope}") emit(rf"\draw[line width=0.6pt] ({x0:.4f},{y0:.4f}) rectangle ({x1:.4f},{y1:.4f});") emit(rf"\node[lab,right] at ({x1:.4f},{R.P[1]:.4f}) {{$P$}};") emit(rf"\node[lab,right] at ({x1:.4f},{Pp[1]:.4f}) {{$P_+$}};") emit(rf"\node[lab,left] at ({x0:.4f},{T[1]:.4f}) {{$T$}};") emit(rf"\node[font=\footnotesize,anchor=south west] at ({x0:.4f},{y1:.4f}) {{Readout detail (magnified $\times{mag}$)}};") emit(r"\end{scope}") def macro(name): emit(rf"\newcommand{{\{name}}}{{%") def end(): emit("}") emit() # ------------------------------------------------------------------ Figure 1 def fig_arc(): p, X, W, H, s = 7, 2.0, 2.0, 4.0, 0.75 R = Rect(W, H, p, X, s) t = R.t eta = (p - 1) * sqrt((p - 2) / (12 * p)) zeta = (5 * p + 2) / (p - 2) d0 = W / eta delta = H / X * sqrt(zeta**2 - 1) G0 = (W, H + H * zeta / X) Oarc = (W - d0 + delta, H - H / (X * eta)) rad = G0[1] - R.E[1] foot = (W - d0, Oarc[1]) D = (W - d0, Oarc[1] - sqrt(rad**2 - delta**2)) # consistency with the scalar formula q5 = sqrt(((p - 2) * (t * t + 1) + (10 * p + 4) * t) / (12 * p)) kap = (H - D[1]) / (W - D[0]) * W * X / H assert abs(kap - (1 + (p - 1) * q5)) < 1e-12 T, Pp = R.step(R.A, (D[0] - W, D[1] - H)) assert abs((1 - Pp[1] / H) - s * kap / (kap - 1 + t)) < 1e-12 macro("figDecentered") emit(r"\begin{tikzpicture}[scale=0.25]") emit(r"\node[ttl] at (-3,23.6) {(a) Circle geometry};") emit(rf"\draw[line width=0.5pt,black!55] (0,0) rectangle ({W},{H});") emit(rf"\draw[accent] {c(Oarc)} circle ({rad:.4f});") emit(rf"\draw[aux] ({W - d0:.4f},-13.4)--({W - d0:.4f},9.0);") emit(rf"\draw[accent,line width=2.2pt] {c(R.E)}--{c(G0)};") emit(rf"\draw[line width=0.8pt] {c(D)}--{c(foot)}--{c(Oarc)};") emit(rf"\draw[line width=0.8pt,acc] {c(Oarc)}--{c(D)};") emit(rf"\draw[line width=0.5pt] ({foot[0]:.4f},{foot[1] - 0.8:.4f})-|({foot[0] + 0.8:.4f},{foot[1]:.4f});") for q in (G0, R.E, Oarc, D, foot): emit(rf"\node[pt] at {c(q)} {{}};") emit(rf"\node[lab,left] at {c(G0)} {{$G_0$}};") emit(rf"\node[lab,anchor=south west] at ({W + 0.15:.4f},{R.E[1] + 0.2:.4f}) {{$E$}};") emit(rf"\node[lab,above right] at {c(Oarc)} {{$O_{{\mathrm{{arc}}}}$}};") emit(rf"\node[lab,below left] at {c(D)} {{$D_{{\mathrm{{arc}}}}$}};") emit(rf"\node[lab,anchor=west,acc] at ({W + 0.9:.4f},20.6) {{compass opening $EG_0=\frac HX(t+\zeta)$}};") emit(rf"\node[lab,above] at ({(foot[0] + Oarc[0]) / 2:.4f},{Oarc[1]:.4f}) {{$\delta$}};") emit(rf"\node[lab,anchor=north west,acc] at ({(D[0] + Oarc[0]) / 2:.4f},{(D[1] + Oarc[1]) / 2 - 0.2:.4f}) {{radius $EG_0$}};") emit(rf"\node[lab,anchor=north west,align=left] at ({W - d0 + 2.6:.4f},-5.6) {{vertical $x=W-d_0$\\[3pt]$\bigl|y_{{D_{{\mathrm{{arc}}}}}}-y_{{O_{{\mathrm{{arc}}}}}}\bigr|=\sqrt{{EG_0^{{2}}-\delta^{{2}}}}$}};") emit(rf"\node[font=\footnotesize,black!60,anchor=east] at (-0.3,1.3) {{rectangle}};") # panel (b): 1 unit = 1.62 cm sc = 6.48 emit(rf"\begin{{scope}}[shift={{(41.5,-5.0)}},scale={sc}]") emit(rf"\node[ttl] at (-0.45,{28.6 / sc:.4f}) {{(b) Support and readout}};") R.base() emit(rf"\draw[support] {c(R.A)}--{c(D)};") R.transport(T, Pp) R.corners(cl="left", bl="below right") R.points(T, Pp, tl="above left", pl="right", ppl="right") emit(rf"\node[pt] at {c(D)} {{}};") emit(rf"\node[lab,below] at {c(D)} {{$D_{{\mathrm{{arc}}}}$}};") emit(r"\end{scope}") emit(r"\end{tikzpicture}%") end() # ------------------------------------------------------------------ Figure 2 def semicircle(x0, sc, a, b, hl, la, lb, top, n): d = a + b r = d / 2 X = lambda u: x0 + sc * u Yh = sc * hl emit(rf"\draw[line width=1.3pt,supp] ({X(d):.4f},0) arc (0:180:{sc * r:.4f});") emit(rf"\draw[rect] ({X(0):.4f},0)--({X(d):.4f},0);") emit(rf"\draw[chain] ({X(0):.4f},0)--({X(a):.4f},{Yh:.4f})--({X(d):.4f},0);") emit(rf"\draw[accent,line width=2pt] ({X(a):.4f},0)--({X(a):.4f},{Yh:.4f});") for q in ((X(0), 0), (X(a), 0), (X(d), 0), (X(a), Yh), (X(r), 0)): emit(rf"\node[pt] at {c(q)} {{}};") emit(rf"\node[lab,below left] at ({X(0):.4f},0) {{$A$}};") emit(rf"\node[lab,below] at ({X(a):.4f},-0.05) {{$H$}};") emit(rf"\node[lab,below right] at ({X(d):.4f},0) {{$B$}};") emit(rf"\node[font=\footnotesize,black!60,above] at ({X(r):.4f},0.05) {{centre}};") emit(rf"\draw[dim] ({X(0):.4f},-0.95)--({X(a):.4f},-0.95) node[midway,below,lab] {{{la}}};") emit(rf"\draw[dim] ({X(a):.4f},-0.95)--({X(d):.4f},-0.95) node[midway,below,lab] {{{lb}}};") emit(rf"\node[lab,acc,anchor=west,fill=white,inner sep=1.5pt] at ({X(a) + 0.18:.4f},{Yh * 0.45:.4f}) {{{top}}};") emit(rf"\node[ttl] at ({X(0) - 0.3:.4f},{sc * r + 0.7:.4f}) {{{n}}};") def fig_means(): ell = sqrt(109 / 13) dd = ell / 108 q9 = sqrt(2 + dd) macro("figMeans") emit(r"\begin{tikzpicture}") semicircle(0.0, 0.70, 1.0, 109 / 13, ell, "$1$", "$109/13$", r"$\ell=\sqrt{109/13}$", "1. First mean proportional") semicircle(8.4, 6.57 / (3 + dd), 1.0, 2 + dd, q9, "$1$", r"$2+d$", r"$q_9=\sqrt{2+d}$", "2. Second mean proportional") emit(r"\node[lab,anchor=north,align=center] at (7.5,-1.75) {Between the two: prepare $d=\ell/108$ by similar triangles, then transfer $2+d$ to the second diameter.};") emit(r"\end{tikzpicture}%") end() # ------------------------------------------------------------------ Figure 3 def fig_support(): W, H = 6.0, 4.0 ell = sqrt(109 / 13) q9 = sqrt(2 + ell / 108) O, A, C, B, M = (0, H), (W, H), (0, 0), (W, 0), (0, 2.0) D9 = (0, 2 - 4 * q9) T9 = meet(A, (D9[0] - W, D9[1] - H), M, (W, -2.0)) P1 = (W, T9[1]) assert abs(T9[0] - 3.524406494288) < 1e-9 and abs(T9[1] - 0.825197835237) < 1e-9 AP1 = H - P1[1] u1 = H / AP1 macro("figSupport") emit(r"\begin{tikzpicture}[scale=1.3]") emit(rf"\node[ttl] at (-1.5,4.7) {{3. Modified support and readout\quad($W=6$, $H=4$)}};") emit(rf"\draw[rect] {c(C)} rectangle {c(A)};") emit(rf"\draw[aux] {c(C)}--{c(D9)};") emit(rf"\draw[accent] {c(M)}--{c(B)};") emit(rf"\draw[support] {c(A)}--{c(D9)};") emit(rf"\draw[transport,line width=1.6pt] {c(T9)}--{c(P1)};") for q in (O, A, C, B, M, D9, T9, P1): emit(rf"\node[pt] at {c(q)} {{}};") emit(rf"\node[lab,above left] at {c(O)} {{$O$}};") emit(rf"\node[lab,above right] at {c(A)} {{$A$}};") emit(rf"\node[lab,below left] at {c(C)} {{$C$}};") emit(rf"\node[lab,below right] at {c(B)} {{$B=P_0=E$}};") emit(rf"\node[lab,above left] at {c(M)} {{$M$}};") emit(rf"\node[lab,below right] at {c(D9)} {{$D_9$}};") emit(rf"\node[lab,anchor=south] at ({T9[0] - 0.22:.4f},{T9[1] + 0.12:.4f}) {{$T_9$}};") emit(rf"\node[lab,above right] at {c(P1)} {{$P_1$}};") emit(rf"\draw[dim,supp] (-0.75,{M[1]:.4f})--(-0.75,{D9[1]:.4f}) node[midway,left,lab,supp] {{$4q_9$}};") emit(rf"\draw[line width=0.4pt,black!50] (-0.9,{M[1]:.4f})--(-0.08,{M[1]:.4f}) (-0.9,{D9[1]:.4f})--(-0.08,{D9[1]:.4f});") emit(rf"\draw[dim,trans] (6.75,{H:.4f})--(6.75,{P1[1]:.4f}) node[midway,right,lab,trans,align=left] {{$AP_1=$\\$3.174802\ldots$}};") emit(rf"\draw[line width=0.4pt,black!50] (6.08,{H:.4f})--(6.9,{H:.4f}) (6.5,{P1[1]:.4f})--(6.9,{P1[1]:.4f});") emit(rf"\node[lab,supp,anchor=east] at (4.35,2.35) {{support $AD_9$}};") emit(rf"\node[lab,acc,anchor=south west] at (0.75,1.78) {{transport line $MB$}};") # inversion panel, in the free area below the rectangle emit(r"\begin{scope}[shift={(3.75,-3.55)}]") emit(rf"\node[ttl] at (-0.45,{u1 + 1.45:.4f}) {{4. Invert by parallel lines}};") emit(rf"\node[lab,anchor=west] at (-0.4,{u1 + 0.85:.4f}) {{$OI=1$,\quad $OV=AP_1$,\quad $OZ=AB$}};") emit(rf"\draw[rect] (0,0)--(4.5,0) (0,0)--(0,{u1 + 0.35:.4f});") emit(rf"\draw[chain,line width=0.9pt] (0,1)--({AP1:.4f},0);") emit(rf"\draw[transport] (0,{u1:.4f})--(4,0);") for q in ((0, 0), (0, 1), (0, u1), (AP1, 0), (4, 0)): emit(rf"\node[pt] at {c(q)} {{}};") emit(r"\node[lab,below left] at (0,0) {$O$};") emit(r"\node[lab,left] at (0,0.93) {$I$};") emit(rf"\node[lab,left] at (0,{u1 + 0.05:.4f}) {{$U$}};") emit(rf"\node[lab,below] at ({AP1:.4f},0) {{$V$}};") emit(r"\node[lab,below] at (4,0) {$Z$};") emit(rf"\node[lab,anchor=south west,trans] at (1.5,0.82) {{$UZ\parallel IV$,\ \ $OU=u_1=AB/AP_1$}};") emit(r"\end{scope}") emit(r"\end{tikzpicture}%") end() # ------------------------------------------------------------------ Figure 4 def fig_subdivision(): a, b = 1.2, 2.8 m = sqrt(a * b) macro("figSubdivision") emit(r"\begin{tikzpicture}[scale=2.2]") emit(rf"\draw[line width=1.3pt,supp] ({a + b},0) arc (0:180:{(a + b) / 2});") emit(rf"\draw[rect] (0,0)--({a + b},0);") emit(rf"\draw[chain] (0,0)--({a},{m:.4f})--({a + b},0);") emit(rf"\draw[accent,line width=2pt] ({a},0)--({a},{m:.4f});") for q in ((0, 0), (a, 0), ((a + b) / 2, 0), (a + b, 0), (a, m)): emit(rf"\node[pt] at {c(q)} {{}};") emit(r"\node[lab,below left] at (0,0) {$O$};") emit(rf"\node[lab,below] at ({a},-0.02) {{$T$}};") emit(rf"\node[lab,below] at ({(a + b) / 2},-0.02) {{$C$}};") emit(rf"\node[lab,below right] at ({a + b},0) {{$S$}};") emit(rf"\node[lab,above left] at ({a},{m:.4f}) {{$G$}};") emit(rf"\node[lab,acc,anchor=west,fill=white,inner sep=1.5pt] at ({a + 0.07},{m * 0.42:.4f}) {{$TG=m=\sqrt{{ab}}$}};") emit(rf"\draw[dim] (0,-0.42)--({a},-0.42) node[midway,below,lab] {{$a$}};") emit(rf"\draw[dim] ({a},-0.42)--({a + b},-0.42) node[midway,below,lab] {{$b$}};") emit(r"\node[anchor=west,align=left,font=\small] at (4.3,1.15) {" r"$\lambda\le\tfrac12:\ (a,b,\lambda)\mapsto(a,\,m,\,2\lambda)$\\[8pt]" r"$\lambda>\tfrac12:\ (a,b,\lambda)\mapsto(m,\,b,\,2\lambda-1)$\\[8pt]" r"gap: $\ b/a\ \mapsto\ \sqrt{b/a}$};") emit(r"\end{tikzpicture}%") end() # ------------------------------------------------------------------ Figure 5 def fig_depth(): ds = [6, 8, 12, 15] ha = [9, 12, 19, 24] pa = [2, 4, 6, 8] sx, sy = 0.9, 0.21 X = lambda d: (d - 5) * sx Y = lambda n: n * sy macro("figDepth") emit(r"\begin{tikzpicture}") for n in (0, 4, 8, 12, 16, 20, 24): emit(rf"\draw[line width=0.3pt,black!20] (0,{Y(n):.3f})--({X(16):.3f},{Y(n):.3f});") emit(rf"\node[lab,left] at (0,{Y(n):.3f}) {{{n}}};") emit(rf"\draw[rect] (0,{Y(27):.3f})--(0,0)--({X(16):.3f},0);") for d in ds: emit(rf"\draw[line width=0.6pt] ({X(d):.3f},0)--({X(d):.3f},-0.1);") emit(rf"\node[lab,below] at ({X(d):.3f},-0.1) {{{d}}};") for vals, col, nm in ((ha, "black!65", "harmonic--arithmetic readout"), (pa, "supp", "final Pad\\'e readout")): path = "--".join(f"({X(d):.3f},{Y(v):.3f})" for d, v in zip(ds, vals)) emit(rf"\draw[line width=1.2pt,{col}] {path};") for d, v in zip(ds, vals): emit(rf"\node[circle,fill={col},inner sep=2pt] at ({X(d):.3f},{Y(v):.3f}) {{}};") emit(rf"\node[lab,above,{col}] at ({X(d):.3f},{Y(v) + 0.05:.3f}) {{{v}}};") emit(rf"\node[lab,{col},anchor=west] at ({X(16) + 0.15:.3f},{Y(vals[-1]):.3f}) {{{nm}}};") emit(rf"\node[lab,anchor=south west] at (-0.45,{Y(27.3):.3f}) {{subdivisions $n$}};") emit(rf"\node[lab,anchor=north] at ({X(10.5):.3f},-0.6) {{digits $d$ of the target $\varepsilon=10^{{-d}}$\quad($X=2$)}};") emit(r"\end{tikzpicture}%") end() # ------------------------------------------------------------------ Figures 6-8 def cubic_rect(): return Rect(2.0, 4.0, 3, 2.0, 0.75) def fig_ak(): R = cubic_rect() K = (R.W * (1 - R.X / R.p), 0) T, Pp = R.step(R.A, (K[0] - R.W, K[1] - R.H)) assert abs((1 - Pp[1] / R.H) - R.p * R.s / (R.p - 1 + R.t)) < 1e-12 macro("figAK") emit(r"\begin{tikzpicture}[scale=1.5]") R.base() emit(rf"\draw[support] {c(R.A)}--{c(K)};") R.transport(T, Pp) R.corners() R.points(T, Pp, tl=None) emit(rf"\node[pt] at {c(K)} {{}};") emit(rf"\node[lab,below] at {c(K)} {{$K$}};") zoom(R, T, Pp, at=(3.1, 1.3), mag=3.0, extra=lambda: emit(rf"\draw[support] {c(R.A)}--{c(K)};")) emit(r"\end{tikzpicture}%") end() def fig_ad(): R = cubic_rect() p, X, W, H = R.p, R.X, R.W, R.H Oad = (W - 2 * W / (p - 1), H - H * (p + 1) / (X * (p - 1))) AE = H * R.s**p D = (Oad[0], Oad[1] - AE) T, Pp = R.step(R.A, (D[0] - W, D[1] - H)) kap = (p + 1 + (p - 1) * R.t) / 2 assert abs((1 - Pp[1] / H) - R.s * kap / (kap - 1 + R.t)) < 1e-12 macro("figAD") emit(r"\begin{tikzpicture}[scale=1.5]") R.base() emit(rf"\draw[accent] ({Oad[0]:.4f},{Oad[1]:.4f}) ++(215:{AE:.4f}) arc (215:325:{AE:.4f});") emit(rf"\draw[accent,densely dashed] {c(Oad)}--{c(D)};") emit(rf"\draw[accent,line width=2.2pt] {c(R.A)}--{c(R.E)};") emit(rf"\draw[support] {c(R.A)}--{c(D)};") R.transport(T, Pp) emit(rf"\node[lab,above left] at {c(R.O)} {{$O$}};") emit(rf"\node[lab,above right] at {c(R.A)} {{$A$}};") emit(rf"\node[lab,anchor=east] at (-0.06,-0.02) {{$C=O_{{\mathrm{{AD}}}}$}};") emit(rf"\node[lab,below right] at {c(R.B)} {{$B$}};") R.points(T, Pp, tl=None) emit(rf"\node[pt] at {c(D)} {{}};") emit(rf"\node[lab,below] at {c(D)} {{$D_{{\mathrm{{AD}}}}$}};") emit(rf"\node[lab,acc,anchor=west] at ({W + 0.08:.4f},{(H + R.E[1]) / 2 + 0.3:.4f}) {{length $AE=Hs^p$}};") emit(rf"\node[lab,acc,anchor=west] at (1.3,-1.25) {{arc of radius $AE$ centred at $O_{{\mathrm{{AD}}}}$}};") zoom(R, T, Pp, at=(3.1, 1.0), mag=3.0, extra=lambda: emit(rf"\draw[support] {c(R.A)}--{c(D)};")) emit(r"\end{tikzpicture}%") end() def fig_projective(): R = cubic_rect() p, X, W, H, t = R.p, R.X, R.W, R.H, R.t ly = H * (1 + (5 * p - 1) / ((p + 1) * X)) Z = (W * (1 + (5 * p - 1) / (2 * p * (2 * p - 1))), H * (1 + (p + 1) / ((2 * p - 1) * X))) D = meet(Z, (R.E[0] - Z[0], R.E[1] - Z[1]), (0, ly), (1, 0)) T, Pp = R.step(R.A, (D[0] - W, D[1] - H)) kap = 2 * p * ((2 * p - 1) * t + p + 1) / ((p + 1) * t + 5 * p - 1) assert abs((D[1] - H) / (D[0] - W) * W * X / H - kap) < 1e-12 assert abs((1 - Pp[1] / H) - R.s * kap / (kap - 1 + t)) < 1e-12 macro("figProjective") emit(r"\begin{tikzpicture}[scale=1.0]") emit(rf"\draw[aux] (-1.6,{ly:.4f})--(9.6,{ly:.4f});") emit(rf"\node[lab,anchor=south west] at (-1.6,{ly:.4f}) {{prepared horizontal $\ell$}};") R.base() emit(rf"\draw[accent] {c(R.E)}--{c(D)};") emit(rf"\draw[support] {c(T)}--{c(D)};") R.transport(T, Pp) R.corners(al="above left") R.points(T, Pp, tl=None) for q in (Z, D): emit(rf"\node[pt] at {c(q)} {{}};") emit(rf"\node[lab,right] at ({Z[0] + 0.08:.4f},{Z[1]:.4f}) {{$Z_{{\mathrm{{proj}}}}$}};") emit(rf"\node[lab,above right] at {c(D)} {{$D_{{\mathrm{{proj}}}}$}};") emit(rf"\node[lab,acc,anchor=west] at (3.95,8.4) {{line $Z_{{\mathrm{{proj}}}}E$}};") emit(rf"\node[lab,supp,anchor=east] at (2.95,7.6) {{support $AD_{{\mathrm{{proj}}}}$}};") zoom(R, T, Pp, at=(3.9, 0.25), mag=4.0, extra=lambda: emit(rf"\draw[support] {c(T)}--{c(D)};")) emit(r"\end{tikzpicture}%") end() def fig_mb(): R = cubic_rect() T, Pp = R.step(R.M, (R.B[0] - R.M[0], R.B[1] - R.M[1])) Sig = sum(R.s**j for j in range(R.p)) assert abs((1 - Pp[1] / R.H) - (1 - (R.X - 1) / (R.X * Sig))) < 1e-12 macro("figMB") emit(r"\begin{tikzpicture}[scale=1.5]") R.base() emit(rf"\draw[support] {c(R.M)}--{c(R.B)};") R.transport(T, Pp) emit(rf"\node[lab,above left] at {c(R.O)} {{$O$}};") emit(rf"\node[lab,above right] at {c(R.A)} {{$A$}};") emit(rf"\node[lab,below left] at {c(R.C)} {{$C$}};") emit(rf"\node[lab,below right] at {c(R.B)} {{$B$}};") R.points(T, Pp, tl=None) zoom(R, T, Pp, at=(3.1, 1.3), mag=3.2, extra=lambda: emit(rf"\draw[support] {c(R.M)}--{c(R.B)};")) emit(r"\end{tikzpicture}%") end() # ------------------------------------------------------------------ three-mean support def mean_consts(p): m = (p - 2) * (47 * p**2 + 21 * p + 4) / (60 * p * (4 * p**2 - 1)) g = 16 * (p + 1) * (4 * p**2 - 1) / (15 * p * (5 * p**2 + 4)) n = 49 * p * (p + 1) * (p**2 - 4) / (10 * (4 * p**2 - 1) * (5 * p**2 + 4)) d = (5 * p**2 + 4) / (84 * p**2) return m, g, n, d def fig_mean(): from math import atan2, degrees p, X, H, s = 3, 2.0, 4.0, 0.75 m, g, n, d = mean_consts(p) lam = H / X zeta = 1 / (2 * d) - 1 W = lam * (n / m) * sqrt((1 - 4 * d) / (4 * d)) # prescribed aspect ratio R = Rect(W, H, p, X, s) t, M, E, A = R.t, R.M, R.E, R.A gam = 1 + 2 * (p - 1) * m delta = W / gam xv = W - delta Kg = (delta / W) * lam * (p - 1) * g Kn = (delta / W) * lam * (p - 1) * n * sqrt(d) x1, x2, x3 = delta * (p - 1) * m, W * Kg / (2 * lam), W * Kn / lam yME = lambda x: M[1] + R.sigma * x N1, N2, N3 = (x1, yME(x1)), (x2, yME(x2)), (x3, yME(x3)) G2, F2, G3 = (x2, M[1] + Kg), (x2, M[1]), (x3, M[1] + Kn * (1 + zeta)) r1 = G3[1] - N3[1] assert abs((xv - x1) - Kn * sqrt(zeta**2 - 1)) < 1e-12 D1 = (xv, N1[1] + sqrt(r1**2 - (xv - x1) ** 2)) r2 = G2[1] - N2[1] Z = (x2 + sqrt(r2**2 - (M[1] - N2[1]) ** 2), M[1]) r3 = Z[0] - F2[0] D = (xv, D1[1] - r3) q = m * (1 + t) + g * sqrt(t) - n * sqrt(t + d * (t - 1) ** 2) kap = (H - D[1]) / (W - D[0]) * W * X / H assert abs(kap - (1 + (p - 1) * q)) < 1e-12 T, Pp = R.step(A, (D[0] - W, D[1] - H)) assert abs((1 - Pp[1] / H) - s * kap / (kap - 1 + t)) < 1e-12 def arc(cen, rad, a0, a1): emit(rf"\draw[accent] ({cen[0]:.4f},{cen[1]:.4f}) ++({a0:.2f}:{rad:.4f}) arc ({a0:.2f}:{a1:.2f}:{rad:.4f});") macro("figMean") emit(r"\begin{tikzpicture}[scale=1.28]") for xx in (x3, x1, xv, x2): emit(rf"\draw[aux] ({xx:.4f},-0.75)--({xx:.4f},5.45);") emit(rf"\draw[aux] (0,{M[1]:.4f})--(9.25,{M[1]:.4f});") R.base() emit(rf"\draw[accent,line width=2.2pt] {c(N3)}--{c(G3)};") emit(rf"\draw[accent,line width=2.2pt] {c(F2)}--{c(Z)};") a = degrees(atan2(D1[1] - N1[1], D1[0] - N1[0])) arc(N1, r1, a - 36, a + 36) a = degrees(atan2(Z[1] - N2[1], Z[0] - N2[0])) arc(N2, r2, a - 14, 90) arc(D1, r3, -113, -67) emit(rf"\draw[support] {c(A)}--{c(D)};") R.transport(T, Pp) R.corners(cl="below left", bl="below right", al="above right") R.points(T, Pp, tl="above left", pl="right", ppl="below right") for qq in (N1, N2, N3, G2, G3, F2, D1, Z, D): emit(rf"\node[pt] at {c(qq)} {{}};") emit(rf"\node[lab,below left,trans] at {c(N3)} {{$J_3$}};") emit(rf"\node[lab,below right,trans] at ({N1[0] - 0.05:.4f},{N1[1]:.4f}) {{$J_1$}};") emit(rf"\node[lab,above left,trans] at {c(N2)} {{$J_2$}};") emit(rf"\node[lab,left] at {c(G3)} {{$G_3$}};") emit(rf"\node[lab,left] at {c(G2)} {{$G_2$}};") emit(rf"\node[lab,below left] at {c(F2)} {{$F$}};") emit(rf"\node[lab,above right,acc] at {c(D1)} {{$D_1$}};") emit(rf"\node[lab,above right,acc] at {c(Z)} {{$Z$}};") emit(rf"\node[lab,below right,supp] at {c(D)} {{$D_M$}};") emit(rf"\node[lab,acc,anchor=west] at ({N1[0] + 0.85:.4f},{D1[1] + 0.5:.4f}) {{arc 1}};") emit(rf"\node[lab,acc,anchor=west] at ({N2[0] + 2.25:.4f},4.35) {{arc 2}};") emit(rf"\node[lab,acc,anchor=west] at ({xv + 1.0:.4f},{D[1] + 0.02:.4f}) {{arc 3}};") emit(rf"\node[lab,supp,anchor=south east] at (4.55,2.55) {{support $AD_M$}};") for xx, nm in ((x3, "v_3"), (x1, "v_1"), (xv, "v"), (x2, "v_2")): anchor = "south east" if nm == "v_3" else "south west" emit(rf"\node[font=\footnotesize,black!60,anchor={anchor}] at ({xx:.4f},5.42) {{${nm}$}};") emit(r"\end{tikzpicture}%") end() emit(PRE) fig_arc() fig_means() fig_support() fig_subdivision() fig_depth() fig_ak() fig_ad() fig_projective() fig_mb() fig_mean() print("\n".join(OUT))