WPILibC++ 2025.1.1
Loading...
Searching...
No Matches
math_util.h File Reference
#include <math.h>
#include <stdlib.h>
#include <stdint.h>
#include <assert.h>

Go to the source code of this file.

Macros

#define _USE_MATH_DEFINES
 
#define to_radians(x)
 
#define to_degrees(x)
 

Functions

static int dequals_mag (double a, double b, double thresh)
 
static int isq (int v)
 
static float fsq (float v)
 
static double sq (double v)
 
static double sgn (double v)
 
static float randf (void)
 
static float signed_randf (void)
 
static int irand (int bound)
 
static double mod2pi_positive (double vin)
 Map vin to [0, 2*PI)
 
static double mod2pi (double vin)
 Map vin to [-PI, PI)
 
static double mod2pi_ref (double ref, double vin)
 Return vin such that it is within PI degrees of ref.
 
static double mod360_positive (double vin)
 Map vin to [0, 360)
 
static double mod360 (double vin)
 Map vin to [-180, 180)
 
static int mod_positive (int vin, int mod)
 
static int theta_to_int (double theta, int max)
 
static int imin (int a, int b)
 
static int imax (int a, int b)
 
static int64_t imin64 (int64_t a, int64_t b)
 
static int64_t imax64 (int64_t a, int64_t b)
 
static int iclamp (int v, int minv, int maxv)
 
static double dclamp (double a, double min, double max)
 
static int fltcmp (float f1, float f2)
 
static int dblcmp (double d1, double d2)
 

Macro Definition Documentation

◆ _USE_MATH_DEFINES

#define _USE_MATH_DEFINES

◆ to_degrees

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

◆ to_radians

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

Function Documentation

◆ dblcmp()

static int dblcmp ( double d1,
double d2 )
inlinestatic

◆ dclamp()

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

◆ dequals_mag()

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

◆ fltcmp()

static int fltcmp ( float f1,
float f2 )
inlinestatic

◆ fsq()

static float fsq ( float v)
inlinestatic

◆ iclamp()

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

◆ imax()

static int imax ( int a,
int b )
inlinestatic

◆ imax64()

static int64_t imax64 ( int64_t a,
int64_t b )
inlinestatic

◆ imin()

static int imin ( int a,
int b )
inlinestatic

◆ imin64()

static int64_t imin64 ( int64_t a,
int64_t b )
inlinestatic

◆ irand()

static int irand ( int bound)
inlinestatic

◆ isq()

static int isq ( int v)
inlinestatic

◆ mod2pi()

static double mod2pi ( double vin)
inlinestatic

Map vin to [-PI, PI)

◆ mod2pi_positive()

static double mod2pi_positive ( double vin)
inlinestatic

Map vin to [0, 2*PI)

◆ mod2pi_ref()

static double mod2pi_ref ( double ref,
double vin )
inlinestatic

Return vin such that it is within PI degrees of ref.

◆ mod360()

static double mod360 ( double vin)
inlinestatic

Map vin to [-180, 180)

◆ mod360_positive()

static double mod360_positive ( double vin)
inlinestatic

Map vin to [0, 360)

◆ mod_positive()

static int mod_positive ( int vin,
int mod )
inlinestatic

◆ randf()

static float randf ( void )
inlinestatic

◆ sgn()

static double sgn ( double v)
inlinestatic

◆ signed_randf()

static float signed_randf ( void )
inlinestatic

◆ sq()

static double sq ( double v)
inlinestatic

◆ theta_to_int()

static int theta_to_int ( double theta,
int max )
inlinestatic