WPILibC++ 2027.0.0-alpha-4
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()

int dblcmp ( double d1,
double d2 )
inlinestatic

◆ dclamp()

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

◆ dequals_mag()

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

◆ fltcmp()

int fltcmp ( float f1,
float f2 )
inlinestatic

◆ fsq()

float fsq ( float v)
inlinestatic

◆ iclamp()

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

◆ imax()

int imax ( int a,
int b )
inlinestatic

◆ imax64()

int64_t imax64 ( int64_t a,
int64_t b )
inlinestatic

◆ imin()

int imin ( int a,
int b )
inlinestatic

◆ imin64()

int64_t imin64 ( int64_t a,
int64_t b )
inlinestatic

◆ irand()

int irand ( int bound)
inlinestatic

◆ isq()

int isq ( int v)
inlinestatic

◆ mod2pi()

double mod2pi ( double vin)
inlinestatic

Map vin to [-PI, PI).

◆ mod2pi_positive()

double mod2pi_positive ( double vin)
inlinestatic

Map vin to [0, 2*PI).

◆ mod2pi_ref()

double mod2pi_ref ( double ref,
double vin )
inlinestatic

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

◆ mod360()

double mod360 ( double vin)
inlinestatic

Map vin to [-180, 180).

◆ mod360_positive()

double mod360_positive ( double vin)
inlinestatic

Map vin to [0, 360).

◆ mod_positive()

int mod_positive ( int vin,
int mod )
inlinestatic

◆ randf()

float randf ( void )
inlinestatic

◆ sgn()

double sgn ( double v)
inlinestatic

◆ signed_randf()

float signed_randf ( void )
inlinestatic

◆ sq()

double sq ( double v)
inlinestatic

◆ theta_to_int()

int theta_to_int ( double theta,
int max )
inlinestatic