If I understood what you want, the basic idea would be to calculate
the points of the polygon for each angle/bin, and fill it with the
appropriate color. The code below should calculate the points:
It can be made a bit more efficient, since the code above re-calculatesCode:const int n_angles = 360; const int n_bins = 512; const double radius = 100.0; // size of circle on screen const double angle_inc = 2.0 * 3.14159 / static_cast<double>(n_angles); const double bin_inc = radius / static_cast<double>(n_bins); for (int i=0; i<n_angles; ++i) { for (int j=0; j<n_bins; ++j) { double angle1 = angle_inc * i; double angle2 = angle_inc * (i+1); double r1 = bin_inc * j; double r2 = bin_inc * (j+1); double x1 = r1 * cos(angle1); double y1 = r1 * sin(angle1); double x2 = r2 * cos(angle1); double y2 = r2 * sin(angle1); double x3 = r2 * cos(angle2); double y3 = r2 * sin(angle2); double x4 = r1 * cos(angle2); double y4 = r1 * sin(angle2); // fill in the polygon consisting of the points: // (x1,y1) , (x2,y2) , (x3,y3) , (x4,y4) } }
some sin/cos values more than it needs to.
(Code not tested).




Reply With Quote