Debian Codegraph @

cvd_src/draw.cc

raw symbols SCIP
1
2 #include <cvd/draw.h>
3
4 namespace CVD
5 {
6 std::vector<ImageRef> getCircle(int radius)
7 {
8 std::vector<ImageRef> points;
9 int y = 0;
10 for(int x = -radius; x <= 0; x++)
11 {
12 int nexty2 = radius * radius - ((x + 1) * (x + 1));
13 while(true)
14 {
15 points.push_back(ImageRef(x, y));
16 if(y * y >= nexty2)
17 break;
18 ++y;
19 }
20 }
21 size_t i;
22 for(i = points.size() - 1; i > 0; i--)
23 points.push_back(ImageRef(-points[i - 1].x, points[i - 1].y));
24 for(i = points.size() - 1; i > 1; i--)
25 points.push_back(ImageRef(points[i - 1].x, -points[i - 1].y));
26 return points;
27 }
28
29 std::vector<ImageRef> getDisc(double radius)
30 {
31 std::vector<ImageRef> points;
32
33 int r = (int)ceil(radius + 1);
34
35 for(ImageRef p(0, -r); p.y <= r; p.y++)
36 for(p.x = -r; p.x <= r; p.x++)
37 if(p.mag_squared() <= radius * radius)
38 points.push_back(p);
39
40 return points;
41 }
42
43 };