#ifndef V_RGEN_H
#define V_RGEN_H

/* fixme: move to config.h */
#define	CONFIG_FAST_RGEN


#ifndef	SQRT_3
#define	SQRT_3	VEC(1.73205080756887729352745)
#endif

/*
 * Lower and upper bounds of uniformly distrubuted value
 */
#define	UNIFORM_LOWER(mean,stdev)	((mean) - (stdev) * SQRT_3)
#define	UNIFORM_UPPER(mean,stdev)	((mean) + (stdev) * SQRT_3)

#ifdef	__cplusplus
extern "C" {
#endif	/* __cplusplus */
	vhandle_t	V_GLOBAL	ranCreateGenerator(int seed);
	void	V_GLOBAL	ranDestroyGenerator(vhandle_t gen);
	long	V_GLOBAL	ranNextLong(vhandle_t gen,long upper_bound);
	vec_t	V_GLOBAL	ranNextFloat(vhandle_t gen);
	vec_t	V_GLOBAL	ranNextFloatRange(vhandle_t gen,vec_t min,vec_t max);
	void	V_GLOBAL	ranNextVec3Range(vhandle_t gen,vec3_t vec3_ret,vec_t min,vec_t max);
	void	V_GLOBAL	ranNextVec3RangeV(vhandle_t gen,vec3_t vec3_ret,vec3_t mins,vec3_t maxs);
	void	V_GLOBAL	ranNextVectorRange(vhandle_t gen,vector_p vec_ret,vec_t min,vec_t max);
	void	V_GLOBAL	ranNextVectorRangeV(vhandle_t gen,vector_p vec_ret,vector_p mins,vector_p maxs);

	vec_t	V_GLOBAL	ranNextGaussian(vhandle_t gen,vec_t mean,vec_t rms);
	void	V_GLOBAL	ranNextGaussianVec3(vhandle_t gen,vec3_t vec3_ret,vec_t mean,vec_t rms);
	void	V_GLOBAL	ranNextGaussianVec3V(vhandle_t gen,vec3_t vec3_ret,vec3_t mean,vec3_t rms);
	void	V_GLOBAL	ranNextGaussianVector(vhandle_t gen,vector_p vec_ret,vec_t mean,vec_t rms);
	void	V_GLOBAL	ranNextGaussianVectorV(vhandle_t gen,vector_p vec_ret,vector_p mean,vector_p rms);
#ifdef	__cplusplus
}
#endif	/* __cplusplus */

#endif	/* V_RGEN_H */
