@antv/l7-map 2.9.33 → 2.9.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/camera.js +766 -508
- package/lib/earthmap.js +389 -223
- package/lib/geo/edge_insets.js +117 -64
- package/lib/geo/lng_lat.js +86 -65
- package/lib/geo/lng_lat_bounds.js +162 -123
- package/lib/geo/mercator.js +91 -62
- package/lib/geo/point.js +234 -171
- package/lib/geo/simple.js +93 -61
- package/lib/geo/transform.js +982 -472
- package/lib/handler/IHandler.js +4 -16
- package/lib/handler/blockable_map_event.js +84 -63
- package/lib/handler/box_zoom.js +201 -123
- package/lib/handler/click_zoom.js +63 -55
- package/lib/handler/events/event.js +20 -35
- package/lib/handler/events/index.js +28 -35
- package/lib/handler/events/map_mouse_event.js +85 -42
- package/lib/handler/events/map_touch_event.js +116 -45
- package/lib/handler/events/map_wheel_event.js +70 -34
- package/lib/handler/events/render_event.js +50 -31
- package/lib/handler/handler_inertia.js +158 -114
- package/lib/handler/handler_manager.js +640 -381
- package/lib/handler/handler_util.js +11 -29
- package/lib/handler/keyboard.js +155 -114
- package/lib/handler/map_event.js +133 -84
- package/lib/handler/mouse/index.js +28 -35
- package/lib/handler/mouse/mouse_handler.js +126 -90
- package/lib/handler/mouse/mousepan_handler.js +64 -46
- package/lib/handler/mouse/mousepitch_hander.js +64 -44
- package/lib/handler/mouse/mouserotate_hander.js +64 -44
- package/lib/handler/mouse/util.js +22 -40
- package/lib/handler/scroll_zoom.js +318 -176
- package/lib/handler/shim/dblclick_zoom.js +76 -42
- package/lib/handler/shim/drag_pan.js +98 -48
- package/lib/handler/shim/drag_rotate.js +82 -43
- package/lib/handler/shim/touch_zoom_rotate.js +127 -59
- package/lib/handler/tap/single_tap_recognizer.js +113 -84
- package/lib/handler/tap/tap_drag_zoom.js +111 -93
- package/lib/handler/tap/tap_recognizer.js +72 -60
- package/lib/handler/tap/tap_zoom.js +113 -88
- package/lib/handler/touch/index.js +36 -38
- package/lib/handler/touch/touch_pan.js +126 -98
- package/lib/handler/touch/touch_pitch.js +108 -74
- package/lib/handler/touch/touch_rotate.js +93 -59
- package/lib/handler/touch/touch_zoom.js +71 -49
- package/lib/handler/touch/two_touch.js +129 -90
- package/lib/hash.js +149 -100
- package/lib/index.js +43 -20
- package/lib/interface.js +4 -16
- package/lib/map.js +420 -240
- package/lib/util.js +88 -69
- package/lib/utils/Aabb.js +134 -81
- package/lib/utils/dom.js +162 -88
- package/lib/utils/performance.js +46 -54
- package/lib/utils/primitives.js +53 -59
- package/lib/utils/task_queue.js +104 -61
- package/package.json +3 -3
package/lib/geo/mercator.js
CHANGED
|
@@ -1,91 +1,120 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
20
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
-
|
|
22
|
-
// src/geo/mercator.ts
|
|
23
|
-
var mercator_exports = {};
|
|
24
|
-
__export(mercator_exports, {
|
|
25
|
-
altitudeFromMercatorZ: () => altitudeFromMercatorZ,
|
|
26
|
-
default: () => MercatorCoordinate,
|
|
27
|
-
latFromMercatorY: () => latFromMercatorY,
|
|
28
|
-
lngFromMercatorX: () => lngFromMercatorX,
|
|
29
|
-
mercatorScale: () => mercatorScale,
|
|
30
|
-
mercatorXfromLng: () => mercatorXfromLng,
|
|
31
|
-
mercatorYfromLat: () => mercatorYfromLat,
|
|
32
|
-
mercatorZfromAltitude: () => mercatorZfromAltitude
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
33
9
|
});
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
10
|
+
exports.altitudeFromMercatorZ = altitudeFromMercatorZ;
|
|
11
|
+
exports.default = void 0;
|
|
12
|
+
exports.latFromMercatorY = latFromMercatorY;
|
|
13
|
+
exports.lngFromMercatorX = lngFromMercatorX;
|
|
14
|
+
exports.mercatorScale = mercatorScale;
|
|
15
|
+
exports.mercatorXfromLng = mercatorXfromLng;
|
|
16
|
+
exports.mercatorYfromLat = mercatorYfromLat;
|
|
17
|
+
exports.mercatorZfromAltitude = mercatorZfromAltitude;
|
|
18
|
+
|
|
19
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
20
|
+
|
|
21
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
22
|
+
|
|
23
|
+
var _lng_lat = _interopRequireWildcard(require("../geo/lng_lat"));
|
|
24
|
+
|
|
25
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
26
|
+
|
|
27
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
28
|
+
|
|
29
|
+
/*
|
|
30
|
+
* The average circumference of the world in meters.
|
|
31
|
+
*/
|
|
32
|
+
var earthCircumfrence = 2 * Math.PI * _lng_lat.earthRadius; // meters
|
|
33
|
+
|
|
34
|
+
/*
|
|
35
|
+
* The circumference at a line of latitude in meters.
|
|
36
|
+
*/
|
|
37
|
+
|
|
37
38
|
function circumferenceAtLatitude(latitude) {
|
|
38
39
|
return earthCircumfrence * Math.cos(latitude * Math.PI / 180);
|
|
39
40
|
}
|
|
41
|
+
|
|
40
42
|
function mercatorXfromLng(lng) {
|
|
41
43
|
return (180 + lng) / 360;
|
|
42
44
|
}
|
|
45
|
+
|
|
43
46
|
function mercatorYfromLat(lat) {
|
|
44
47
|
return (180 - 180 / Math.PI * Math.log(Math.tan(Math.PI / 4 + lat * Math.PI / 360))) / 360;
|
|
45
48
|
}
|
|
49
|
+
|
|
46
50
|
function mercatorZfromAltitude(altitude, lat) {
|
|
47
51
|
return altitude / circumferenceAtLatitude(lat);
|
|
48
52
|
}
|
|
53
|
+
|
|
49
54
|
function lngFromMercatorX(x) {
|
|
50
55
|
return x * 360 - 180;
|
|
51
56
|
}
|
|
57
|
+
|
|
52
58
|
function latFromMercatorY(y) {
|
|
53
|
-
|
|
59
|
+
var y2 = 180 - y * 360;
|
|
54
60
|
return 360 / Math.PI * Math.atan(Math.exp(y2 * Math.PI / 180)) - 90;
|
|
55
61
|
}
|
|
62
|
+
|
|
56
63
|
function altitudeFromMercatorZ(z, y) {
|
|
57
64
|
return z * circumferenceAtLatitude(latFromMercatorY(y));
|
|
58
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* Determine the Mercator scale factor for a given latitude, see
|
|
68
|
+
* https://en.wikipedia.org/wiki/Mercator_projection#Scale_factor
|
|
69
|
+
*
|
|
70
|
+
* At the equator the scale factor will be 1, which increases at higher latitudes.
|
|
71
|
+
*
|
|
72
|
+
* @param {number} lat Latitude
|
|
73
|
+
* @returns {number} scale factor
|
|
74
|
+
* @private
|
|
75
|
+
*/
|
|
76
|
+
|
|
77
|
+
|
|
59
78
|
function mercatorScale(lat) {
|
|
60
79
|
return 1 / Math.cos(lat * Math.PI / 180);
|
|
61
80
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
constructor(x, y, z = 0) {
|
|
81
|
+
|
|
82
|
+
var MercatorCoordinate = /*#__PURE__*/function () {
|
|
83
|
+
function MercatorCoordinate(x, y) {
|
|
84
|
+
var z = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
85
|
+
(0, _classCallCheck2.default)(this, MercatorCoordinate);
|
|
68
86
|
this.x = +x;
|
|
69
87
|
this.y = +y;
|
|
70
88
|
this.z = +z;
|
|
71
89
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
|
|
91
|
+
(0, _createClass2.default)(MercatorCoordinate, [{
|
|
92
|
+
key: "toLngLat",
|
|
93
|
+
value: function toLngLat() {
|
|
94
|
+
return new _lng_lat.default(lngFromMercatorX(this.x), latFromMercatorY(this.y));
|
|
95
|
+
}
|
|
96
|
+
}, {
|
|
97
|
+
key: "toAltitude",
|
|
98
|
+
value: function toAltitude() {
|
|
99
|
+
return altitudeFromMercatorZ(this.z, this.y);
|
|
100
|
+
}
|
|
101
|
+
}, {
|
|
102
|
+
key: "meterInMercatorCoordinateUnits",
|
|
103
|
+
value: function meterInMercatorCoordinateUnits() {
|
|
104
|
+
// 1 meter / circumference at equator in meters * Mercator projection scale factor at this latitude
|
|
105
|
+
return 1 / earthCircumfrence * mercatorScale(latFromMercatorY(this.y));
|
|
106
|
+
}
|
|
107
|
+
}], [{
|
|
108
|
+
key: "fromLngLat",
|
|
109
|
+
value: function fromLngLat(lngLatLike) {
|
|
110
|
+
var altitude = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
111
|
+
|
|
112
|
+
var lngLat = _lng_lat.default.convert(lngLatLike);
|
|
113
|
+
|
|
114
|
+
return new MercatorCoordinate(mercatorXfromLng(lngLat.lng), mercatorYfromLat(lngLat.lat), mercatorZfromAltitude(altitude, lngLat.lat));
|
|
115
|
+
}
|
|
116
|
+
}]);
|
|
117
|
+
return MercatorCoordinate;
|
|
118
|
+
}();
|
|
119
|
+
|
|
120
|
+
exports.default = MercatorCoordinate;
|
package/lib/geo/point.js
CHANGED
|
@@ -1,176 +1,239 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
18
4
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
__export(point_exports, {
|
|
22
|
-
default: () => Point
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
23
7
|
});
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
return a;
|
|
34
|
-
}
|
|
35
|
-
constructor(x, y) {
|
|
36
|
-
this.x = x;
|
|
37
|
-
this.y = y;
|
|
38
|
-
}
|
|
39
|
-
clone() {
|
|
40
|
-
return new Point(this.x, this.y);
|
|
41
|
-
}
|
|
42
|
-
_add(p) {
|
|
43
|
-
this.x += p.x;
|
|
44
|
-
this.y += p.y;
|
|
45
|
-
return this;
|
|
46
|
-
}
|
|
47
|
-
add(p) {
|
|
48
|
-
return this.clone()._add(p);
|
|
49
|
-
}
|
|
50
|
-
_sub(p) {
|
|
51
|
-
this.x -= p.x;
|
|
52
|
-
this.y -= p.y;
|
|
53
|
-
return this;
|
|
54
|
-
}
|
|
55
|
-
sub(p) {
|
|
56
|
-
return this.clone()._sub(p);
|
|
57
|
-
}
|
|
58
|
-
_multByPoint(p) {
|
|
59
|
-
this.x *= p.x;
|
|
60
|
-
this.y *= p.y;
|
|
61
|
-
return this;
|
|
62
|
-
}
|
|
63
|
-
multByPoint(p) {
|
|
64
|
-
return this.clone()._multByPoint(p);
|
|
65
|
-
}
|
|
66
|
-
_divByPoint(p) {
|
|
67
|
-
this.x /= p.x;
|
|
68
|
-
this.y /= p.y;
|
|
69
|
-
return this;
|
|
70
|
-
}
|
|
71
|
-
divByPoint(p) {
|
|
72
|
-
return this.clone()._divByPoint(p);
|
|
73
|
-
}
|
|
74
|
-
_mult(k) {
|
|
75
|
-
this.x *= k;
|
|
76
|
-
this.y *= k;
|
|
77
|
-
return this;
|
|
78
|
-
}
|
|
79
|
-
mult(k) {
|
|
80
|
-
return this.clone()._mult(k);
|
|
81
|
-
}
|
|
82
|
-
_div(k) {
|
|
83
|
-
this.x /= k;
|
|
84
|
-
this.y /= k;
|
|
85
|
-
return this;
|
|
86
|
-
}
|
|
87
|
-
div(k) {
|
|
88
|
-
return this.clone()._div(k);
|
|
89
|
-
}
|
|
90
|
-
_rotate(angle) {
|
|
91
|
-
const cos = Math.cos(angle);
|
|
92
|
-
const sin = Math.sin(angle);
|
|
93
|
-
const x = cos * this.x - sin * this.y;
|
|
94
|
-
const y = sin * this.x + cos * this.y;
|
|
95
|
-
this.x = x;
|
|
96
|
-
this.y = y;
|
|
97
|
-
return this;
|
|
98
|
-
}
|
|
99
|
-
rotate(angle) {
|
|
100
|
-
return this.clone()._rotate(angle);
|
|
101
|
-
}
|
|
102
|
-
_rotateAround(angle, p) {
|
|
103
|
-
const cos = Math.cos(angle);
|
|
104
|
-
const sin = Math.sin(angle);
|
|
105
|
-
const x = p.x + cos * (this.x - p.x) - sin * (this.y - p.y);
|
|
106
|
-
const y = p.y + sin * (this.x - p.x) + cos * (this.y - p.y);
|
|
107
|
-
this.x = x;
|
|
108
|
-
this.y = y;
|
|
109
|
-
return this;
|
|
110
|
-
}
|
|
111
|
-
roateAround(angle, p) {
|
|
112
|
-
return this.clone()._rotateAround(angle, p);
|
|
113
|
-
}
|
|
114
|
-
_matMult(m) {
|
|
115
|
-
const x = m[0] * this.x + m[1] * this.y;
|
|
116
|
-
const y = m[2] * this.x + m[3] * this.y;
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
+
|
|
12
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
|
+
|
|
14
|
+
var Point = /*#__PURE__*/function () {
|
|
15
|
+
function Point(x, y) {
|
|
16
|
+
(0, _classCallCheck2.default)(this, Point);
|
|
117
17
|
this.x = x;
|
|
118
18
|
this.y = y;
|
|
119
|
-
return this;
|
|
120
|
-
}
|
|
121
|
-
matMult(m) {
|
|
122
|
-
return this.clone()._matMult(m);
|
|
123
|
-
}
|
|
124
|
-
_unit() {
|
|
125
|
-
this.div(this.mag());
|
|
126
|
-
return this;
|
|
127
|
-
}
|
|
128
|
-
unit() {
|
|
129
|
-
return this.clone()._unit();
|
|
130
|
-
}
|
|
131
|
-
_perp() {
|
|
132
|
-
const y = this.y;
|
|
133
|
-
this.y = this.x;
|
|
134
|
-
this.x = -y;
|
|
135
|
-
return this;
|
|
136
|
-
}
|
|
137
|
-
perp() {
|
|
138
|
-
return this.clone()._perp();
|
|
139
|
-
}
|
|
140
|
-
_round() {
|
|
141
|
-
this.x = Math.round(this.x);
|
|
142
|
-
this.y = Math.round(this.y);
|
|
143
|
-
return this;
|
|
144
|
-
}
|
|
145
|
-
round() {
|
|
146
|
-
return this.clone()._round();
|
|
147
|
-
}
|
|
148
|
-
mag() {
|
|
149
|
-
return Math.sqrt(this.x * this.x + this.y * this.y);
|
|
150
|
-
}
|
|
151
|
-
equals(other) {
|
|
152
|
-
return this.x === other.x && this.y === other.y;
|
|
153
|
-
}
|
|
154
|
-
dist(p) {
|
|
155
|
-
return Math.sqrt(this.distSqr(p));
|
|
156
|
-
}
|
|
157
|
-
distSqr(p) {
|
|
158
|
-
const dx = p.x - this.x;
|
|
159
|
-
const dy = p.y - this.y;
|
|
160
|
-
return dx * dx + dy * dy;
|
|
161
19
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
|
|
20
|
+
|
|
21
|
+
(0, _createClass2.default)(Point, [{
|
|
22
|
+
key: "clone",
|
|
23
|
+
value: function clone() {
|
|
24
|
+
return new Point(this.x, this.y);
|
|
25
|
+
}
|
|
26
|
+
}, {
|
|
27
|
+
key: "_add",
|
|
28
|
+
value: function _add(p) {
|
|
29
|
+
this.x += p.x;
|
|
30
|
+
this.y += p.y;
|
|
31
|
+
return this;
|
|
32
|
+
}
|
|
33
|
+
}, {
|
|
34
|
+
key: "add",
|
|
35
|
+
value: function add(p) {
|
|
36
|
+
return this.clone()._add(p);
|
|
37
|
+
}
|
|
38
|
+
}, {
|
|
39
|
+
key: "_sub",
|
|
40
|
+
value: function _sub(p) {
|
|
41
|
+
this.x -= p.x;
|
|
42
|
+
this.y -= p.y;
|
|
43
|
+
return this;
|
|
44
|
+
}
|
|
45
|
+
}, {
|
|
46
|
+
key: "sub",
|
|
47
|
+
value: function sub(p) {
|
|
48
|
+
return this.clone()._sub(p);
|
|
49
|
+
}
|
|
50
|
+
}, {
|
|
51
|
+
key: "_multByPoint",
|
|
52
|
+
value: function _multByPoint(p) {
|
|
53
|
+
this.x *= p.x;
|
|
54
|
+
this.y *= p.y;
|
|
55
|
+
return this;
|
|
56
|
+
}
|
|
57
|
+
}, {
|
|
58
|
+
key: "multByPoint",
|
|
59
|
+
value: function multByPoint(p) {
|
|
60
|
+
return this.clone()._multByPoint(p);
|
|
61
|
+
}
|
|
62
|
+
}, {
|
|
63
|
+
key: "_divByPoint",
|
|
64
|
+
value: function _divByPoint(p) {
|
|
65
|
+
this.x /= p.x;
|
|
66
|
+
this.y /= p.y;
|
|
67
|
+
return this;
|
|
68
|
+
}
|
|
69
|
+
}, {
|
|
70
|
+
key: "divByPoint",
|
|
71
|
+
value: function divByPoint(p) {
|
|
72
|
+
return this.clone()._divByPoint(p);
|
|
73
|
+
}
|
|
74
|
+
}, {
|
|
75
|
+
key: "_mult",
|
|
76
|
+
value: function _mult(k) {
|
|
77
|
+
this.x *= k;
|
|
78
|
+
this.y *= k;
|
|
79
|
+
return this;
|
|
80
|
+
}
|
|
81
|
+
}, {
|
|
82
|
+
key: "mult",
|
|
83
|
+
value: function mult(k) {
|
|
84
|
+
return this.clone()._mult(k);
|
|
85
|
+
}
|
|
86
|
+
}, {
|
|
87
|
+
key: "_div",
|
|
88
|
+
value: function _div(k) {
|
|
89
|
+
this.x /= k;
|
|
90
|
+
this.y /= k;
|
|
91
|
+
return this;
|
|
92
|
+
}
|
|
93
|
+
}, {
|
|
94
|
+
key: "div",
|
|
95
|
+
value: function div(k) {
|
|
96
|
+
return this.clone()._div(k);
|
|
97
|
+
}
|
|
98
|
+
}, {
|
|
99
|
+
key: "_rotate",
|
|
100
|
+
value: function _rotate(angle) {
|
|
101
|
+
var cos = Math.cos(angle);
|
|
102
|
+
var sin = Math.sin(angle);
|
|
103
|
+
var x = cos * this.x - sin * this.y;
|
|
104
|
+
var y = sin * this.x + cos * this.y;
|
|
105
|
+
this.x = x;
|
|
106
|
+
this.y = y;
|
|
107
|
+
return this;
|
|
108
|
+
}
|
|
109
|
+
}, {
|
|
110
|
+
key: "rotate",
|
|
111
|
+
value: function rotate(angle) {
|
|
112
|
+
return this.clone()._rotate(angle);
|
|
113
|
+
}
|
|
114
|
+
}, {
|
|
115
|
+
key: "_rotateAround",
|
|
116
|
+
value: function _rotateAround(angle, p) {
|
|
117
|
+
var cos = Math.cos(angle);
|
|
118
|
+
var sin = Math.sin(angle);
|
|
119
|
+
var x = p.x + cos * (this.x - p.x) - sin * (this.y - p.y);
|
|
120
|
+
var y = p.y + sin * (this.x - p.x) + cos * (this.y - p.y);
|
|
121
|
+
this.x = x;
|
|
122
|
+
this.y = y;
|
|
123
|
+
return this;
|
|
124
|
+
}
|
|
125
|
+
}, {
|
|
126
|
+
key: "roateAround",
|
|
127
|
+
value: function roateAround(angle, p) {
|
|
128
|
+
return this.clone()._rotateAround(angle, p);
|
|
129
|
+
}
|
|
130
|
+
}, {
|
|
131
|
+
key: "_matMult",
|
|
132
|
+
value: function _matMult(m) {
|
|
133
|
+
var x = m[0] * this.x + m[1] * this.y;
|
|
134
|
+
var y = m[2] * this.x + m[3] * this.y;
|
|
135
|
+
this.x = x;
|
|
136
|
+
this.y = y;
|
|
137
|
+
return this;
|
|
138
|
+
}
|
|
139
|
+
}, {
|
|
140
|
+
key: "matMult",
|
|
141
|
+
value: function matMult(m) {
|
|
142
|
+
return this.clone()._matMult(m);
|
|
143
|
+
}
|
|
144
|
+
}, {
|
|
145
|
+
key: "_unit",
|
|
146
|
+
value: function _unit() {
|
|
147
|
+
this.div(this.mag());
|
|
148
|
+
return this;
|
|
149
|
+
}
|
|
150
|
+
}, {
|
|
151
|
+
key: "unit",
|
|
152
|
+
value: function unit() {
|
|
153
|
+
return this.clone()._unit();
|
|
154
|
+
}
|
|
155
|
+
}, {
|
|
156
|
+
key: "_perp",
|
|
157
|
+
value: function _perp() {
|
|
158
|
+
var y = this.y;
|
|
159
|
+
this.y = this.x;
|
|
160
|
+
this.x = -y;
|
|
161
|
+
return this;
|
|
162
|
+
}
|
|
163
|
+
}, {
|
|
164
|
+
key: "perp",
|
|
165
|
+
value: function perp() {
|
|
166
|
+
return this.clone()._perp();
|
|
167
|
+
}
|
|
168
|
+
}, {
|
|
169
|
+
key: "_round",
|
|
170
|
+
value: function _round() {
|
|
171
|
+
this.x = Math.round(this.x);
|
|
172
|
+
this.y = Math.round(this.y);
|
|
173
|
+
return this;
|
|
174
|
+
}
|
|
175
|
+
}, {
|
|
176
|
+
key: "round",
|
|
177
|
+
value: function round() {
|
|
178
|
+
return this.clone()._round();
|
|
179
|
+
}
|
|
180
|
+
}, {
|
|
181
|
+
key: "mag",
|
|
182
|
+
value: function mag() {
|
|
183
|
+
return Math.sqrt(this.x * this.x + this.y * this.y);
|
|
184
|
+
}
|
|
185
|
+
}, {
|
|
186
|
+
key: "equals",
|
|
187
|
+
value: function equals(other) {
|
|
188
|
+
return this.x === other.x && this.y === other.y;
|
|
189
|
+
}
|
|
190
|
+
}, {
|
|
191
|
+
key: "dist",
|
|
192
|
+
value: function dist(p) {
|
|
193
|
+
return Math.sqrt(this.distSqr(p));
|
|
194
|
+
}
|
|
195
|
+
}, {
|
|
196
|
+
key: "distSqr",
|
|
197
|
+
value: function distSqr(p) {
|
|
198
|
+
var dx = p.x - this.x;
|
|
199
|
+
var dy = p.y - this.y;
|
|
200
|
+
return dx * dx + dy * dy;
|
|
201
|
+
}
|
|
202
|
+
}, {
|
|
203
|
+
key: "angle",
|
|
204
|
+
value: function angle() {
|
|
205
|
+
return Math.atan2(this.y, this.x);
|
|
206
|
+
}
|
|
207
|
+
}, {
|
|
208
|
+
key: "angleTo",
|
|
209
|
+
value: function angleTo(b) {
|
|
210
|
+
return Math.atan2(this.y - b.y, this.x - b.x);
|
|
211
|
+
}
|
|
212
|
+
}, {
|
|
213
|
+
key: "angleWith",
|
|
214
|
+
value: function angleWith(b) {
|
|
215
|
+
return this.angleWithSep(b.x, b.y);
|
|
216
|
+
}
|
|
217
|
+
}, {
|
|
218
|
+
key: "angleWithSep",
|
|
219
|
+
value: function angleWithSep(x, y) {
|
|
220
|
+
return Math.atan2(this.x * y - this.y * x, this.x * x + this.y * y);
|
|
221
|
+
}
|
|
222
|
+
}], [{
|
|
223
|
+
key: "convert",
|
|
224
|
+
value: function convert(a) {
|
|
225
|
+
if (a instanceof Point) {
|
|
226
|
+
return a;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
if (Array.isArray(a)) {
|
|
230
|
+
return new Point(a[0], a[1]);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
return a;
|
|
234
|
+
}
|
|
235
|
+
}]);
|
|
236
|
+
return Point;
|
|
237
|
+
}();
|
|
238
|
+
|
|
239
|
+
exports.default = Point;
|