/** * Generate next point * @param n space dimensionality * @param radius sphere radius * @param center sphere center (null for 0) * @param x resulting vector point */ static void nextPoint(int n, double radius, double * center, double* x) { double norm; Gaussian gauss; gauss.setSeqLen(n); norm = 0.; for(int j = 0; j < n; j ++) { x[j] = gauss.getRand(); norm += x[j] * x[j];; } double a; a = radius / sqrt(norm); for(int j = 0; j < n; j ++) { x[j] *= a; } if(center) { for(int j = 0; j < n; j ++) { x[j] += center[j]; } } }