Getting the centriod of a circle Turbo C++
<p>It's me again. Turbo C++ is real ancient. I got a problem in getting my centriod of a circle, I have written a program to show me the co-ordinates of the centroid but the display shows me -NAN, -NAN instead of numbers. Please advice, thnx.</p>

<pre><code>unsigned char *p = rgbImage; //rbgImage = new unsigned char [ 160 * 120 * 4 ]
unsigned char *q = image; //image = new unsigned char [ 160 * 120 * 1 ]
int n = 0;
float LaserX = 0, LaserY = 0;
char* LaserMID = new char[255];

for( int j = 0; j &lt; 120; j++ ) {
    for( int i = 0; i &lt; 160; i++ ) {
        *q++ = *p++;
        if ( *q &gt;= Thrshld ) {
            LaserX += j;
            LaserY += i;
            n = n + 1;
        }
    }
}
LaserX = LaserX/n;
LaserY = LaserY/n;
sprintf(LaserMID, "%.1f, %.1f", LaserX, LaserY);
ShowCo-&gt;Text = LaserMID;
</code></pre>
