<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: G33kDaddy “G33Kdaddy”</title>
    <description>The latest articles on DEV Community by G33kDaddy “G33Kdaddy” (@g33kdaddy_g33kdaddy_7e5).</description>
    <link>https://dev.to/g33kdaddy_g33kdaddy_7e5</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3990496%2Fa9593149-954a-4f61-bd36-f1d9c8c5e5c9.png</url>
      <title>DEV Community: G33kDaddy “G33Kdaddy”</title>
      <link>https://dev.to/g33kdaddy_g33kdaddy_7e5</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/g33kdaddy_g33kdaddy_7e5"/>
    <language>en</language>
    <item>
      <title>DTFC — Draw The F***ing Circle</title>
      <dc:creator>G33kDaddy “G33Kdaddy”</dc:creator>
      <pubDate>Thu, 18 Jun 2026 08:36:32 +0000</pubDate>
      <link>https://dev.to/g33kdaddy_g33kdaddy_7e5/dtfc-draw-the-fing-circle-5bo</link>
      <guid>https://dev.to/g33kdaddy_g33kdaddy_7e5/dtfc-draw-the-fing-circle-5bo</guid>
      <description>&lt;p&gt;&lt;em&gt;Or: the story of a bug that turned out to be more correct than the correct code&lt;/em&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Boot sequence
&lt;/h2&gt;

&lt;p&gt;Year: somewhere between 1983 and 1987.&lt;br&gt;
Iron: a custom board — &lt;strong&gt;Motorola 68000&lt;/strong&gt; (32-bit. Pure luxury. The HW team argued about it for a week.) and a &lt;strong&gt;Texas Instruments TMS34010&lt;/strong&gt;, one of the first programmable graphics chips on the planet.&lt;br&gt;
VRAM: &lt;strong&gt;256 kilobytes&lt;/strong&gt;. That's not a typo.&lt;br&gt;
Mass storage: &lt;strong&gt;20 megabytes&lt;/strong&gt;. Total. Bare SCSI-like interface, no OS.&lt;br&gt;
Mission: rasterize A0 architectural drawings at 400 dpi.&lt;/p&gt;

&lt;p&gt;RTFM and do the math:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;A0 = 841 × 1189 mm
At 400 dpi → ~13,300 × 18,700 pixels
1 bit per pixel → ~30 MB
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The output bitmap &lt;strong&gt;did not fit on the disk&lt;/strong&gt;.&lt;br&gt;
The disk that also held the OS, the FAT, the filesystem driver,&lt;br&gt;
the application, and the quadtree-compressed source drawing.&lt;br&gt;
Every byte was hand-negotiated. Every cycle was audited.&lt;br&gt;
The entire stack — OS, filesystem, elevator disk scheduler, swap system — was written from scratch, in assembly or C, by some people with a logic analyzer and too much coffee.&lt;/p&gt;

&lt;p&gt;This is the environment in which one needed to DTFC.&lt;/p&gt;


&lt;h2&gt;
  
  
  The textbook solution (a.k.a. the one that doesn't run)
&lt;/h2&gt;

&lt;p&gt;The clean approach: place a point on the circle, then &lt;strong&gt;rotate it step by step&lt;/strong&gt; around the origin.&lt;br&gt;
Standard rotation matrix, angle &lt;code&gt;a = 2π/N&lt;/code&gt; for N steps:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;| cos(a)  -sin(a) |     applied to     | x |
| sin(a)   cos(a) |                    | y |
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="kt"&gt;float&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;N&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;plot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="kt"&gt;float&lt;/span&gt; &lt;span class="n"&gt;nx&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;cos&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;sin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="kt"&gt;float&lt;/span&gt; &lt;span class="n"&gt;ny&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;sin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;cos&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;nx&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ny&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Mathematically perfect. Beautiful.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Totally unrunnable&lt;/strong&gt; on 8-bit era hardware.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;No FPU. Not even close.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;cos()&lt;/code&gt; and &lt;code&gt;sin()&lt;/code&gt;? Lookup tables eat precious RAM.
Computing them costs &lt;strong&gt;dozens of cycles each&lt;/strong&gt;, on a CPU where
the budget per pixel was counted on fingers.&lt;/li&gt;
&lt;li&gt;Four multiplications per step. On a 68000, a 16×16 multiply was a &lt;em&gt;luxury instruction&lt;/em&gt;. You felt it in the profiler. (Hmm.. actually... there was &lt;em&gt;no&lt;/em&gt; profiler. You felt it in your soul.)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Abort. Reboot. Think harder.&lt;/p&gt;




&lt;h2&gt;
  
  
  Patch #1 — Nuke the trig
&lt;/h2&gt;

&lt;p&gt;For a small angle &lt;code&gt;a&lt;/code&gt;, Taylor says:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cos(a) ≈ 1
sin(a) ≈ a
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Plug that into the rotation matrix:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;| 1   -a |
| a    1 |
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The loop becomes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="kt"&gt;float&lt;/span&gt; &lt;span class="n"&gt;nx&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kt"&gt;float&lt;/span&gt; &lt;span class="n"&gt;ny&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;nx&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ny&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Zero trig. Two multiplications by a constant &lt;code&gt;a&lt;/code&gt;. Progress.&lt;/p&gt;

&lt;p&gt;Ship it? Not yet. Those two multiplications still hurt.&lt;/p&gt;




&lt;h2&gt;
  
  
  Patch #2 — Nuke the multiplications
&lt;/h2&gt;

&lt;p&gt;If &lt;code&gt;a = 1/2^n&lt;/code&gt;... multiplications become &lt;strong&gt;right bit shifts&lt;/strong&gt;.&lt;br&gt;
And dropping the temp variables is EZ PZ:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Zero multiplications.&lt;/strong&gt; Shifts and adds only.&lt;br&gt;
In 16-bit fixed-point (8.8 format), this is &lt;strong&gt;3-4 cycles per point&lt;/strong&gt;.&lt;br&gt;
At 8 MHz: tens of thousands of circle points per second.&lt;br&gt;
The plotter can't even keep up.&lt;/p&gt;

&lt;p&gt;One ran it.&lt;/p&gt;

&lt;p&gt;The circle closed perfectly.&lt;/p&gt;

&lt;p&gt;Ship it.&lt;/p&gt;


&lt;h2&gt;
  
  
  Wait. There's a bug here.
&lt;/h2&gt;

&lt;p&gt;Look at that code again. &lt;em&gt;Really&lt;/em&gt; look at it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;   &lt;span class="cm"&gt;/* x is modified HERE...         */&lt;/span&gt;
&lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;   &lt;span class="cm"&gt;/* ...NEW x is reused here. OOPS. */&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's not the same as the clean version with a temp variable.&lt;br&gt;
That's an &lt;strong&gt;in-place update bug&lt;/strong&gt; — the classic freshman mistake, the thing that gets you a raised eyebrow in code review.&lt;/p&gt;

&lt;p&gt;And there's worse. Look at the approximation matrix in the maths above:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;| 1   -a |     det = 1×1 − (−a)×a = 1 + a²
| a    1 |
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Determinant &lt;strong&gt;greater than 1&lt;/strong&gt;. Every step should &lt;em&gt;expand&lt;/em&gt; the radius slightly.&lt;br&gt;
After N iterations, the spiral should drift &lt;strong&gt;outward&lt;/strong&gt;. The circle should not close.&lt;/p&gt;

&lt;p&gt;And yet. No drift. No spiral. Closed.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;How.&lt;/em&gt;&lt;/p&gt;


&lt;h2&gt;
  
  
  POST-MORTEM — what the "bug" actually computes
&lt;/h2&gt;

&lt;p&gt;Let's expand what that broken code actually does, algebraically:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;x' = x - y*a
y' = y + x'*a
   = y + (x - y*a)*a
   = y + x*a - y*a²
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The implicit transformation matrix is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;|  1      -a   |
|  a    1-a²   |
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Determinant:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1×(1−a²) − (−a)×a
= 1 − a² + a²
= 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Exactly 1.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Not approximately. Not "close enough for graphics work".&lt;br&gt;
&lt;strong&gt;Exactly, algebraically, provably 1 — for 'any' value of &lt;code&gt;a&lt;/code&gt;.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The "buggy" in-place update doesn't just &lt;em&gt;compensate&lt;/em&gt; for the spiral drift.&lt;br&gt;
It &lt;strong&gt;perfectly cancels it&lt;/strong&gt; — the &lt;code&gt;+a²&lt;/code&gt; from the approximation error and the &lt;code&gt;−a²&lt;/code&gt; from the in-place reuse cancel each other out, identically.&lt;/p&gt;

&lt;p&gt;The bug fixed the bug.&lt;/p&gt;




&lt;h2&gt;
  
  
  DTFC — final, shipped, still running
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="cm"&gt;/*
** DTFC - Draw The F***ing Circle
**
** Radius r, centered at origin.
** N steps for a full revolution.
** shift = bit precision (e.g. shift=6 means a ≈ 1/64)
**
** No sin(). No cos(). No multiply. No temp variable.
** Just shifts, adds, and one algebraically perfect "mistake".
**
** Determinant = 1. Circle closes. Every time.
*/&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;N&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;plot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;shift&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;   &lt;span class="cm"&gt;/* wrong order. keep it. */&lt;/span&gt;
    &lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;shift&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;   &lt;span class="cm"&gt;/* new x. intentional.   */&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Runs on a Z80. Runs on a 6809. Runs on a TMS34010. Could run on your Arduino right now.&lt;br&gt;
Three lines of logic. Zero trig. Zero multiply.&lt;br&gt;
One preserved determinant hiding in plain sight.&lt;/p&gt;




&lt;h2&gt;
  
  
  AFAIK never saw this trick in a textbook
&lt;/h2&gt;

&lt;p&gt;This trick sits at the junction of:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Numerical analysis&lt;/strong&gt; — linearization of transcendental functions&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Linear algebra&lt;/strong&gt; — determinant as area-preservation invariant&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hardware archaeology&lt;/strong&gt; — shift-only fixed-point arithmetic&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Accidental correctness&lt;/strong&gt; — the bug that was righter than the fix&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It was never written down, to anyone's knowledge.&lt;br&gt;
It lived in the fingertips of engineers at &lt;strong&gt;Benson&lt;/strong&gt;, &lt;strong&gt;Schlumberger Graphics&lt;/strong&gt;, &lt;strong&gt;OCE&lt;/strong&gt; — people who built A0 plotters and raster engines when RAM was rationed and every cycle had a name.&lt;/p&gt;

&lt;p&gt;One colleague — from &lt;strong&gt;Sun Microsystems&lt;/strong&gt;, where he had just taped out &lt;strong&gt;the first hardware triangle rasterizer ever built in silicon&lt;/strong&gt; — kept &lt;em&gt;Graphics Gems&lt;/em&gt; on his desk, beside Knuth's bibles.&lt;/p&gt;

&lt;p&gt;This trick deserved a page in it.&lt;/p&gt;

&lt;p&gt;It didn't get one.&lt;/p&gt;

&lt;p&gt;Consider this that page.&lt;/p&gt;




&lt;h2&gt;
  
  
  Halt and catch fire
&lt;/h2&gt;

&lt;p&gt;Sometimes the bug is smarter than the programmer.&lt;br&gt;
Sometimes the constraint &lt;em&gt;is&lt;/em&gt; the algorithm.&lt;br&gt;
And sometimes, at 8 MHz with 256k of VRAM and a plotter spooling A0 drawings for architects who will never know, one accidentally writes something that is more correct than the correct version.&lt;/p&gt;

&lt;p&gt;The circle closed. It always closed.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;— Recovered from memory, ~40 years post-silicon. Still compiles. Still works.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;P.S. — Should work with floating point too. The algebra doesn't care about your type system.&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Tags: &lt;code&gt;#8bit&lt;/code&gt; &lt;code&gt;#retrocomputing&lt;/code&gt; &lt;code&gt;#graphics&lt;/code&gt; &lt;code&gt;#fixedpoint&lt;/code&gt; &lt;code&gt;#TMS34010&lt;/code&gt; &lt;code&gt;#68000&lt;/code&gt;&lt;/em&gt;&lt;br&gt;
&lt;em&gt;&lt;code&gt;#circledrawing&lt;/code&gt; &lt;code&gt;#linearlgebra&lt;/code&gt; &lt;code&gt;#determinant&lt;/code&gt; &lt;code&gt;#GraphicsGems&lt;/code&gt; &lt;code&gt;#accidentalgenius&lt;/code&gt;&lt;/em&gt;&lt;/p&gt;

</description>
      <category>algorithms</category>
      <category>devjournal</category>
      <category>performance</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
