Skip to content

Commit c2dba4d

Browse files
committed
format: change indent to 4
1 parent 35550f4 commit c2dba4d

File tree

2 files changed

+313
-337
lines changed

2 files changed

+313
-337
lines changed

Diff for: examples/main.cpp

+46-47
Original file line numberDiff line numberDiff line change
@@ -6,65 +6,64 @@
66

77
struct Point
88
{
9-
float x;
10-
float y;
9+
float x;
10+
float y;
1111
};
1212

1313
Point make_random_point()
1414
{
15-
return Point{
16-
(static_cast<float>(rand()) / static_cast<float>(RAND_MAX)) * 10.0f,
17-
(static_cast<float>(rand()) / static_cast<float>(RAND_MAX)) *
18-
10.0f};
15+
return Point{
16+
(static_cast<float>(rand()) / static_cast<float>(RAND_MAX)) * 10.0f,
17+
(static_cast<float>(rand()) / static_cast<float>(RAND_MAX)) * 10.0f};
1918
}
2019

2120
int main()
2221
{
23-
srand(static_cast<unsigned>(time(0)));
24-
std::ofstream file("kdtree.txt");
25-
// Tree from the Wikipedia article
26-
// std::vector<Point> points = {{2,3}, {5,4}, {9,6}, {4,7}, {8,1}, {7,2}
27-
//};
22+
srand(static_cast<unsigned>(time(0)));
23+
std::ofstream file("kdtree.txt");
24+
// Tree from the Wikipedia article
25+
// std::vector<Point> points = {{2,3}, {5,4}, {9,6}, {4,7}, {8,1}, {7,2}
26+
//};
2827

29-
// Generate random points
30-
file << "# points\n";
31-
std::vector<Point> points;
32-
for (size_t i = 0; i < 550; ++i)
33-
{
34-
points.emplace_back(make_random_point());
35-
file << points[i].x << "," << points[i].y << '\n';
36-
}
28+
// Generate random points
29+
file << "# points\n";
30+
std::vector<Point> points;
31+
for (size_t i = 0; i < 550; ++i)
32+
{
33+
points.emplace_back(make_random_point());
34+
file << points[i].x << "," << points[i].y << '\n';
35+
}
3736

38-
// Define function to grab object's coordinates
39-
auto get_coord = [](const Point& p, int axis)
40-
{
41-
if (axis == 0) return p.x;
42-
return p.y;
43-
};
44-
// Create Kdtree
45-
kdtree::Kdtree<Point, /* Dimension */ 2, decltype(get_coord)> tree(
46-
points, get_coord);
37+
// Define function to grab object's coordinates
38+
auto get_coord = [](const Point& p, int axis)
39+
{
40+
if (axis == 0) return p.x;
41+
return p.y;
42+
};
43+
// Create Kdtree
44+
kdtree::Kdtree<Point, /* Dimension */ 2, decltype(get_coord)> tree(
45+
points, get_coord);
4746

48-
// Generate point whose neighbors we want to find
49-
file << "# gold\n";
50-
Point gold = make_random_point();
51-
file << gold.x << "," << gold.y << '\n';
47+
// Generate point whose neighbors we want to find
48+
file << "# gold\n";
49+
Point gold = make_random_point();
50+
file << gold.x << "," << gold.y << '\n';
5251

53-
// Find the nearest neighbor
54-
file << "# nn\n";
55-
const Point& nn = tree.find_nn(gold);
56-
file << nn.x << "," << nn.y << '\n';
52+
// Find the nearest neighbor
53+
file << "# nn\n";
54+
const Point& nn = tree.find_nn(gold);
55+
file << nn.x << "," << nn.y << '\n';
5756

58-
// Find all the neighbors within 'radius' distance
59-
float radius = 2.0;
60-
file << "# neighbors\n";
61-
file << radius << '\n';
62-
std::vector<size_t> neighbors = tree.find_neighbors(gold, radius);
63-
for (auto&& ind : neighbors)
64-
{
65-
auto& neigh = points[ind];
66-
file << neigh.x << "," << neigh.y << '\n';
67-
}
57+
// Find all the neighbors within 'radius' distance
58+
float radius = 2.0;
59+
file << "# neighbors\n";
60+
file << radius << '\n';
61+
std::vector<size_t> neighbors = tree.find_neighbors(gold, radius);
62+
for (auto&& ind : neighbors)
63+
{
64+
auto& neigh = points[ind];
65+
file << neigh.x << "," << neigh.y << '\n';
66+
}
6867

69-
return 0;
68+
return 0;
7069
}

0 commit comments

Comments
 (0)