How to get an array of circle points

so I know that the parametric equation for ONE circle is:

x = cx + r * cos(a) y = cy + r * sin(a) 

From here it is easy to get a point from its circumference ...

But what if I want to get points of an array from many intersecting circles of a circle ? Like this: Intersected circles

So, how can I draw similar circular alliances with GL lines containing points (Vertices, sequence questions) in a coordinate system. If I know every center of the circle and radius?

(It would be best if you had to iterate over it using its parameter of the collective parametric equation to get each vertex with the desired density.)

Attention! The result is just an array of dots (any density) associated with the lines when they follow each other (bold black part). NOT polygons. The form is not completed.

(I want to draw it in Unity3D using C # and GL.Lines)

+6
source share
3 answers

Since you know Circle c1:

 x1 = cx1 + r1 * cos(a) y1 = cy1 + r1 * sin(a) 

and you need an additional condition point P [x1, y1] βˆ‰ any other C. Just generate all the circles (or check the condition when generating) and delete all the points that are closer to any center [cx, cy], and then the corresponding circle radius R To calculate the density (or the best square distance and compare with the previously calculated square R to improve perforation), simply measure the distance of the P-Center vector (pythagoras):

 foreach (Point p){ foreach (other Circle c){ float dist = (P - Center).Lenght; if (dist < cR){ // point is not valid, remove } } } 

this solution is really not optimal (as indicated in the comments). Another approach would be to calculate the intersections of each circle with each other ( https://math.stackexchange.com/questions/256100/how-can-i-find-the-points-at-which-two-circles-intersect ) and delete RANGE between these points (the right one of the cc - its beginning to get complicated). In addition, if you need to maintain the correct sequence, it should be possible to continue generating one circle until you reach the intersection - then switch the circles to a new one, etc. However, note: you need to start outside the form!

+4
source

Depending on which version of OpenGL you want to use, a simple way would be to trace the triangles of each circle in the stencil. Then trace the same circles in the lines, excluding the area in the stencil.

To solve the shader, you can check here :

 #ifdef GL_ES precision mediump float; #endif uniform vec3 iResolution; // viewport resolution (in pixels) uniform float iGlobalTime; // shader playback time (in seconds) uniform float iChannelTime[4]; // channel playback time (in seconds) uniform vec3 iChannelResolution[4]; // channel resolution (in pixels) uniform vec4 iMouse; // mouse pixel coords. xy: current (if MLB down), zw: click uniform samplerXX iChannel0..3; // input channel. XX = 2D/Cube uniform vec4 iDate; // (year, month, day, time in seconds) uniform float iSampleRate; // sound sample rate (ie, 44100) bool PixelInsideCircle( vec3 circle ) { return length(vec2(gl_FragCoord.xy - circle.xy)) < circle.z; } bool PixelOnCircleContour( vec3 circle ) { return PixelInsideCircle(circle) && !PixelInsideCircle( vec3(circle.xy,circle.z-1.0) ); } void main( void ) { float timeFactor = (2.0+sin(iGlobalTime))/2.0; const int NB_CIRCLES=3; vec3 c[NB_CIRCLES]; c[0] = vec3( 0.6, 0.4, 0.07 ) * iResolution; c[1] = vec3( 0.45, 0.69, 0.09 ) * iResolution; c[2] = vec3( 0.35, 0.58, 0.06 ) * iResolution; c[0].z = 0.09*iResolution.x*timeFactor; c[1].z = 0.1*iResolution.x*timeFactor; c[2].z = 0.07*iResolution.x*timeFactor; c[0].xy = iMouse.xy; bool keep = false; for ( int i = 0; i < NB_CIRCLES; ++i ) { if ( !PixelOnCircleContour(c[i]) ) continue; bool insideOther = false; for ( int j = 0; j < NB_CIRCLES; ++j ) { if ( i == j ) continue; if ( PixelInsideCircle(c[j]) ) insideOther = true; } keep = keep || !insideOther; } if ( keep ) gl_FragColor = vec4(1.0,1.0,0.0,1.0); } 

and adjust it a little

+3
source

Your question is not completely completed, since you do not explain how you want the points to be distributed along the contour. I suppose you need a dense sequence of points arranged along a single curve.

There is no simple solution to this problem, and the resulting form can be very complex (it can even have holes). You will not spare the calculation of intersections between circular arcs and other geometric problems.

One way to solve this problem is to polygon circles with a sufficient density of points and use the algorithm for combining polygons. The excellent Clipper library ( http://www.angusj.com/delphi/clipper.php ) comes to mind.

Another quick and dirty solution is to work in a raster space: create a large white image and draw all the circles in black. Then use the following algorithm, such as Moore neighborhood ( http://www.imageprocessingplace.com/downloads_V3/root_downloads/tutorials/contour_tracing_Abeer_George_Ghuneim/index.html ).

+1
source

All Articles