title: Coordinates of every point on a circle's circumference
body: <p>First, please note, that this question is not a duplicate of these: <a href="https://stackoverflow.com/questions/839899/how-do-i-calculate-a-point-on-a-circle-s-circumference">1st</a> , <a href="https://stackoverflow.com/questions/674225/calculating-point-on-a-circles-circumference-from-angle-in-c">2nd</a> , and <a href="https://stackoverflow.com/questions/4600741/how-to-calculate-the-x-or-y-coordinate-of-point-on-a-circumference-of-a-circle">3rd</a>.</p>
  
  <p>I am using delphi and openCV, but I am looking for an algorithm, a solution regardless of the language.</p>
  
  <p>For the purpose of a precise image analysis, I need to check for changes in pixel intensity in circular areas. So I read pixel values on a circumference of continuously growing circle. To be able to do that, I of course need to know coordinates of the pixels. </p>
  
  <p>The best solution I found is <code>y:= Round(centerY + radius * sin(angle)), x:= Round(centerX + radius * cos(angle))</code>, while because counting with only 360 degrees is hardly enough, when the radius of the circle is larger, than circa 60px, the angle is being counted like this <code>angle:= angle + (360 / (2 * 3.14 * currentRadius))</code> -> I sweep through every value from 0 to 360, while the value is being incremented by a fraction of 360/circumference of the circle in pixels. But this approach is not very precise. The larger the circle, the smaller the fraction of the angle needs to be and the precission suffers from the inaccuracy of Pi, plus the rounding.</p>
  
  <p>If I use the mentioned method, and try to draw the counted pixels with this code:</p>
  
  <pre><code>  centerX:= 1700;
    centerY:= 1200;
    maxRadius:= 500;
  
    for currentRadius:= 80 to maxRadius do
    begin
  
      angle:= 0;
      while angle &lt; 360 do
      begin
  
        xI:= Round(centerX + currentRadius * cos(angle));
        yI:= Round(centerY + currentRadius * sin(angle));
        angle:= angle + (360 / (2 * 3.14 * currentRadius));
  
        //this is openCV function, to test the code, you can use anything, that will draw a dot...
        cvLine(image,cvPoint(xI,yI),cvPoint(xI,yI),CV_RGB(0, 255, 0));
  
      end;
  
    end;
  </code></pre>
  
  <p>the result is this:
  <a href="https://i.stack.imgur.com/68FIS.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/68FIS.jpg" alt="circles"></a></p>
  
  <p>It is not bad, but taking into account, that rougly a third of all pixels in the circular area are black, you realize, that a lot of pixels has been "skipped". Plus looking closely on the edge of the last circle, there is clearly visible, that some dots are off the actual circumference - another result of the inaccuracy...</p>
  
  <p>I could possibly use a formula <code>(x - xorig)^2 + (y - yorig)^2 = r^2</code> to check every possible pixel in a rectangular area around the center, slightly bigger, than a diameter of the circle, if it does, or does't fall onto the cirle's circumference. But that would be very slow to repeat it all the time, as the circle grows.</p>
  
  <p>Is there something, that could be done better? Could anyone help me to improve this? I don't insist on anything from my solution at all, and will accept any other solution, as long as it gives the desired results => let me read values of <strong>all</strong> (or the vast majority - 95%+) pixels on a circumference of a circle with given center and radius. The faster, the better...</p>