@immugio/three-math-extensions 0.2.9 → 0.2.10
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/CHANGELOG.md +23 -3
- package/README.md +1 -80
- package/cjs/index.js +3 -1
- package/cjs/isPointInPolygon.js +16 -0
- package/docs/README.md +86 -1
- package/docs/classes/BoundingBox.md +7 -7
- package/docs/classes/Line2D.md +88 -60
- package/docs/classes/Line3D.md +32 -32
- package/docs/classes/Polygon.md +15 -15
- package/docs/classes/Rectangle.md +17 -17
- package/docs/classes/Size2.md +3 -3
- package/docs/classes/Vec2.md +54 -6
- package/docs/classes/Vec3.md +11 -11
- package/docs/interfaces/Point2.md +2 -2
- package/docs/interfaces/Point3.md +3 -3
- package/docs/modules.md +25 -3
- package/esm/index.js +1 -0
- package/esm/isPointInPolygon.js +12 -0
- package/package.json +1 -1
- package/src/index.ts +2 -1
- package/src/isPointInPolygon.ts +19 -0
- package/types/index.d.ts +1 -0
- package/types/isPointInPolygon.d.ts +2 -0
package/docs/classes/Vec3.md
CHANGED
|
@@ -72,7 +72,7 @@ Adds x amount to this Vec3 instance and return this
|
|
|
72
72
|
|
|
73
73
|
#### Defined in
|
|
74
74
|
|
|
75
|
-
[src/Vec3.ts:65](https://github.com/Immugio/three-math-extensions/blob/
|
|
75
|
+
[src/Vec3.ts:65](https://github.com/Immugio/three-math-extensions/blob/66cba15/src/Vec3.ts#L65)
|
|
76
76
|
|
|
77
77
|
___
|
|
78
78
|
|
|
@@ -94,7 +94,7 @@ Adds y amount to this Vec3 instance and return this
|
|
|
94
94
|
|
|
95
95
|
#### Defined in
|
|
96
96
|
|
|
97
|
-
[src/Vec3.ts:56](https://github.com/Immugio/three-math-extensions/blob/
|
|
97
|
+
[src/Vec3.ts:56](https://github.com/Immugio/three-math-extensions/blob/66cba15/src/Vec3.ts#L56)
|
|
98
98
|
|
|
99
99
|
___
|
|
100
100
|
|
|
@@ -112,7 +112,7 @@ Vector3.clone
|
|
|
112
112
|
|
|
113
113
|
#### Defined in
|
|
114
114
|
|
|
115
|
-
[src/Vec3.ts:114](https://github.com/Immugio/three-math-extensions/blob/
|
|
115
|
+
[src/Vec3.ts:114](https://github.com/Immugio/three-math-extensions/blob/66cba15/src/Vec3.ts#L114)
|
|
116
116
|
|
|
117
117
|
___
|
|
118
118
|
|
|
@@ -134,7 +134,7 @@ Returns a clone of the point closest to this from the given points.
|
|
|
134
134
|
|
|
135
135
|
#### Defined in
|
|
136
136
|
|
|
137
|
-
[src/Vec3.ts:74](https://github.com/Immugio/three-math-extensions/blob/
|
|
137
|
+
[src/Vec3.ts:74](https://github.com/Immugio/three-math-extensions/blob/66cba15/src/Vec3.ts#L74)
|
|
138
138
|
|
|
139
139
|
___
|
|
140
140
|
|
|
@@ -156,7 +156,7 @@ Get distance to another vector while ignoring the y-axis.
|
|
|
156
156
|
|
|
157
157
|
#### Defined in
|
|
158
158
|
|
|
159
|
-
[src/Vec3.ts:98](https://github.com/Immugio/three-math-extensions/blob/
|
|
159
|
+
[src/Vec3.ts:98](https://github.com/Immugio/three-math-extensions/blob/66cba15/src/Vec3.ts#L98)
|
|
160
160
|
|
|
161
161
|
___
|
|
162
162
|
|
|
@@ -180,7 +180,7 @@ maxDistance is the maximum distance between the two vectors within which they ar
|
|
|
180
180
|
|
|
181
181
|
#### Defined in
|
|
182
182
|
|
|
183
|
-
[src/Vec3.ts:106](https://github.com/Immugio/three-math-extensions/blob/
|
|
183
|
+
[src/Vec3.ts:106](https://github.com/Immugio/three-math-extensions/blob/66cba15/src/Vec3.ts#L106)
|
|
184
184
|
|
|
185
185
|
___
|
|
186
186
|
|
|
@@ -204,7 +204,7 @@ This Vec3 instance.
|
|
|
204
204
|
|
|
205
205
|
#### Defined in
|
|
206
206
|
|
|
207
|
-
[src/Vec3.ts:43](https://github.com/Immugio/three-math-extensions/blob/
|
|
207
|
+
[src/Vec3.ts:43](https://github.com/Immugio/three-math-extensions/blob/66cba15/src/Vec3.ts#L43)
|
|
208
208
|
|
|
209
209
|
___
|
|
210
210
|
|
|
@@ -229,7 +229,7 @@ This Vec3 instance.
|
|
|
229
229
|
|
|
230
230
|
#### Defined in
|
|
231
231
|
|
|
232
|
-
[src/Vec3.ts:27](https://github.com/Immugio/three-math-extensions/blob/
|
|
232
|
+
[src/Vec3.ts:27](https://github.com/Immugio/three-math-extensions/blob/66cba15/src/Vec3.ts#L27)
|
|
233
233
|
|
|
234
234
|
___
|
|
235
235
|
|
|
@@ -245,7 +245,7 @@ Projects this Vec3 instance onto 2d plan. Vec3.z becomes Vec2.y and Vec3.y is ig
|
|
|
245
245
|
|
|
246
246
|
#### Defined in
|
|
247
247
|
|
|
248
|
-
[src/Vec3.ts:90](https://github.com/Immugio/three-math-extensions/blob/
|
|
248
|
+
[src/Vec3.ts:90](https://github.com/Immugio/three-math-extensions/blob/66cba15/src/Vec3.ts#L90)
|
|
249
249
|
|
|
250
250
|
___
|
|
251
251
|
|
|
@@ -261,7 +261,7 @@ Returns a clone of this Vec3 instance with y and z swapped.
|
|
|
261
261
|
|
|
262
262
|
#### Defined in
|
|
263
263
|
|
|
264
|
-
[src/Vec3.ts:83](https://github.com/Immugio/three-math-extensions/blob/
|
|
264
|
+
[src/Vec3.ts:83](https://github.com/Immugio/three-math-extensions/blob/66cba15/src/Vec3.ts#L83)
|
|
265
265
|
|
|
266
266
|
___
|
|
267
267
|
|
|
@@ -285,4 +285,4 @@ A new Vec3 instance.
|
|
|
285
285
|
|
|
286
286
|
#### Defined in
|
|
287
287
|
|
|
288
|
-
[src/Vec3.ts:17](https://github.com/Immugio/three-math-extensions/blob/
|
|
288
|
+
[src/Vec3.ts:17](https://github.com/Immugio/three-math-extensions/blob/66cba15/src/Vec3.ts#L17)
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
#### Defined in
|
|
19
19
|
|
|
20
|
-
[src/Point2.ts:2](https://github.com/Immugio/three-math-extensions/blob/
|
|
20
|
+
[src/Point2.ts:2](https://github.com/Immugio/three-math-extensions/blob/66cba15/src/Point2.ts#L2)
|
|
21
21
|
|
|
22
22
|
___
|
|
23
23
|
|
|
@@ -27,4 +27,4 @@ ___
|
|
|
27
27
|
|
|
28
28
|
#### Defined in
|
|
29
29
|
|
|
30
|
-
[src/Point2.ts:3](https://github.com/Immugio/three-math-extensions/blob/
|
|
30
|
+
[src/Point2.ts:3](https://github.com/Immugio/three-math-extensions/blob/66cba15/src/Point2.ts#L3)
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
|
|
19
19
|
#### Defined in
|
|
20
20
|
|
|
21
|
-
[src/Point3.ts:2](https://github.com/Immugio/three-math-extensions/blob/
|
|
21
|
+
[src/Point3.ts:2](https://github.com/Immugio/three-math-extensions/blob/66cba15/src/Point3.ts#L2)
|
|
22
22
|
|
|
23
23
|
___
|
|
24
24
|
|
|
@@ -28,7 +28,7 @@ ___
|
|
|
28
28
|
|
|
29
29
|
#### Defined in
|
|
30
30
|
|
|
31
|
-
[src/Point3.ts:3](https://github.com/Immugio/three-math-extensions/blob/
|
|
31
|
+
[src/Point3.ts:3](https://github.com/Immugio/three-math-extensions/blob/66cba15/src/Point3.ts#L3)
|
|
32
32
|
|
|
33
33
|
___
|
|
34
34
|
|
|
@@ -38,4 +38,4 @@ ___
|
|
|
38
38
|
|
|
39
39
|
#### Defined in
|
|
40
40
|
|
|
41
|
-
[src/Point3.ts:4](https://github.com/Immugio/three-math-extensions/blob/
|
|
41
|
+
[src/Point3.ts:4](https://github.com/Immugio/three-math-extensions/blob/66cba15/src/Point3.ts#L4)
|
package/docs/modules.md
CHANGED
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
|
|
27
27
|
### Functions
|
|
28
28
|
|
|
29
|
+
- [isPointInPolygon](modules.md#ispointinpolygon)
|
|
29
30
|
- [normalizeAngleDegrees](modules.md#normalizeangledegrees)
|
|
30
31
|
- [normalizeAngleRadians](modules.md#normalizeangleradians)
|
|
31
32
|
|
|
@@ -37,10 +38,31 @@
|
|
|
37
38
|
|
|
38
39
|
#### Defined in
|
|
39
40
|
|
|
40
|
-
[src/MathConstants.ts:1](https://github.com/Immugio/three-math-extensions/blob/
|
|
41
|
+
[src/MathConstants.ts:1](https://github.com/Immugio/three-math-extensions/blob/66cba15/src/MathConstants.ts#L1)
|
|
41
42
|
|
|
42
43
|
## Functions
|
|
43
44
|
|
|
45
|
+
### isPointInPolygon
|
|
46
|
+
|
|
47
|
+
▸ **isPointInPolygon**(`p`, `point`): `boolean`
|
|
48
|
+
|
|
49
|
+
#### Parameters
|
|
50
|
+
|
|
51
|
+
| Name | Type |
|
|
52
|
+
| :------ | :------ |
|
|
53
|
+
| `p` | [`Point2`](interfaces/Point2.md)[] |
|
|
54
|
+
| `point` | [`Point2`](interfaces/Point2.md) |
|
|
55
|
+
|
|
56
|
+
#### Returns
|
|
57
|
+
|
|
58
|
+
`boolean`
|
|
59
|
+
|
|
60
|
+
#### Defined in
|
|
61
|
+
|
|
62
|
+
[src/isPointInPolygon.ts:3](https://github.com/Immugio/three-math-extensions/blob/66cba15/src/isPointInPolygon.ts#L3)
|
|
63
|
+
|
|
64
|
+
___
|
|
65
|
+
|
|
44
66
|
### normalizeAngleDegrees
|
|
45
67
|
|
|
46
68
|
▸ **normalizeAngleDegrees**(`angle`): `number`
|
|
@@ -59,7 +81,7 @@ Normalizes an angle in degrees to the range [0, 360].
|
|
|
59
81
|
|
|
60
82
|
#### Defined in
|
|
61
83
|
|
|
62
|
-
[src/normalizeAngleDegrees.ts:5](https://github.com/Immugio/three-math-extensions/blob/
|
|
84
|
+
[src/normalizeAngleDegrees.ts:5](https://github.com/Immugio/three-math-extensions/blob/66cba15/src/normalizeAngleDegrees.ts#L5)
|
|
63
85
|
|
|
64
86
|
___
|
|
65
87
|
|
|
@@ -81,4 +103,4 @@ Normalize an angle in radians to the range of 0 to 2π.
|
|
|
81
103
|
|
|
82
104
|
#### Defined in
|
|
83
105
|
|
|
84
|
-
[src/normalizeAngleRadians.ts:7](https://github.com/Immugio/three-math-extensions/blob/
|
|
106
|
+
[src/normalizeAngleRadians.ts:7](https://github.com/Immugio/three-math-extensions/blob/66cba15/src/normalizeAngleRadians.ts#L7)
|
package/esm/index.js
CHANGED
|
@@ -9,3 +9,4 @@ export { Rectangle } from "./Rectangle";
|
|
|
9
9
|
export { normalizeAngleDegrees } from "./normalizeAngleDegrees";
|
|
10
10
|
export { normalizeAngleRadians } from "./normalizeAngleRadians";
|
|
11
11
|
export { TwoPI } from "./MathConstants";
|
|
12
|
+
export { isPointInPolygon } from "./isPointInPolygon";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export function isPointInPolygon(p, point) {
|
|
2
|
+
const x = point.x, y = point.y;
|
|
3
|
+
let i, j, c = false;
|
|
4
|
+
for (i = 0, j = p.length - 1; i < p.length; j = i++) {
|
|
5
|
+
if ((((p[i].y <= y) && (y < p[j].y)) ||
|
|
6
|
+
((p[j].y <= y) && (y < p[i].y))) &&
|
|
7
|
+
(x < (p[j].x - p[i].x) * (y - p[i].y) / (p[j].y - p[i].y) + p[i].x)) {
|
|
8
|
+
c = !c;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
return c;
|
|
12
|
+
}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -10,4 +10,5 @@ export { normalizeAngleDegrees } from "./normalizeAngleDegrees";
|
|
|
10
10
|
export { normalizeAngleRadians } from "./normalizeAngleRadians";
|
|
11
11
|
export { TwoPI } from "./MathConstants";
|
|
12
12
|
export { Point2 } from "./Point2";
|
|
13
|
-
export { Point3 } from "./Point3";
|
|
13
|
+
export { Point3 } from "./Point3";
|
|
14
|
+
export { isPointInPolygon } from "./isPointInPolygon";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Point2 } from "./Point2";
|
|
2
|
+
|
|
3
|
+
export function isPointInPolygon(p: Point2[], point: Point2): boolean {
|
|
4
|
+
|
|
5
|
+
const x = point.x, y = point.y;
|
|
6
|
+
|
|
7
|
+
let i: number, j: number, c = false;
|
|
8
|
+
|
|
9
|
+
for (i = 0, j = p.length - 1; i < p.length; j = i++) {
|
|
10
|
+
|
|
11
|
+
if ((((p[i].y <= y) && (y < p[j].y)) ||
|
|
12
|
+
((p[j].y <= y) && (y < p[i].y))) &&
|
|
13
|
+
(x < (p[j].x - p[i].x) * (y - p[i].y) / (p[j].y - p[i].y) + p[i].x)) {
|
|
14
|
+
c = !c;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return c;
|
|
19
|
+
}
|
package/types/index.d.ts
CHANGED