From 5983bd340ec8f9d6d61f09efd79131ed4487b8b2 Mon Sep 17 00:00:00 2001 From: Jiri Vlasak Date: Tue, 2 Apr 2019 16:48:37 +0200 Subject: [PATCH] Move MIN macro to aux header file, add MAX --- incl/aux.h | 10 ++++++++++ incl/nv.h | 5 +---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/incl/aux.h b/incl/aux.h index 27f98ef..7884242 100644 --- a/incl/aux.h +++ b/incl/aux.h @@ -23,4 +23,14 @@ along with I am car. If not, see . pow(pow((_b)->x() - (_a)->x(), 2) + \ pow((_b)->y() - (_a)->y(), 2), 0.5); }) +// see http://www.cplusplus.com/reference/algorithm/max/ +#define MAX(a, b) ({ __typeof__ (a) _a = (a); \ + __typeof__ (b) _b = (b); \ + (_a < _b) ? _b : _a; }) + +// see http://www.cplusplus.com/reference/algorithm/min/ +#define MIN(a, b) ({ __typeof__ (a) _a = (a); \ + __typeof__ (b) _b = (b); \ + !(_b < _a) ? _a : _b; }) + #endif diff --git a/incl/nv.h b/incl/nv.h index 9eae1d7..94d986c 100644 --- a/incl/nv.h +++ b/incl/nv.h @@ -19,13 +19,10 @@ along with I am car. If not, see . #define NEARVERTICES_H #include +#include "aux.h" #include "rrtbase.h" #include "rrtnode.h" -#define MIN(a, b) ({ __typeof__ (a) _a = (a); \ - __typeof__ (b) _b = (b); \ - _a < _b ? _a : _b; }) - #define GAMMA_RRTSTAR(card_V) ({ __typeof__ (card_V) _card_V = (card_V); \ pow(log(_card_V) / _card_V, 1.0/3.0); }) -- 2.39.2