banner



How To Draw 4 Intersecting Circles

I have a fix of points and each 1 has an area of "influence" or essentially a radius. I would like to be able to draw each ane of these influence circles for all the points equally a simple circular line.

They will overlap however I wish to depict the outside of the shape formed. I know this would probably require me working out where they intersect and somehow forming a total shape to draw. The problem is that some points might not fifty-fifty impact others! So I need to exist able to work that out likewise.

I take attempted to illustrate what I mean simply:

enter image description here

Notation that I wish to draw simply the blackness line, no fill. This is because I wish groundwork images and other geometry to bear witness through.

I would be doing this in openGL so the circle would be probably fabricated using GL_LINES or some such with various vertices forming the curves just I really just don't accept whatever idea about how I would work out this perimeter.

If anyone has any communication or could point me at how I might go about working this out information technology would be profoundly appreciated!

This might be more than of a maths question, I am not looking for bits of lawmaking but actually how to go about working out these shapes. I just can't think most how to do information technology!

*****Edit: with the solution I came up with, hopefully might assistance someone else!

Then I used the suggested ideas and basically decided the all-time way would be to depict using the stencil buffer. This at present means that I loop through my points three times only I need to do some careful sorting of them to discover merely visible ones anyway.

Then code wise I now have this:

          private void stencilCircleAroundStars() {     //Lets attempt and depict something hither using stencil     glColorMask(imitation, false, simulated, false); //Disable colour mask     glEnable(GL_STENCIL_TEST); // Enable Stencil Buffer For "marking" the outer circle     glDisable(GL_DEPTH_TEST);// Disable Depth Testing      for (Object value : stars.values())     {         Star star = (Star)value;          glStencilFunc(GL_ALWAYS, 1, 1); // Always Passes, ane Bit Airplane, 1 Every bit Mask         glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); // We Set The Stencil Buffer To ane Where We Draw Any Polygon          //Draw the large circle         starOb.location.copy(star.location);         starOb.setScale(2000);         starOb.draw();     }      for (Object value : stars.values())     {         Star star = (Star)value;         //Now we change the functions and remove a slightly smaller circle from buffer.         glStencilFunc(GL_ALWAYS, 0, 0); // E'er passes, 0 fleck plane, 0 as mask;         glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); // Nosotros Set The Stencil Buffer To 0 Where We Depict Any Polygon         starOb.location.copy(star.location);         starOb.setScale(1900);         starOb.describe();     }      //Now we enable the colour     glColorMask(true, true, true, true);     glStencilFunc(GL_EQUAL, one, one); // We Describe Only Where The Stencil Is 1     glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); // Don't Change The Stencil Buffer      glColor4f(0.5f, 1.0f, 0.5f, 0.5f);     for (Object value : stars.values())     {         Star star = (Star)value;         starOb.location.copy(star.location);         starOb.setScale(2000);         starOb.draw();     }      //Now we are done .. disable     glDisable(GL_STENCIL_TEST);   }                  

My points are in essence entities called "stars" for the purpose of my program and StarOb is a collection of quads I have loaded from a file which form a overnice smooth circle.

I disable color mask and I loop through in one case, drawing the largest circle I tin can into the stencil buffer and setting a value of i. I then loop around once more drawing the smaller scaled circle into the stencil buffer only this time setting a value of 0. This should leave a border around any star that is not touching other stars and will effectively remove where they overlap.

I finally re-enable the colour mask and actually draw the coloured circles. the stencil buffer stops the insides from beingness rendered and I get what I wanted! I then disable the stencil buffer.

If you really wanted to run into it, here's a video of generating several increasing amounts of points: Video of information technology running

Here is a low quality version of how it came out (background was non fatigued while testing):

Overlapping circles with centre not drawn due to stencil

Source: https://stackoverflow.com/questions/7490093/drawing-outline-of-intersecting-circles

Posted by: westfalltherwer.blogspot.com

0 Response to "How To Draw 4 Intersecting Circles"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel