Пример #1
0
        public void generate_random_points(int inpt_point_count, int x_coord_limit, int y_coord_limit)
        {
            delaunay_triangle = new Planar_object_store();                                              // reinitialize the all the lists

            List <Planar_object_store.point2d> temp_pt_list = new List <Planar_object_store.point2d>(); // create a temporary list to store the points
                                                                                                        // !!!!!!!!!!!! Need major improvements below - very slow to generate unique n random points !!!!!!!!!!!!!!!!!!!!!!!!!!!
            int point_count = inpt_point_count;

            do
            {
                for (int i = 0; i < point_count; i++)    // Loop thro' the point count
                {
                    Planar_object_store.point2d temp_pt; // temp_pt to store the intermediate random points
                    PointF rand_pt = new PointF(rand0.Next(-x_coord_limit, x_coord_limit),
                                                rand0.Next(-y_coord_limit, y_coord_limit));
                    temp_pt = new Planar_object_store.point2d(i, rand_pt.X, rand_pt.Y);
                    temp_pt_list.Add(temp_pt); // add to the temp list
                }

                temp_pt_list = temp_pt_list.Distinct(new Planar_object_store.points_equality_comparer()).ToList();


                point_count = inpt_point_count - temp_pt_list.Count;
            } while (point_count != 0);

            // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
            // copy to the main list
            delaunay_triangle.delaunay_points = temp_pt_list;
            // List<PointF> temp_rand_pts = Enumerable.Range(0,point_count).Select(obj => the_static_class.random_point(-x_coord_limit, x_coord_limit,-y_coord_limit, y_coord_limit)).ToList();
        }
Пример #2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            initiate_canvas_size();

            delaunay_triangle = new Planar_object_store(); // intialize the main drawing object
        }