question: @ SuppressWarnings ( "PointlessArithmeticExpression" ) public void computeClosestPoints ( ) { float centerX = contentRect . centerX ( ) ; float closestDistance = Float . MAX_VALUE ; for ( int i = 0 ; i < pointsCountWithinXRange * 2 ; i += 2 ) { float x = getDrawX ( xRangePoints [ i ] ) ; float distance = Math . abs ( x - centerX ) ; if ( distance <= closestDistance ) { if ( distance == closestDistance ) { closestPointsCount ++ ; } else { closestPointsCount = 0 ; } closestDistance = distance ; if ( closestPointsBuffer . length < ( closestPointsCount * 2 + 2 ) ) { closestPointsBuffer = new float [ closestPointsBuffer . length * 2 ] ; } closestPointsBuffer [ closestPointsCount * 2 + 0 ] = xRangePoints [ i ] ; closestPointsBuffer [ closestPointsCount * 2 + 1 ] = xRangePoints [ i + 1 ] ; } } if ( pointsCountWithinXRange > 0 ) { closestPointsCount ++ ; } }
target:  Compute closest to central line points. Several points will be written to array only if they have same X values