Factor out ol.geom.Circle#getRadiusSquared_
This commit is contained in:
+10
-1
@@ -106,9 +106,18 @@ ol.geom.Circle.prototype.getExtent = function(opt_extent) {
|
|||||||
* @return {number} Radius.
|
* @return {number} Radius.
|
||||||
*/
|
*/
|
||||||
ol.geom.Circle.prototype.getRadius = function() {
|
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 dx = this.flatCoordinates[this.stride] - this.flatCoordinates[0];
|
||||||
var dy = this.flatCoordinates[this.stride + 1] - this.flatCoordinates[1];
|
var dy = this.flatCoordinates[this.stride + 1] - this.flatCoordinates[1];
|
||||||
return Math.sqrt(dx * dx + dy * dy);
|
return dx * dx + dy * dy;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user