MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/CompactNSearch / brute_force_search

Function brute_force_search

demo/main.cpp:56–80  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54}
55
56std::vector<std::vector<unsigned int>>
57brute_force_search()
58{
59 std::vector<std::vector<unsigned int>> brute_force_neighbors(positions.size());
60 for (int i = 0; i < positions.size(); ++i)
61 {
62 std::vector<unsigned int>& neighbors = brute_force_neighbors[i];
63 for (int j = 0; j < positions.size(); ++j)
64 {
65 if (i == j)
66 continue;
67 std::array<Real, 3> const& xa = positions[i];
68 std::array<Real, 3> const& xb = positions[j];
69 Real l2 =
70 (xa[0] - xb[0])*(xa[0] - xb[0]) +
71 (xa[1] - xb[1])*(xa[1] - xb[1]) +
72 (xa[2] - xb[2])*(xa[2] - xb[2]);
73 if (l2 <= radius * radius)
74 {
75 neighbors.push_back(j);
76 }
77 }
78 }
79 return std::move(brute_force_neighbors);
80}
81
82void
83compare_with_bruteforce_search(NeighborhoodSearch const& nsearch)

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected