calculates the maxX and maxY taking into consideration dimensions