]> rtime.felk.cvut.cz Git - hubacji1/iamcar.git/commitdiff
Add IS_NEAR macro
authorJiri Hubacek <hubacji1@fel.cvut.cz>
Mon, 24 Sep 2018 08:00:38 +0000 (10:00 +0200)
committerJiri Hubacek <hubacji1@fel.cvut.cz>
Mon, 24 Sep 2018 08:00:38 +0000 (10:00 +0200)
incl/rrtnode.h

index ef66143d4d551a2708ca963afdc433f7ac52be4b..40ca962027f41c911c733d50f83f57af3ca6e11f 100644 (file)
@@ -20,6 +20,12 @@ along with I am car. If not, see <http://www.gnu.org/licenses/>.
 
 #include <vector>
 
+#define IS_NEAR(a, b) ({ __typeof__ (a) _a = (a); \
+                __typeof__ (b) _b = (b); \
+                pow(pow(_b->x() - _a->x(), 2) + \
+                                pow(_b->y() - _a->y(), 2), 0.5) < 0.2 && \
+                std::abs(_b->h() - _a->h()) < M_PI / 32 ? true : false; })
+
 class RRTNode {
         private:
                 float dcost_ = 0; // direct cost (of edge) to parent