Math utilities that are required by other code. More...
#include <math.h>
#include <stdlib.h>
#include <stdint.h>
#include <assert.h>
Go to the source code of this file.
| |
#define | to_degrees(x) ( (x) * (180.0 / M_PI )) |
#define | to_radians(x) ( (x) * (PI / 180.0 )) |
#define | TWOPI (2*PI) |
#define | TWOPI_INV (0.5/PI) |
static double | fclamp (double v, double minv, double maxv) |
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 double | mod2pi (double vin) |
static double | mod2pi_positive (double vin) |
static double | mod2pi_ref (double ref, double vin) |
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) |
Math utilities that are required by other code.
Definition in file math_util.h.
#define to_degrees | ( | x | ) | ( (x) * (180.0 / M_PI )) |
Definition at line 46 of file math_util.h.
#define to_radians | ( | x | ) | ( (x) * (PI / 180.0 )) |
Definition at line 45 of file math_util.h.
#define TWOPI (2*PI) |
Definition at line 79 of file math_util.h.
#define TWOPI_INV (0.5/PI) |
Definition at line 78 of file math_util.h.
static double fclamp | ( | double | v, | |
double | minv, | |||
double | maxv | |||
) | [inline, static] |
Definition at line 143 of file math_util.h.
static int iclamp | ( | int | v, | |
int | minv, | |||
int | maxv | |||
) | [inline, static] |
Definition at line 138 of file math_util.h.
static int imax | ( | int | a, | |
int | b | |||
) | [inline, static] |
Definition at line 123 of file math_util.h.
static int64_t imax64 | ( | int64_t | a, | |
int64_t | b | |||
) | [inline, static] |
Definition at line 133 of file math_util.h.
static int imin | ( | int | a, | |
int | b | |||
) | [inline, static] |
Definition at line 118 of file math_util.h.
static int64_t imin64 | ( | int64_t | a, | |
int64_t | b | |||
) | [inline, static] |
Definition at line 128 of file math_util.h.
static int irand | ( | int | bound | ) | [inline, static] |
Definition at line 70 of file math_util.h.
static double mod2pi | ( | double | vin | ) | [inline, static] |
Map v to [-PI, PI]
Definition at line 91 of file math_util.h.
static double mod2pi_positive | ( | double | vin | ) | [inline, static] |
valid only for v > 0
Definition at line 82 of file math_util.h.
static double mod2pi_ref | ( | double | ref, | |
double | vin | |||
) | [inline, static] |
Return vin such that it is within PI degrees of ref
Definition at line 100 of file math_util.h.
static float randf | ( | ) | [inline, static] |
Definition at line 59 of file math_util.h.
static double sgn | ( | double | v | ) | [inline, static] |
Definition at line 53 of file math_util.h.
static float signed_randf | ( | ) | [inline, static] |
Definition at line 64 of file math_util.h.
static double sq | ( | double | v | ) | [inline, static] |
Definition at line 48 of file math_util.h.
static int theta_to_int | ( | double | theta, | |
int | max | |||
) | [inline, static] |
Definition at line 105 of file math_util.h.