Factor out ol.geom.Circle#getRadiusSquared_

This commit is contained in:
Tom Payne
2014-01-30 16:02:38 +01:00
parent 00962d69f1
commit 82341c779a

View File

@@ -106,9 +106,18 @@ ol.geom.Circle.prototype.getExtent = function(opt_extent) {
* @return {number} Radius.
*/
ol.geom.Circle.prototype.getRadius = function() {
return Math.sqrt(this.getRadiusSquared_());
};
/**
* @private
* @return {number} Radius squared.
*/
ol.geom.Circle.prototype.getRadiusSquared_ = function() {
var dx = this.flatCoordinates[this.stride] - this.flatCoordinates[0];
var dy = this.flatCoordinates[this.stride + 1] - this.flatCoordinates[1];
return Math.sqrt(dx * dx + dy * dy);
return dx * dx + dy * dy;
};