PDA

View Full Version : Random numbers help plz



iNsaNEiVaN
05-26-2001, 11:42 AM
what is the function to find a random number between any 2 declared numbers in win32 opengl programming?

thank you!

Randolph
05-26-2001, 01:42 PM
There is a function rand in C++ that calculates random integer number between predefined 0 and RAND_MAX constant
Try this function:

#include <stdlib.h>

//-----------------------

float RandAB(float A, float B)
{
return A+(B-A)*rand()/RAND_MAX;
}

If you dont use C++, your language should have function for generation of random numbers.

As far as I know, there is no special random function in Win32 or 3D graphics programming. I can well be wrong.

Gavin
05-29-2001, 01:37 AM
If you want t something a bit closer to random.....
try
Mersenne Twister
or
Taygata
they both have code on the web and are really easy to pop into your code.....

gav