-3

i want to divide number of circles into 3 parts and checking from every part whether it has points or not .. here code but i do not how can i check ?

int[] x = new int[3];
int[] y = new int[3];

for (int p = 0; p < Points.Count; p++ )
{
    Point po =(Point)points[p];

    for (int i = 1; i <= 3;i++ )
    {
         double angle = i * (360 / 3);
         x[i] = (int)(po.x + iTransmissionRadius * Math.Cos(convertToRadians(angle)));
         y[i] = (int)(po.y + iTransmissionRadius * Math.Sin(convertToRadians(angle)));
    }
}
Dmitry Bychenko
  • 180,369
  • 20
  • 160
  • 215
denez
  • 19
  • 1
  • Possible duplicate of [Efficiently find points inside a circle sector](http://stackoverflow.com/questions/13652518/efficiently-find-points-inside-a-circle-sector) – Frank J Mar 04 '16 at 14:23
  • I suggest you keep `float` coordinates instead of converting into `int`. – John Alexiou Mar 04 '16 at 16:13
  • I don't understand what you are checking. "and checking from every part whether it has points or not". Each part is defined by points `x` and `y`. – John Alexiou Mar 04 '16 at 16:15

1 Answers1

0

Is this what you are asking for?

class Program
{
    static Random rnd=new Random();        

    static void Main(string[] args)
    {
        var points=new List<Point>();
        for(int i=0; i<100; i++)
        {
            points.Add(new Point(rnd.Next(100), rnd.Next(100)));
        }

        int iTransmissionRadius=6;

        var neighbors=FindClosestPoints(points).ToArray();
        // count = 100

        var has_neighbors_within_radius=neighbors.Zip(points, (A, B) => AreWithinRadius(A,B,iTransmissionRadius)).ToArray();
        // true or false if there is neighbor closer than radius
    }

    static double DistanceBetweenPoints(Point A, Point B)
    {
        return Math.Sqrt((A.X-B.X)*(A.X-B.X)+(A.Y-B.Y)*(A.Y-B.Y));
    }

    static bool AreWithinRadius(Point A, Point B, int radius)
    {
        return DistanceBetweenPoints(A,B)<=radius;
    }

    static IEnumerable<Point> FindClosestPoints(IEnumerable<Point> points)
    {
        return points.Select((A) =>
        {
            var list=points.ToArray();
            Array.Sort(list, (B,C)=> DistanceBetweenPoints(A,B).CompareTo(DistanceBetweenPoints(A,C)));
            return list.Skip(1).FirstOrDefault();
        });
    }

}
John Alexiou
  • 28,472
  • 11
  • 77
  • 133