Macros | Functions
math_util.h File Reference
#include <math.h>
#include <float.h>
#include <stdlib.h>
#include <stdint.h>
#include <assert.h>
#include <string.h>
Include dependency graph for math_util.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define M_PI   3.141592653589793238462643383279502884196
 
#define M_TWOPI   6.2831853071795862319959 /* 2*pi */
 
#define max(A, B)   (A < B ? B : A)
 
#define min(A, B)   (A < B ? A : B)
 
#define to_degrees(x)   ( (x) * (180.0 / M_PI ))
 
#define to_radians(x)   ( (x) * (M_PI / 180.0 ))
 

Functions

static int dblcmp (double d1, double d2)
 
static double dclamp (double a, double min, double max)
 
static int dequals_mag (double a, double b, double thresh)
 
static int fltcmp (float f1, float f2)
 
static float fsq (float v)
 
static int iclamp (int v, int minv, int maxv)
 
static int imax (int a, int b)
 
static int64_t imax64 (int64_t a, int64_t b)
 
static int imin (int a, int b)
 
static int64_t imin64 (int64_t a, int64_t b)
 
static int irand (int bound)
 
static int isq (int v)
 
static double mod2pi (double vin)
 
static double mod2pi_positive (double vin)
 
static double mod2pi_ref (double ref, double vin)
 
static double mod360 (double vin)
 
static double mod360_positive (double vin)
 
static int mod_positive (int vin, int mod)
 
static float randf ()
 
static double sgn (double v)
 
static float signed_randf ()
 
static double sq (double v)
 
static int theta_to_int (double theta, int max)
 

Macro Definition Documentation

◆ M_PI

#define M_PI   3.141592653589793238462643383279502884196

Definition at line 46 of file math_util.h.

◆ M_TWOPI

#define M_TWOPI   6.2831853071795862319959 /* 2*pi */

Definition at line 42 of file math_util.h.

◆ max

#define max (   A,
 
)    (A < B ? B : A)

Definition at line 52 of file math_util.h.

◆ min

#define min (   A,
 
)    (A < B ? A : B)

Definition at line 53 of file math_util.h.

◆ to_degrees

#define to_degrees (   x)    ( (x) * (180.0 / M_PI ))

Definition at line 50 of file math_util.h.

◆ to_radians

#define to_radians (   x)    ( (x) * (M_PI / 180.0 ))

Definition at line 49 of file math_util.h.

Function Documentation

◆ dblcmp()

static int dblcmp ( double  d1,
double  d2 
)
inlinestatic

Definition at line 203 of file math_util.h.

◆ dclamp()

static double dclamp ( double  a,
double  min,
double  max 
)
inlinestatic

Definition at line 183 of file math_util.h.

◆ dequals_mag()

static int dequals_mag ( double  a,
double  b,
double  thresh 
)
inlinestatic

Definition at line 63 of file math_util.h.

◆ fltcmp()

static int fltcmp ( float  f1,
float  f2 
)
inlinestatic

Definition at line 192 of file math_util.h.

◆ fsq()

static float fsq ( float  v)
inlinestatic

Definition at line 73 of file math_util.h.

◆ iclamp()

static int iclamp ( int  v,
int  minv,
int  maxv 
)
inlinestatic

Definition at line 178 of file math_util.h.

◆ imax()

static int imax ( int  a,
int  b 
)
inlinestatic

Definition at line 163 of file math_util.h.

◆ imax64()

static int64_t imax64 ( int64_t  a,
int64_t  b 
)
inlinestatic

Definition at line 173 of file math_util.h.

◆ imin()

static int imin ( int  a,
int  b 
)
inlinestatic

Definition at line 158 of file math_util.h.

◆ imin64()

static int64_t imin64 ( int64_t  a,
int64_t  b 
)
inlinestatic

Definition at line 168 of file math_util.h.

◆ irand()

static int irand ( int  bound)
inlinestatic

Definition at line 101 of file math_util.h.

◆ isq()

static int isq ( int  v)
inlinestatic

Definition at line 68 of file math_util.h.

◆ mod2pi()

static double mod2pi ( double  vin)
inlinestatic

Map vin to [-PI, PI)

Definition at line 118 of file math_util.h.

◆ mod2pi_positive()

static double mod2pi_positive ( double  vin)
inlinestatic

Map vin to [0, 2*PI)

Definition at line 112 of file math_util.h.

◆ mod2pi_ref()

static double mod2pi_ref ( double  ref,
double  vin 
)
inlinestatic

Return vin such that it is within PI degrees of ref

Definition at line 124 of file math_util.h.

◆ mod360()

static double mod360 ( double  vin)
inlinestatic

Map vin to [-180, 180)

Definition at line 136 of file math_util.h.

◆ mod360_positive()

static double mod360_positive ( double  vin)
inlinestatic

Map vin to [0, 360)

Definition at line 130 of file math_util.h.

◆ mod_positive()

static int mod_positive ( int  vin,
int  mod 
)
inlinestatic

Definition at line 141 of file math_util.h.

◆ randf()

static float randf ( )
inlinestatic

Definition at line 89 of file math_util.h.

◆ sgn()

static double sgn ( double  v)
inlinestatic

Definition at line 83 of file math_util.h.

◆ signed_randf()

static float signed_randf ( )
inlinestatic

Definition at line 95 of file math_util.h.

◆ sq()

static double sq ( double  v)
inlinestatic

Definition at line 78 of file math_util.h.

◆ theta_to_int()

static int theta_to_int ( double  theta,
int  max 
)
inlinestatic

Definition at line 145 of file math_util.h.



apriltag
Author(s): Edwin Olson , Max Krogius
autogenerated on Mon Jun 26 2023 02:26:35