Hi new programmer, the answer I can give you is something that uses array, functions and, in the best case scenario, object-oriented programming (makes it easier, it's not actually required at all). I haven't ever used graphics.h, but lately I've been obsessed with circles in console, therefore I can present something you can do (it's generic, not necessarily for console. It can also be used for bitmap images).
Now, since I am not sure what you mean by "2/3 quadrants" (at first I thought it meant that a quadrant=2 thirds of a circle, but it didn't make sense to me), and since I suppose it refers to "2 or 3 quadrants", then I will answer accordingly.
1. Determine the circle's radius.
1.1. If you want the circle to be in the top left corner, then ignore 1.2.
1.2. Determine the point around which you want to draw the circle (x and y coordinates).
2. Using circle defining algorithms found on the internet (i use midpoint circle algorithm), you can create your circle and (i recommend doing this) put it into an array or, even better, in a std::string object.
3. I start with the middle, rightmost point, but you can start anywhere
(I highly recommend you start in one of the four quadrant intersections, and here are the 4 equations:
top point:
x=center dot's x coordinate
y=center dot's y coordinate-radius
bottom point:
x=center dot's x coordinate
y=center dot's y coordinate+radius
left point:
x=center dot's x coordinate-radius
y=center dot's y coordinate
right point:
x=center dot's x coordinate+radius
y=center dot's y coordinate)
4. You can use equations to project lines from the center, through a dot and on the circle (but I haven't really written the whole thing down), or this (it's generic and not found in libraries):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
//start with the rightmost point
int start_x=center_x+radius;
int start_y=center_y;
int final_x=start_x;
int final_y=start_y
//circle can be any array, and you only have to mention, inside the function, what a point means in
//that array
int numberOfDots=functionGetNumberOfDots(circle);
//since a circle has 360 degrees, then a point is (360/the number of points) degrees.
float angleRatio=360./float(numberOfPoints);
//this is for 3 equal quadrants, each having a third degrees of a full circle
float quadrant=120.;
for (float initialAngle=0; initialAngle<quadrant; initialAngle+=angleRatio)
{
//this moves the dot along the circle's circumference
moveCounterClockwise(final_x, final_y);
}
//now that you have the arc (quadrant) of the circle, draw 2 lines: from center to start point and
//from center to final point
line(circle, center_x, center_y, start_x, start_y);
line(circle, center_x, center_y, final_x, final_y);
fillSector(circle);
drawSector(circle, color);
|
You can use this "pseudocode prototype" or whatever it could be called, and you should be all right.