aboutsummaryrefslogtreecommitdiffstats
path: root/extlib/leaflet/src/geometry/Transformation.js
diff options
context:
space:
mode:
authorJoar Wandborg <git@wandborg.com>2012-01-28 18:47:01 +0100
committerJoar Wandborg <git@wandborg.com>2012-01-28 18:47:01 +0100
commit3d0d3bc97270095fae5f9a2508068631c46a5e61 (patch)
tree76778fcacaae35fc5662f276dab512a07bcee186 /extlib/leaflet/src/geometry/Transformation.js
parentd7bec8577ea1b4d83df097f586324445fed1ef50 (diff)
parent9542a2ba076b7e00e79d7adb1a4e90a095427645 (diff)
downloadmediagoblin-3d0d3bc97270095fae5f9a2508068631c46a5e61.tar.lz
mediagoblin-3d0d3bc97270095fae5f9a2508068631c46a5e61.tar.xz
mediagoblin-3d0d3bc97270095fae5f9a2508068631c46a5e61.zip
Merge remote-tracking branch 'joar/exif-rebase'
Diffstat (limited to 'extlib/leaflet/src/geometry/Transformation.js')
-rw-r--r--extlib/leaflet/src/geometry/Transformation.js31
1 files changed, 31 insertions, 0 deletions
diff --git a/extlib/leaflet/src/geometry/Transformation.js b/extlib/leaflet/src/geometry/Transformation.js
new file mode 100644
index 00000000..37f40968
--- /dev/null
+++ b/extlib/leaflet/src/geometry/Transformation.js
@@ -0,0 +1,31 @@
+/*
+ * L.Transformation is an utility class to perform simple point transformations through a 2d-matrix.
+ */
+
+L.Transformation = L.Class.extend({
+ initialize: function(/*Number*/ a, /*Number*/ b, /*Number*/ c, /*Number*/ d) {
+ this._a = a;
+ this._b = b;
+ this._c = c;
+ this._d = d;
+ },
+
+ transform: function(point, scale) {
+ return this._transform(point.clone(), scale);
+ },
+
+ // destructive transform (faster)
+ _transform: function(/*Point*/ point, /*Number*/ scale) /*-> Point*/ {
+ scale = scale || 1;
+ point.x = scale * (this._a * point.x + this._b);
+ point.y = scale * (this._c * point.y + this._d);
+ return point;
+ },
+
+ untransform: function(/*Point*/ point, /*Number*/ scale) /*-> Point*/ {
+ scale = scale || 1;
+ return new L.Point(
+ (point.x/scale - this._b) / this._a,
+ (point.y/scale - this._d) / this._c);
+ }
+}); \ No newline at end of file