<commit_before>goog.provide('ol.Rectangle');

goog.require('goog.asserts');
goog.require('ol.Coordinate');
goog.require('ol.Size');



/**
 * @constructor
 * @param {number} minX Minimum X.
 * @param {number} minY Minimum Y.
 * @param {number} maxX Maximum X.
 * @param {number} maxY Maximum Y.
 */
ol.Rectangle = function(minX, minY, maxX, maxY) {

  goog.asserts.assert(minX <= maxX);
  goog.asserts.assert(minY <= maxY);

  /**
   * @type {number}
   */
  this.minX = minX;

  /**
   * @type {number}
   */
  this.minY = minY;

  /**
   * @type {number}
   */
  this.maxX = maxX;

  /**
   * @type {number}
   */
  this.maxY = maxY;

};


/**
 * @return {ol.Coordinate} Center.
 */
ol.Rectangle.prototype.getCenter = function() {
  return new ol.Coordinate(
      (this.minX + this.maxX) / 2, (this.minY + this.maxY) / 2);
};


/**
 * @return {number} Height.
 */
ol.Rectangle.prototype.getHeight = function() {
  return this.maxY - this.minY;
};


/**
 * @return {ol.Size} Size.
 */
ol.Rectangle.prototype.getSize = function() {
  return new ol.Size(this.getWidth(), this.getHeight());
};


/**
 * @return {number} Width.
 */
ol.Rectangle.prototype.getWidth = function() {
  return this.maxX - this.minX;
};


/**
 * @param {ol.Rectangle} rectangle Rectangle.
 * @return {boolean} Intersects.
 */
ol.Rectangle.prototype.intersects = function(rectangle) {
  return this.minX <= rectangle.maxX &&
      this.maxX >= rectangle.minX &&
      this.minY <= rectangle.maxY &&
      this.maxY >= rectangle.minY;
};


/**
 * @param {ol.Coordinate} coordinate Coordinate.
 * @return {ol.Coordinate} Coordinate.
 */
ol.Rectangle.prototype.normalize = function(coordinate) {
  return new ol.Coordinate(
      (coordinate.x - this.minX) / this.getWidth(),
      (coordinate.y - this.minY) / this.getHeight());
};


/**
 * @return {string} String.
 */
ol.Rectangle.prototype.toString = function() {
  return '(' + [this.minX, this.minY, this.maxX, this.maxY].join(', ') + ')';
};
<commit_msg>Add ol.Rectangle.extend<commit_after>goog.provide('ol.Rectangle');

goog.require('goog.asserts');
goog.require('ol.Coordinate');
goog.require('ol.Size');



/**
 * @constructor
 * @param {number} minX Minimum X.
 * @param {number} minY Minimum Y.
 * @param {number} maxX Maximum X.
 * @param {number} maxY Maximum Y.
 */
ol.Rectangle = function(minX, minY, maxX, maxY) {

  goog.asserts.assert(minX <= maxX);
  goog.asserts.assert(minY <= maxY);

  /**
   * @type {number}
   */
  this.minX = minX;

  /**
   * @type {number}
   */
  this.minY = minY;

  /**
   * @type {number}
   */
  this.maxX = maxX;

  /**
   * @type {number}
   */
  this.maxY = maxY;

};


/**
 * @param {ol.Rectangle} rectangle Rectangle.
 */
ol.Rectangle.prototype.extend = function(rectangle) {
  this.minX = Math.min(this.minX, rectangle.minX);
  this.minY = Math.min(this.minY, rectangle.minY);
  this.maxX = Math.max(this.maxX, rectangle.maxX);
  this.maxY = Math.max(this.maxY, rectangle.maxY);
};


/**
 * @return {ol.Coordinate} Center.
 */
ol.Rectangle.prototype.getCenter = function() {
  return new ol.Coordinate(
      (this.minX + this.maxX) / 2, (this.minY + this.maxY) / 2);
};


/**
 * @return {number} Height.
 */
ol.Rectangle.prototype.getHeight = function() {
  return this.maxY - this.minY;
};


/**
 * @return {ol.Size} Size.
 */
ol.Rectangle.prototype.getSize = function() {
  return new ol.Size(this.getWidth(), this.getHeight());
};


/**
 * @return {number} Width.
 */
ol.Rectangle.prototype.getWidth = function() {
  return this.maxX - this.minX;
};


/**
 * @param {ol.Rectangle} rectangle Rectangle.
 * @return {boolean} Intersects.
 */
ol.Rectangle.prototype.intersects = function(rectangle) {
  return this.minX <= rectangle.maxX &&
      this.maxX >= rectangle.minX &&
      this.minY <= rectangle.maxY &&
      this.maxY >= rectangle.minY;
};


/**
 * @param {ol.Coordinate} coordinate Coordinate.
 * @return {ol.Coordinate} Coordinate.
 */
ol.Rectangle.prototype.normalize = function(coordinate) {
  return new ol.Coordinate(
      (coordinate.x - this.minX) / this.getWidth(),
      (coordinate.y - this.minY) / this.getHeight());
};


/**
 * @return {string} String.
 */
ol.Rectangle.prototype.toString = function() {
  return '(' + [this.minX, this.minY, this.maxX, this.maxY].join(', ') + ')';
};

{'fraction_non_alphanumeric': 0.19249592169657423, 'fraction_numerical': 0.0009321836401771149, 'mean_word_length': 3.107177033492823, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '309918', 'n_tokens_mistral': 1631, 'n_tokens_neox': 1563, 'n_words': 289}