Hello:

I am a new in IPHONE developing. Now I have a project which was written by processing before and I want to translate it into OFW_IPHONE. It has nextGaussian() function inside produced by java. I can not find any gaussian random function in both OFW and OFW+IPHONE.

I try to modify the math.cpp in the openframeworks folder. Here is the code:

double nextGaussian() {

if (haveNextNextGaussian ) {

haveNextNextGaussian = false;

return nextNextGaussian;

} else {

double v1, v2, s;

do {

v1 = 2 * (double)ofRandomf() - 1; // between -1.0 and 1.0

v2 = 2 * (double)ofRandomf() - 1; // between -1.0 and 1.0

s = v1 * v1 + v2 * v2;

} while (s >= 1 || s == 0);

double multiplier = sqrt(-2 * log(s)/s);

nextNextGaussian = v2 * multiplier;

haveNextNextGaussian = true;

return v1 * multiplier;

}

}

and I add

bool haveNextNextGaussian ;

double nextNextGaussian;

in the math.h;

but it can not built correctly. Both in OFW and OFW+IPHONE, they pop up the error message.

Is there anyone can give me some help to finish the Gaussian random in the OFW Iphone??

Thanks a lot.