#805 - all geometries now know how to rotate - see the examples/rotate-features.html for geometry.rotate in action

git-svn-id: http://svn.openlayers.org/trunk/openlayers@3602 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Tim Schaub
2007-07-05 22:03:27 +00:00
parent debca7c477
commit dcffa03e7d
6 changed files with 207 additions and 0 deletions

View File

@@ -132,6 +132,22 @@ OpenLayers.Geometry.Point.prototype =
this.y = this.y + y;
},
/**
* APIMethod: rotate
* Rotate a point around another
*
* Parameters:
* angle - {Float} Rotation angle in radians (measured counterclockwise
* from the positive x-axis)
* origin - {OpenLayers.Geometry.Point} Center point for the rotation
*/
rotate: function(angle, origin) {
var radius = this.distanceTo(origin);
var theta = angle + Math.atan2(this.y - origin.y, this.x - origin.x);
this.x = origin.x + (radius * Math.cos(theta));
this.y = origin.y + (radius * Math.sin(theta));
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Geometry.Point"
});