Here is the relevant part of the solution:
for ( r=0; r<nrows; r++ ) for ( c=0; c<ncols; c++ ) { dist = sqrt( (r-cntR)*(r-cntR) + (c-cntC)*(c-cntC)) ; thetaCC = atan2( (c-cntC), (r-cntR) ); radians = 2*M_PI*(dist/radius)*1.0 + thetaCC ; red = 125 + 125*cos( radians*redCycles ); grn = 125 + 125*cos( radians*grnCycles ); blu = 125 + 125*cos( radians*bluCycles ); fputc( red, image ); fputc( grn, image ); fputc( blu, image ); }
Comments: Most of the work in this program is in collecting parameters from the command line.