-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
51 lines (35 loc) · 998 Bytes
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include "Image.h"
#include "Welzl.h"
#include <time.h>
// Ãåíåðàöèÿ òî÷åê â ðåêòàíãëå.
std::vector<Point> Generate(const Point &lb, const Point &rt, unsigned int count)
{
std::vector<Point> points;
points.reserve(count);
Size size(static_cast<unsigned int>(rt.x - lb.x), static_cast<unsigned int>(rt.y - lb.y));
for(unsigned int i = 0; i < count; ++i)
{
points.push_back(Point(lb.x + rand() % size.width, lb.y + rand() % size.height));
}
return points;
}
int main()
{
srand(static_cast<unsigned int>(time(0)));
Size size(1000, 1000);
Image image;
image.Resize(size);
image.Fill(0xFFFFFFFF);
std::vector<Point> points = Generate(Point(500, 300), Point(700, 700), 10000000);
Welzl w;
printf("begin\n");
Circle c = w.Process(points);
printf("end\n");
image.DrawCircle(c.center, c.radius, 0xFF0000FF);
for(auto it = points.begin(); it != points.end(); ++it)
{
image.DrawPoint(*it, 0x00FF00FF);
}
image.Save("img.png");
return 0;
}