1
1
mirror of https://github.com/tstellar/bygfoot.git synced 2025-03-05 11:37:50 +01:00
bygfoot/src/maths.h

37 lines
839 B
C
Raw Normal View History

#ifndef MATHS_H
#define MATHS_H
2004-12-23 12:58:39 +00:00
#include <math.h>
2004-12-23 12:58:39 +00:00
#include "bygfoot.h"
/**
Macros for random number generation (#rnd for float, #rndi and #gauss_disti for integer).
2004-12-23 12:58:39 +00:00
*/
#define math_rnd(lower,upper) ((gfloat)random()/(gfloat)0x7fffffff*((upper)-(lower))+(lower))
#define math_rndi(lower,upper) ((gint)rint( math_rnd((gfloat)(lower) - 0.499, (gfloat)(upper) + 0.499) ))
#define math_gauss_disti(lower, upper) ((gint)rint( math_gauss_dist((gfloat)lower - 0.499, (gfloat)upper + 0.499)))
2004-12-23 12:58:39 +00:00
gfloat
math_gaussrand(void);
2004-12-23 12:58:39 +00:00
gfloat
math_gauss_dist(gfloat lower, gfloat upper);
2004-12-23 12:58:39 +00:00
gint
math_get_place(gint value, gint place);
2004-12-23 12:58:39 +00:00
gint
math_round_integer(gint number, gint places);
void
math_generate_permutation(gint *array, gint start, gint end);
2004-12-23 12:58:39 +00:00
2005-01-09 20:21:22 +00:00
gint
math_get_bye_len(gint number);
gint
math_sum_int_array(const gint *array, gint max);
2005-01-09 20:21:22 +00:00
2004-12-23 12:58:39 +00:00
#endif