public double estimateExcludedVolumeFraction ( ) { //Calculate volume/area of the of the scene without obstacles if ( recalculateVolumeFraction ) { CentralRandomNumberGenerator r = CentralRandomNumberGenerator . getInstance ( ) ; boolean firstRandomDraw = false ; if ( randomNumbers == null ) { randomNumbers = new double [ nRandPoints * dimension ] ; firstRandomDraw = true ; } int countCollision = 0 ; for ( int i = 0 ; i < nRandPoints ; i ++ ) { double [ ] pos = new double [ dimension ] ; for ( int j = 0 ; j < dimension ; j ++ ) { if ( firstRandomDraw ) { randomNumbers [ i * dimension + j ] = r . nextDouble ( ) ; } pos [ j ] = randomNumbers [ i * dimension + j ] * size [ j ] ; } if ( checkCollision ( pos ) ) { countCollision ++ ; } } fraction = countCollision * 1.0 / nRandPoints ; recalculateVolumeFraction = false ; } return fraction ; }
Estimate excluded volume fraction by monte carlo method