How to draw anti-aliased circle in OpenGL?

Draw horizontal and vertical lines lines inside a circle.?

  • please specify how to draw horizontal lines inside a circle, like the chords of circle;

  • Answer:

    Well, I'm not doing the MATH, per se, but the method of making an answer is easy. You have your circle, and you know the radius. So to begin, half your circle horizontally. Twice the radius gives you your first line, the base of the rising moon, as it looks like. Then you ascend vertically, after arbitrarily dividing it into increments. If you want 3 more lines above it, divide the radius by 4...the uppermost line is a point, as it rests on the apex of the half moon. Note that you will always wind up with one less line than you have increments, as by definition a line that just touches a circle in one place is a tangent line, and not a chord. Draw each parallel line through the rising increments of the perpendicular radius to the line at the base of the half moon, but check the value of the ends to see if they are bounded inside the scribe of the circle. The trigonometry functions are very important in doing this, especially the sine function (I'm assumming that you are writing a program to do this). If the value of X (where that point is in the X-axis) is outside of the circle at that particular Y (the increment on the Y-axis), throw that X value away...don't use it to draw that part of the line. In other words, only use X values that are on the circle or inside the circle to draw your lines. After reaching the upper-most increment, the line of which should be of length zero because it is on the circle, you can then just make a reflection of the whole thing, so a copy becomes the bottom of the circle, with it's horizontal lines already made. To get the vertical lines, you can either make another copy of this circle with horizontal lines and rotate it 90 degrees, or pi/4 radians, to get the vertical lines...or solve it incrementally as I had the first circle, but using the cosine function in place of the sine to do your bounds checking, and a vertical "base" of a half moon turned up on one "tip"...kind of like the letter "D". Just make sure you wind up superimposing these circles on top of each other so that it appears to be one circle with crosshatched lines. When I did it for class, it helped that I did it by hand first...i.e. using a scribing compass and ruler, I followed each step, then figured out how to tell the computer how to do what I had done. Graphic calculators are a little harder to figure out how to instruct, at least to me, but only because you have to figure out the equations to use before you enter them into the beasts. The "Big Three" in calculators, Texas Instruments, Casio, and HP, use their own particular way to input the equations...there is no universal method of entering an equation, unfortunantly.

aqeel m at Yahoo! Answers Visit the source

Was this solution helpful to you?

Other answers

8 lines across

chasen54

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.