tga classباستخدام
Implement a circle drawing procedure (circlePolar) using polar equations. The procedure should take the center, radius, and a color as its input as well as a reference to the image. The procedure should take advantage of the symmetry of the circle and draw the circle as a collection of points. If the circle does not fit into the image an appropriate error message should appear.
Note: the trigonometric functions in C++ take angles in radians as their parameters, remember: 360 degrees = 2π radians and π = 3.14, therefore 1 degree = 3.14/180 radians..
[/size]
[size="3"]Change the following Midpoint algorithm to get rid of the multiplication to be an accurate implementation of the midpoint algorithm and to include an additional parameter for the image:
void circleMidpoint (int xC, int yC, int r)
{
int x=0, y=r, p=1-r;
plotSymmetricPoints(x,y,xC,yC);
while (x<y)
{ x++;
if(p<0)
p+= 2*x+1;
else{
y--;
p+= 2*x+1-2*y;}
plotSymmetricPoints(x,y,xC,yC);}}
Where plotSymmetricPoints(x,y,xC,yC) draws x,y, and it's 7 symmetric points.
Write a procedure that produces a pie chart. It should take the following as its input: the radius, the center, the number of sections, an int array of angular sizes of each section (need to add up to 360), a ColorChar array of the color of each section (other than black and white), and the image into which to place the chart. Define a constant MAXSECTION, set it to 20.
The procedure will draw the pie chart on white background with black circumference and black section divisions. Check for the correctness of the input within the procedure, if anything is incorrect display an appropriate message and abort the procedure for that chart. You need to make sure the pie chart fits within your image.
Test your procedure by drawing several pie charts within the same image (size 300x300). Also show your error handling by providing incorrect input to the procedure. The input data should be read from a file "input.txt" with the following format:
The first line should contain the number of pie charts to be drawn. Followed by a number of lines for each pie chart containing the following date on each line:
· radius xcenter ycenter numSections
· for each section one line containing: angle r g b
Bonus allow a section to be exploded by adding an additional parameter, if it is 0, no section is exploded, any other number represents the number of the section to be exploded. Demonstrate your procedure on 2 pie charts approximately like shown. You may use CirclePolar if you think it is necessary.