Transformation fix

This commit is contained in:
mourner 2010-09-15 16:45:16 +03:00
parent 06d043853d
commit b6ead1dbf2
2 changed files with 6 additions and 6 deletions

View File

@ -7,13 +7,13 @@ describe("Transformation", function() {
}); });
it("#transform should perform a transformation", function() { it("#transform should perform a transformation", function() {
var p2 = t.transform(p); var p2 = t.transform(p, 2);
expect(p2).toEqual(new L.Point(12, 64)); expect(p2).toEqual(new L.Point(24, 128));
}); });
it("#untransform should perform a reverse transformation", function() { it("#untransform should perform a reverse transformation", function() {
var p2 = t.transform(p); var p2 = t.transform(p, 2);
var p3 = t.untransform(p2); var p3 = t.untransform(p2, 2);
expect(p3).toEqual(p); expect(p3).toEqual(p);
}); });
}); });

View File

@ -20,7 +20,7 @@ L.Transformation = L.Class.extend({
untransform: function(/*Point*/ point, /*Number*/ scale) /*-> Point*/ { untransform: function(/*Point*/ point, /*Number*/ scale) /*-> Point*/ {
scale = scale || 1; scale = scale || 1;
return new L.Point( return new L.Point(
((point.x - this._b) / this._a) / scale, (point.x/scale - this._b) / this._a,
((point.y - this._d) / this._c) / scale); (point.y/scale - this._d) / this._c);
} }
}); });