In this article, we use the inner Polygon method of the circle. The principle is to generate an inner close to the circle according to the provided center and radius.48Edges, and then combine them with the polygon objectFilterTo query the space. Of course, the closer the number of edges of the inner polygon is to the circle, the more accurate the query result is. ExampleCodeAs follows: // Java Public polygon createcirlepolygon (point PNT, double dradius ){ Double sinetheta, cosinetheta, twopi; Int numpoints = 48 ;//Number of edges of the inner Polygon Polygon poly = new polygon (); Points PNTs = new points (); Twopi = 3.1415*2.0; //Create a polygon For (INT I = 0; I <numpoints; I ++) { Point CPT = new point (); Sinetheta = math. Sin (twopi * (I * 1.0/numpoints )); Cosinetheta = math. Cos (twopi * (I * 1.0/numpoints )); CPT. setx (PNT. getx () + dradius * cosinetheta ); CPT. sety (PNT. Gety () + dradius * sinetheta ); PNTs. addpointobject (CPT ); } PNTs. addpointobject (PNTs. getpointobject (0 )); Ring = new ring (); Ring. setpoints (PNTs ); Poly. addring (ring ); Return poly; } // ASP. NET Public imspolympus Gon createcirlepolygon (imspoint PNT, double dradius) { Imspolympus Gon poly = new imspolympus Gon (); Double sinetheta, cosinetheta, twopi; Int numpoints = 48 ;//Number of edges of the inner Polygon Imspoints PNTs = new imspoints (); Twopi = 3.1415*2.0; //Create a polygon For (INT I = 0; I <numpoints; I ++) { Imspoint CPT = new imspoint (); Sinetheta = math. Sin (twopi * (I * 1.0/numpoints )); Cosinetheta = math. Cos (twopi * (I * 1.0/numpoints )); CPT. x = (PNT. x + dradius * cosinetheta ); CPT. Y = (PNT. Y + dradius * sinetheta ); PNTs. Add (CPT ); } PNTs. Add (PNTs [0]); Imsparts parts = new imsparts (); Parts. Add (PNTs ); Poly. parts = parts; Return poly; } |