Adding a distanceTo for pixels. p=bbinet, r=me (closes #3119)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@11491 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Tim Schaub
2011-02-25 13:34:59 +00:00
parent 09c21c6b86
commit b6cc99be8f
2 changed files with 30 additions and 1 deletions

View File

@@ -85,6 +85,24 @@ OpenLayers.Pixel = OpenLayers.Class({
return equals;
},
/**
* APIMethod: distanceTo
* Returns the distance to the pixel point passed in as a parameter.
*
* Parameters:
* px - {<OpenLayers.Pixel>}
*
* Returns:
* {Float} The pixel point passed in as parameter to calculate the
* distance to.
*/
distanceTo:function(px) {
return Math.sqrt(
Math.pow(this.x - px.x, 2) +
Math.pow(this.y - px.y, 2)
);
},
/**
* APIMethod: add
*