maplair
Version:
JavaScript library for mobile-friendly interactive maps
34 lines (33 loc) • 789 B
JavaScript
import { Point } from "./Point.js";
//#region src/geometry/Transformation.js
var Transformation = class {
constructor(a, b, c, d) {
if (Array.isArray(a)) {
this._a = a[0];
this._b = a[1];
this._c = a[2];
this._d = a[3];
return;
}
this._a = a;
this._b = b;
this._c = c;
this._d = d;
}
transform(point, scale) {
return this._transform(new Point(point), scale);
}
_transform(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(point, scale) {
scale ||= 1;
return new Point((point.x / scale - this._b) / this._a, (point.y / scale - this._d) / this._c);
}
};
//#endregion
export { Transformation };
//# sourceMappingURL=Transformation.js.map