Script and makefile adjustments for updating extlib
[larjonas-mediagoblin.git] / extlib / leaflet / src / geometry / Transformation.js
blob37f4096897680909124337e77b9532f0c9f022b4
1 /*
2 * L.Transformation is an utility class to perform simple point transformations through a 2d-matrix.
3 */
5 L.Transformation = L.Class.extend({
6 initialize: function(/*Number*/ a, /*Number*/ b, /*Number*/ c, /*Number*/ d) {
7 this._a = a;
8 this._b = b;
9 this._c = c;
10 this._d = d;
13 transform: function(point, scale) {
14 return this._transform(point.clone(), scale);
17 // destructive transform (faster)
18 _transform: function(/*Point*/ point, /*Number*/ scale) /*-> Point*/ {
19 scale = scale || 1;
20 point.x = scale * (this._a * point.x + this._b);
21 point.y = scale * (this._c * point.y + this._d);
22 return point;
25 untransform: function(/*Point*/ point, /*Number*/ scale) /*-> Point*/ {
26 scale = scale || 1;
27 return new L.Point(
28 (point.x/scale - this._b) / this._a,
29 (point.y/scale - this._d) / this._c);
31 });