#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:
@@ -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"
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user