]> rtime.felk.cvut.cz Git - hubacji1/bcar.git/commitdiff
Implement naive collide function
authorJiri Vlasak <hubacji1@fel.cvut.cz>
Thu, 1 Aug 2019 14:48:00 +0000 (16:48 +0200)
committerJiri Vlasak <hubacji1@fel.cvut.cz>
Thu, 1 Aug 2019 14:50:43 +0000 (16:50 +0200)
src/bcar.cc

index db8666cb9c1a8fff341ef6efa4199fd1cd4bcc37..23c2c02177a766e9fc87c9e640d8f711ca6a7698 100644 (file)
@@ -173,6 +173,22 @@ std::tuple<bool, unsigned int, unsigned int> collide(
         std::vector<std::tuple<double, double>> p2
 )
 {
+        for (unsigned int i = 0; i < p1.size() - 1; i++) {
+                for (unsigned int j = 0; j < p2.size() - 1; j++) {
+                        auto x = intersect(
+                                std::get<0>(p1[i]),
+                                std::get<1>(p1[i]),
+                                std::get<0>(p1[i + 1]),
+                                std::get<1>(p1[i + 1]),
+                                std::get<0>(p2[j]),
+                                std::get<1>(p2[j]),
+                                std::get<0>(p2[j + 1]),
+                                std::get<1>(p2[j + 1])
+                        );
+                        if (std::get<0>(x))
+                                return std::make_tuple(true, i, j);
+                }
+        }
         return std::make_tuple(false, 0, 0);
 }