code: public static int pixelXToTileXWithScaleFactor(double pixelX, double scaleFactor, int tileSize) {
          return (int) Math.min(Math.max(pixelX / tileSize, 0), scaleFactor - 1);
      }
docs: Converts a pixel X coordinate to the tile X number.
  
  @param pixelX      the pixel X coordinate that should be converted.
  @param scaleFactor the scale factor at which the coordinate should be converted.
  @return the tile X number.