Add ol.Rectangle.normalize

This commit is contained in:
Tom Payne
2012-07-18 00:06:27 +02:00
parent fad873d44c
commit b93cb7c47a
2 changed files with 38 additions and 0 deletions

View File

@@ -103,3 +103,14 @@ ol.Rectangle.prototype.getSize = function() {
ol.Rectangle.prototype.getWidth = function() {
return this.maxX - this.minX;
};
/**
* @param {goog.math.Coordinate} coordinate Coordinate.
* @return {goog.math.Coordinate} Coordinate.
*/
ol.Rectangle.prototype.normalize = function(coordinate) {
return new goog.math.Coordinate(
(coordinate.x - this.minX) / this.getWidth(),
(coordinate.y - this.minY) / this.getHeight());
};