Commit a7cfcf09c6071d5bf2ce4cdd3382401054414a86

These are also wrong.
c/azy.c
(14 / 32)
  
216216
217217bool azy_guess_radius(double* const result_,
218218 struct position const* const p0,
219 struct position const* const p1/*t0*/,
220 struct position const* const p2/*t3*/,
219 struct position const* const t0,
220 struct position const* const t3,
221221 struct position const* const p3,
222 double const ai,
223222 double const ac,
224 double const rfree,
225 double const rindet) {
226 double k01, k02, k03, k12, k13, k23;
227 azy_determinant(&k01, p0, p1);
228 azy_determinant(&k02, p0, p2);
229 azy_determinant(&k03, p0, p3);
230 azy_determinant(&k12, p1, p2);
231 azy_determinant(&k13, p1, p3);
232 azy_determinant(&k23, p2, p3);
233 double const q1 = 20 * (ac - ai) / 3 - 3 * k03;
234 double const q2 = 2 * (k01 + k23) - k02 - k13;
235 double const q3 = k12;
223 double const ai,
224 double const rfree) {
225 double const q2 = 2 * ((p0->y - p3->y) * t0->x
226 + (p3->x - p0->x) * t0->y
227 + (p0->y - p3->y) * t3->x
228 + (p3->x - p0->x) * t3->y);
229 double const q3 = t0->y * t3->x - t0->x * t3->y;
236230 double r;
237 if (q1 == 0) {
238 if (q3 == 0)
239 r = rfree;
240 else
241 r = -q2 / q3;
242 } else {
243 double const d = q2 * q2 - 4 * q1 * q3;
244 double const m = -1 / (2 * q1);
245 if (d < 0)
246 r = rindet;
247 else if (d == 0)
248 r = q2 / m;
249 else // Which one to choose?
250 r = fmax((q2 + sqrt(d)) / m,
251 (q2 - sqrt(d)) / m);
252 }
231 if (q3 == 0)
232 r = rfree;
233 else
234 r = -q2 / q3;
253235
254236 *result_ = r;
255237
729729 double radius;
730730 say("Guessing for areas %f and %f.", ai, ac);
731731 azy_guess_radius(&radius, &starter, &start_normal, &end_normal, &ender,
732 ai, ac, 0, 0);
732 ac, ai, 1);
733733 say("Fun radius %f.", radius);
734734 radius = 100;
735735 // Some heuristic.
log/log.tex
(16 / 6)
  
197197 & = A_i + A_r
198198 \Leftrightarrow \\
199199 \frac{20} 3 (A_c - A_i) - \frac{20} 3 A_r
200 & = 0
201 \Leftrightarrow \\
202 \frac{20} 3 (A_c - A_i) - 3 K_4^1 + r (2 K_2^1 + 2 K_4^3 + K_3^1 + K_4^2) + r^2 K_3^2
203200 & = Q_1 + r Q_2 + r^2 Q_3
204201 = 0
205202 \Leftrightarrow \\
206203 r
207 & = -\frac{Q_2 \pm \sqrt{Q_2^2 - 4 Q_1 Q_3}}{2 Q_1}.
204 & = -\frac{Q_2 \pm \sqrt{Q_2^2 - 4 Q_1 Q_3}}{2 Q_1},
208205\end{align*}
206where
207\begin{align*}
208 Q_1
209 & = 0 \\
210 Q_2
211 & = \frac 3{10} ((P_1^y - P_4^y) \bar T_1^x
212 + (P_4^x - P_1^x) \bar T_1^y
213 + (P_1^y - P_4^y) \bar T_4^x
214 + (P_4^x - P_1^x) \bar T_4^y) \\
215 Q_3
216 & = \frac 3{20} (\bar T_1^y \bar T_4^x
217 - \bar T_1^x \bar T_4^y).
218\end{align*}
209219Does it always have a solution (as in $Q_2^2 \ge 4 Q_1 Q_3$)?
210Hope so!
211If $Q_1 = 0$ then either $r = 0$, which is ridiculous, or
220Indeed it does, because $Q_1 = 0$.
221Therefore either $r = 0$, which is ridiculous, or
212222\begin{align*}
213223 Q_2 + r Q_3
214224 & = 0