]> rtime.felk.cvut.cz Git - hubacji1/iamcar.git/blobdiff - incl/aux.h
Merge branch 'release/0.7.0'
[hubacji1/iamcar.git] / incl / aux.h
index 27f98efe988b7f25d5f3490f49973484ba8cf096..73fefb83c263d6f4b83e24542bc88c1ba386d7e5 100644 (file)
@@ -18,9 +18,27 @@ along with I am car. If not, see <http://www.gnu.org/licenses/>.
 #ifndef AUX_H
 #define AUX_H
 
-#define EDIST(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); })
+#define EDIST(a, b) ({ \
+        __typeof__ (a) _a = (a); \
+        __typeof__ (b) _b = (b); \
+        sqrt( \
+                pow((_b)->x() - (_a)->x(), 2) \
+                + pow((_b)->y() - (_a)->y(), 2) \
+        ); \
+})
+
+// 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