The point is this: I am writing an arcanoid on a project at the institute. The task now is the organization of the ball collision algorithm with blocks. Those. need to determine when he collides with them to change the direction of the ball. What did I do? I tried to write a touchBounds method on the Block class (bricks on the screen), which determined which side of the block touched the ball and, depending on this, returns a whole from 0 to 3. It causes doubts about optimization. Since every 1000/60 milliseconds I need to perform this operation with all the available blocks. Since I am a layman in this matter, I ask for advice, can anyone know how these situations in programming are usually handled? 
Code:
public int touchBounds( int[][] a, int inc ) { int xC = ( a[0][0] + a[1][0] ) / 2; int yC = ( a[0][1] + a[2][1] ) / 2; if ( between( yC, offset[0][1] - ( inc + 1 ), offset[0][1] ) && between( xC, offset[0][0], offset[1][0] ) ) { return 0; } else if ( between( yC, offset[0][1], offset[2][1] ) && between( xC, offset[1][0], offset[1][0] + ( inc + 1 ) ) ) { return 1; } else if ( between( yC, offset[2][1], offset[2][1] + ( inc + 1 ) ) && between( xC, offset[0][0], offset[1][0] ) ) { return 2; } else if ( between( yC, offset[0][1], offset[2][1] ) && between( xC, offset[0][0] - ( inc + 1 ), offset[0][0] ) ) { return 3; } return -1; } private boolean between( int a, int b, int c ) { if ( a >= b && a <= c ) { return true; } return false; } where inc is the trim position of the ball, int [] [] a is the offset of the ball, xC is the center of the ball in X, xY is the center of the ball in Y