title: Can you explain this Bresenham's Circle implementation?
body: <p>I'm studying a paper in which the author claims to use Bresenham circles to scan the area around a pixel efficiently. I studied the algorithm but the equations used in most websites I've seen are way different from the author's implementation. Have a look:</p>
  <pre><code>//center(center.x,center.y) is the circle's center pixel. 
  int err = 0;
  int dx = _radius;
  int dy = 0;
  int plus = 1;
  int minus = (_radius &lt;&lt; 1) - 1;
  int olddx = dx;
  
  while (dx&gt;=dy){
      int mask;
      int y=center.y-dy;
      int x=center.x-dx;
      //Found p(x,y).
      //Pixel operations here, not included, not relevant...
      //
  
      //Now the update. How do they check whether to decrease dx or not??
      dy++;
      err += plus;
      plus += 2;
      
      mask = (err &lt;= 0) - 1;
      
      err -= minus &amp; mask;
      dx += mask;
      minus -= mask &amp; 2;
  }
  </code></pre>
  <p>I understand that we only find the pixels of one octant. I understand that we start from (center.x-radius,center.y). So, as we travel along the corresponding octant, dy always increases but dx needs to pass a test to decrease. I've been trying to figure out how the test is done here but with no luck.</p>
  <p><code>plus, minus, mask, err </code></p>
  <p>What do these represent? Any ideas? It's either a simplification of Bresenham's circle algorithm for a faster scan with less computations or a completely different one?</p>
  <p>I think I can only understand how <code>mask</code> is defined. If the error <code>err</code>(which we usually have formulas for) is negative, dx stays the same according to the Bresenham algorithm. <code>mask</code> makes sure this is the case here as well.  As for how the error is calculated here and how it's connected to <code>plus</code> and <code>minus</code>, I have no idea.</p>