a/math: Add MIN, MAX and CLAMP macros

This commit is contained in:
Mateo de Mayo 2022-05-17 18:12:53 -03:00 committed by Jakob Bornecrantz
parent df5b5f40a9
commit 63b477d250
3 changed files with 27 additions and 1 deletions
src/xrt
auxiliary
drivers/euroc

View file

@ -50,6 +50,31 @@ extern "C" {
*/
#define MATH_GRAVITY_M_S2 (9.8066)
/*!
* Minimum of A and B.
*
* @ingroup aux_math
*/
#ifndef MIN // Avoid clash with OpenCV def
#define MIN(A, B) ((A) < (B) ? (A) : (B))
#endif
/*!
* Maximum of A and B.
*
* @ingroup aux_math
*/
#ifndef MAX // Avoid clash with OpenCV def
#define MAX(A, B) ((A) > (B) ? (A) : (B))
#endif
/*!
* X clamped to the range [A, B].
*
* @ingroup aux_math
*/
#define CLAMP(X, A, B) (MIN(MAX((X), (A)), (B)))
/*
*

View file

@ -7,6 +7,7 @@
* @ingroup aux_util
*/
#include "math/m_api.h"
#include "util/u_autoexpgain.h"
#include "util/u_format.h"
#include "util/u_misc.h"

View file

@ -16,6 +16,7 @@
#include "util/u_var.h"
#include "util/u_sink.h"
#include "tracking/t_frame_cv_mat_wrapper.hpp"
#include "math/m_api.h"
#include "math/m_filter_fifo.h"
#include "euroc_driver.h"
@ -46,7 +47,6 @@ DEBUG_GET_ONCE_BOOL_OPTION(play_from_start, "EUROC_PLAY_FROM_START", false)
DEBUG_GET_ONCE_BOOL_OPTION(print_progress, "EUROC_PRINT_PROGRESS", false)
#define EUROC_PLAYER_STR "Euroc Player"
#define CLAMP(X, A, B) (MIN(MAX((X), (A)), (B)))
using std::async;
using std::find_if;