@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/CHANGELOG.md
CHANGED
|
@@ -7,11 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
9
9
|
|
|
10
|
-
## [0.2.
|
|
10
|
+
## [0.2.10](https://github.com/Immugio/three-math-extensions/compare/16.15.10...0.2.10)
|
|
11
11
|
|
|
12
12
|
### Commits
|
|
13
13
|
|
|
14
14
|
- Add Rectangle, update Polygon [`58ee875`](https://github.com/Immugio/three-math-extensions/commit/58ee87539af8f9ade186e5250cba9e01926da514)
|
|
15
|
+
- Add isPointInPolygon [`a59eb4b`](https://github.com/Immugio/three-math-extensions/commit/a59eb4be026f17a3106070ae626a0588cd4f4411)
|
|
15
16
|
- Improve Line2D.closestPointToPoint, add Vec2.signedAngle [`151f214`](https://github.com/Immugio/three-math-extensions/commit/151f21462e0358057ad8e9d75d5782563a1061f6)
|
|
16
17
|
- Improve documentation [`d0fcb51`](https://github.com/Immugio/three-math-extensions/commit/d0fcb5132f127b4382ac5f7291575a061b8ec121)
|
|
17
18
|
- Vec3, Line3D - update documentation [`67d9c32`](https://github.com/Immugio/three-math-extensions/commit/67d9c328e08cc0a5599932d2f0529e97f31c9213)
|
|
@@ -30,7 +31,13 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
30
31
|
- Vec2.fromPoint and Vec3.fromPoint should accept null [`4b871af`](https://github.com/Immugio/three-math-extensions/commit/4b871af297bdcbe8584f1e2b99d602247b77687c)
|
|
31
32
|
- Excluded files from build [`ec70614`](https://github.com/Immugio/three-math-extensions/commit/ec70614bc7df7a98f854c7a6693365118e04faf7)
|
|
32
33
|
|
|
33
|
-
## [16.15.10](https://github.com/Immugio/three-math-extensions/compare/0.2.
|
|
34
|
+
## [16.15.10](https://github.com/Immugio/three-math-extensions/compare/0.2.9...16.15.10) - 2023-01-02
|
|
35
|
+
|
|
36
|
+
## [0.2.9](https://github.com/Immugio/three-math-extensions/compare/0.2.8...0.2.9) - 2023-05-22
|
|
37
|
+
|
|
38
|
+
### Commits
|
|
39
|
+
|
|
40
|
+
- Line2D.intersect - enable line segments intersection only [`1f1470e`](https://github.com/Immugio/three-math-extensions/commit/1f1470e1cf00118e643f5c44a135e0baf6b76d41)
|
|
34
41
|
|
|
35
42
|
## [0.2.8](https://github.com/Immugio/three-math-extensions/compare/0.2.7...0.2.8) - 2023-05-19
|
|
36
43
|
|
|
@@ -168,7 +175,19 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
168
175
|
|
|
169
176
|
- Release 0.0.4 - tag pattern 4 [`ab9ad4e`](https://github.com/Immugio/three-math-extensions/commit/ab9ad4e49477a991482ed6d4d3a3ca4687a70b44)
|
|
170
177
|
|
|
171
|
-
## 0.0.7 - 2022-11-21
|
|
178
|
+
## [0.0.7](https://github.com/Immugio/three-math-extensions/compare/0.0.6...0.0.7) - 2022-11-21
|
|
179
|
+
|
|
180
|
+
## [0.0.6](https://github.com/Immugio/three-math-extensions/compare/0.0.4...0.0.6) - 2022-11-24
|
|
181
|
+
|
|
182
|
+
### Commits
|
|
183
|
+
|
|
184
|
+
- Improve API, minor bug fix, improve test coverage [`881a5f0`](https://github.com/Immugio/three-math-extensions/commit/881a5f096823f0d5fd90faa76cd602f076291bc5)
|
|
185
|
+
- Add .npmignore [`f58329a`](https://github.com/Immugio/three-math-extensions/commit/f58329a86b96589bb574d6ebed37d4cc4474663a)
|
|
186
|
+
- Correct change log version [`c6244bf`](https://github.com/Immugio/three-math-extensions/commit/c6244bf1488ad21bcc5589d1dff62c41d8182d48)
|
|
187
|
+
- Release 0.0.4 - tag pattern 6 [`c1c5454`](https://github.com/Immugio/three-math-extensions/commit/c1c54541ed400e1ad49bf42fe8926cd5293efefd)
|
|
188
|
+
- Release 0.0.4 - tag pattern 5 [`5245eed`](https://github.com/Immugio/three-math-extensions/commit/5245eed60195103e989c0fadf9bd642f39ef4589)
|
|
189
|
+
|
|
190
|
+
## 0.0.4 - 2022-11-21
|
|
172
191
|
|
|
173
192
|
### Commits
|
|
174
193
|
|
|
@@ -185,6 +204,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
185
204
|
- Edit publish script condition [`dc77d89`](https://github.com/Immugio/three-math-extensions/commit/dc77d8978d87daab8732d6429ad1b01ba0ca6f97)
|
|
186
205
|
- CI to use node version 16 [`dc42650`](https://github.com/Immugio/three-math-extensions/commit/dc426508939de922cc0316b7652bbd09aeed4610)
|
|
187
206
|
- Action rename [`26a1f01`](https://github.com/Immugio/three-math-extensions/commit/26a1f014827faab2c02d30ca8ed18dac8f9ff8af)
|
|
207
|
+
- Release 0.0.4 - tag pattern 4 [`ab9ad4e`](https://github.com/Immugio/three-math-extensions/commit/ab9ad4e49477a991482ed6d4d3a3ca4687a70b44)
|
|
188
208
|
- Release 0.0.4 - tag pattern 3 [`d7d4c8f`](https://github.com/Immugio/three-math-extensions/commit/d7d4c8f546e6550868ddd06a5213fdec6c68bcd2)
|
|
189
209
|
- Release 0.0.4 - tag pattern 2 [`0dcf801`](https://github.com/Immugio/three-math-extensions/commit/0dcf80190bd67a3ca93d45131a403201ab39e00f)
|
|
190
210
|
- Release 0.0.4 - tag pattern [`e7f2f76`](https://github.com/Immugio/three-math-extensions/commit/e7f2f76aa247e1c51f0522c300a7aaf07253039c)
|
package/README.md
CHANGED
|
@@ -6,83 +6,4 @@
|
|
|
6
6
|
|
|
7
7
|
# @immugio/three-math-extensions
|
|
8
8
|
|
|
9
|
-
##
|
|
10
|
-
|
|
11
|
-
### Classes
|
|
12
|
-
|
|
13
|
-
- [BoundingBox](docs/classes/BoundingBox.md)
|
|
14
|
-
- [Line2D](docs/classes/Line2D.md)
|
|
15
|
-
- [Line3D](docs/classes/Line3D.md)
|
|
16
|
-
- [Polygon](docs/classes/Polygon.md)
|
|
17
|
-
- [Rectangle](docs/classes/Rectangle.md)
|
|
18
|
-
- [Size2](docs/classes/Size2.md)
|
|
19
|
-
- [Vec2](docs/classes/Vec2.md)
|
|
20
|
-
- [Vec3](docs/classes/Vec3.md)
|
|
21
|
-
|
|
22
|
-
### Interfaces
|
|
23
|
-
|
|
24
|
-
- [Point2](docs/interfaces/Point2.md)
|
|
25
|
-
- [Point3](docs/interfaces/Point3.md)
|
|
26
|
-
|
|
27
|
-
### Variables
|
|
28
|
-
|
|
29
|
-
- [TwoPI](docs/modules.md#twopi)
|
|
30
|
-
|
|
31
|
-
### Functions
|
|
32
|
-
|
|
33
|
-
- [normalizeAngleDegrees](docs/modules.md#normalizeangledegrees)
|
|
34
|
-
- [normalizeAngleRadians](docs/modules.md#normalizeangleradians)
|
|
35
|
-
|
|
36
|
-
## Variables
|
|
37
|
-
|
|
38
|
-
### TwoPI
|
|
39
|
-
|
|
40
|
-
• `Const` **TwoPI**: `number`
|
|
41
|
-
|
|
42
|
-
#### Defined in
|
|
43
|
-
|
|
44
|
-
[src/MathConstants.ts:1](https://github.com/Immugio/three-math-extensions/blob/151f214/src/MathConstants.ts#L1)
|
|
45
|
-
|
|
46
|
-
## Functions
|
|
47
|
-
|
|
48
|
-
### normalizeAngleDegrees
|
|
49
|
-
|
|
50
|
-
▸ **normalizeAngleDegrees**(`angle`): `number`
|
|
51
|
-
|
|
52
|
-
Normalizes an angle in degrees to the range [0, 360].
|
|
53
|
-
|
|
54
|
-
#### Parameters
|
|
55
|
-
|
|
56
|
-
| Name | Type | Description |
|
|
57
|
-
| :------ | :------ | :------ |
|
|
58
|
-
| `angle` | `number` | in degrees |
|
|
59
|
-
|
|
60
|
-
#### Returns
|
|
61
|
-
|
|
62
|
-
`number`
|
|
63
|
-
|
|
64
|
-
#### Defined in
|
|
65
|
-
|
|
66
|
-
[src/normalizeAngleDegrees.ts:5](https://github.com/Immugio/three-math-extensions/blob/151f214/src/normalizeAngleDegrees.ts#L5)
|
|
67
|
-
|
|
68
|
-
___
|
|
69
|
-
|
|
70
|
-
### normalizeAngleRadians
|
|
71
|
-
|
|
72
|
-
▸ **normalizeAngleRadians**(`angle`): `number`
|
|
73
|
-
|
|
74
|
-
Normalize an angle in radians to the range of 0 to 2π.
|
|
75
|
-
|
|
76
|
-
#### Parameters
|
|
77
|
-
|
|
78
|
-
| Name | Type | Description |
|
|
79
|
-
| :------ | :------ | :------ |
|
|
80
|
-
| `angle` | `number` | in radians |
|
|
81
|
-
|
|
82
|
-
#### Returns
|
|
83
|
-
|
|
84
|
-
`number`
|
|
85
|
-
|
|
86
|
-
#### Defined in
|
|
87
|
-
|
|
88
|
-
[src/normalizeAngleRadians.ts:7](https://github.com/Immugio/three-math-extensions/blob/151f214/src/normalizeAngleRadians.ts#L7)
|
|
9
|
+
## [Documentation](docs/modules.md)
|
package/cjs/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TwoPI = exports.normalizeAngleRadians = exports.normalizeAngleDegrees = exports.Rectangle = exports.BoundingBox = exports.Polygon = exports.Size2 = exports.Line3D = exports.Line2D = exports.Vec3 = exports.Vec2 = void 0;
|
|
3
|
+
exports.isPointInPolygon = exports.TwoPI = exports.normalizeAngleRadians = exports.normalizeAngleDegrees = exports.Rectangle = exports.BoundingBox = exports.Polygon = exports.Size2 = exports.Line3D = exports.Line2D = exports.Vec3 = exports.Vec2 = void 0;
|
|
4
4
|
var Vec2_1 = require("./Vec2");
|
|
5
5
|
Object.defineProperty(exports, "Vec2", { enumerable: true, get: function () { return Vec2_1.Vec2; } });
|
|
6
6
|
var Vec3_1 = require("./Vec3");
|
|
@@ -23,3 +23,5 @@ var normalizeAngleRadians_1 = require("./normalizeAngleRadians");
|
|
|
23
23
|
Object.defineProperty(exports, "normalizeAngleRadians", { enumerable: true, get: function () { return normalizeAngleRadians_1.normalizeAngleRadians; } });
|
|
24
24
|
var MathConstants_1 = require("./MathConstants");
|
|
25
25
|
Object.defineProperty(exports, "TwoPI", { enumerable: true, get: function () { return MathConstants_1.TwoPI; } });
|
|
26
|
+
var isPointInPolygon_1 = require("./isPointInPolygon");
|
|
27
|
+
Object.defineProperty(exports, "isPointInPolygon", { enumerable: true, get: function () { return isPointInPolygon_1.isPointInPolygon; } });
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isPointInPolygon = void 0;
|
|
4
|
+
function isPointInPolygon(p, point) {
|
|
5
|
+
const x = point.x, y = point.y;
|
|
6
|
+
let i, j, c = false;
|
|
7
|
+
for (i = 0, j = p.length - 1; i < p.length; j = i++) {
|
|
8
|
+
if ((((p[i].y <= y) && (y < p[j].y)) ||
|
|
9
|
+
((p[j].y <= y) && (y < p[i].y))) &&
|
|
10
|
+
(x < (p[j].x - p[i].x) * (y - p[i].y) / (p[j].y - p[i].y) + p[i].x)) {
|
|
11
|
+
c = !c;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return c;
|
|
15
|
+
}
|
|
16
|
+
exports.isPointInPolygon = isPointInPolygon;
|
package/docs/README.md
CHANGED
|
@@ -1,5 +1,90 @@
|
|
|
1
1
|
@immugio/three-math-extensions / [Exports](modules.md)
|
|
2
2
|
|
|
3
|
-
# Set of utilities for 2d and 3d
|
|
3
|
+
# Set of utilities for 2d and 3d math built on top of three.js
|
|
4
4
|
|
|
5
5
|
[](https://github.com/Immugio/three-math-extensions/actions/workflows/build.yml)
|
|
6
|
+
|
|
7
|
+
[@immugio/three-math-extensions](README.md) / Exports
|
|
8
|
+
|
|
9
|
+
# @immugio/three-math-extensions
|
|
10
|
+
|
|
11
|
+
## Table of contents
|
|
12
|
+
|
|
13
|
+
### Classes
|
|
14
|
+
|
|
15
|
+
- [BoundingBox](docs/classes/BoundingBox.md)
|
|
16
|
+
- [Line2D](docs/classes/Line2D.md)
|
|
17
|
+
- [Line3D](docs/classes/Line3D.md)
|
|
18
|
+
- [Polygon](docs/classes/Polygon.md)
|
|
19
|
+
- [Rectangle](docs/classes/Rectangle.md)
|
|
20
|
+
- [Size2](docs/classes/Size2.md)
|
|
21
|
+
- [Vec2](docs/classes/Vec2.md)
|
|
22
|
+
- [Vec3](docs/classes/Vec3.md)
|
|
23
|
+
|
|
24
|
+
### Interfaces
|
|
25
|
+
|
|
26
|
+
- [Point2](docs/interfaces/Point2.md)
|
|
27
|
+
- [Point3](docs/interfaces/Point3.md)
|
|
28
|
+
|
|
29
|
+
### Variables
|
|
30
|
+
|
|
31
|
+
- [TwoPI](docs/modules.md#twopi)
|
|
32
|
+
|
|
33
|
+
### Functions
|
|
34
|
+
|
|
35
|
+
- [normalizeAngleDegrees](docs/modules.md#normalizeangledegrees)
|
|
36
|
+
- [normalizeAngleRadians](docs/modules.md#normalizeangleradians)
|
|
37
|
+
|
|
38
|
+
## Variables
|
|
39
|
+
|
|
40
|
+
### TwoPI
|
|
41
|
+
|
|
42
|
+
• `Const` **TwoPI**: `number`
|
|
43
|
+
|
|
44
|
+
#### Defined in
|
|
45
|
+
|
|
46
|
+
[src/MathConstants.ts:1](https://github.com/Immugio/three-math-extensions/blob/151f214/src/MathConstants.ts#L1)
|
|
47
|
+
|
|
48
|
+
## Functions
|
|
49
|
+
|
|
50
|
+
### normalizeAngleDegrees
|
|
51
|
+
|
|
52
|
+
▸ **normalizeAngleDegrees**(`angle`): `number`
|
|
53
|
+
|
|
54
|
+
Normalizes an angle in degrees to the range [0, 360].
|
|
55
|
+
|
|
56
|
+
#### Parameters
|
|
57
|
+
|
|
58
|
+
| Name | Type | Description |
|
|
59
|
+
| :------ | :------ | :------ |
|
|
60
|
+
| `angle` | `number` | in degrees |
|
|
61
|
+
|
|
62
|
+
#### Returns
|
|
63
|
+
|
|
64
|
+
`number`
|
|
65
|
+
|
|
66
|
+
#### Defined in
|
|
67
|
+
|
|
68
|
+
[src/normalizeAngleDegrees.ts:5](https://github.com/Immugio/three-math-extensions/blob/151f214/src/normalizeAngleDegrees.ts#L5)
|
|
69
|
+
|
|
70
|
+
___
|
|
71
|
+
|
|
72
|
+
### normalizeAngleRadians
|
|
73
|
+
|
|
74
|
+
▸ **normalizeAngleRadians**(`angle`): `number`
|
|
75
|
+
|
|
76
|
+
Normalize an angle in radians to the range of 0 to 2π.
|
|
77
|
+
|
|
78
|
+
#### Parameters
|
|
79
|
+
|
|
80
|
+
| Name | Type | Description |
|
|
81
|
+
| :------ | :------ | :------ |
|
|
82
|
+
| `angle` | `number` | in radians |
|
|
83
|
+
|
|
84
|
+
#### Returns
|
|
85
|
+
|
|
86
|
+
`number`
|
|
87
|
+
|
|
88
|
+
#### Defined in
|
|
89
|
+
|
|
90
|
+
[src/normalizeAngleRadians.ts:7](https://github.com/Immugio/three-math-extensions/blob/151f214/src/normalizeAngleRadians.ts#L7)
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
|
|
41
41
|
#### Defined in
|
|
42
42
|
|
|
43
|
-
[src/BoundingBox.ts:4](https://github.com/Immugio/three-math-extensions/blob/
|
|
43
|
+
[src/BoundingBox.ts:4](https://github.com/Immugio/three-math-extensions/blob/66cba15/src/BoundingBox.ts#L4)
|
|
44
44
|
|
|
45
45
|
## Properties
|
|
46
46
|
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
|
|
51
51
|
#### Defined in
|
|
52
52
|
|
|
53
|
-
[src/BoundingBox.ts:4](https://github.com/Immugio/three-math-extensions/blob/
|
|
53
|
+
[src/BoundingBox.ts:4](https://github.com/Immugio/three-math-extensions/blob/66cba15/src/BoundingBox.ts#L4)
|
|
54
54
|
|
|
55
55
|
___
|
|
56
56
|
|
|
@@ -60,7 +60,7 @@ ___
|
|
|
60
60
|
|
|
61
61
|
#### Defined in
|
|
62
62
|
|
|
63
|
-
[src/BoundingBox.ts:4](https://github.com/Immugio/three-math-extensions/blob/
|
|
63
|
+
[src/BoundingBox.ts:4](https://github.com/Immugio/three-math-extensions/blob/66cba15/src/BoundingBox.ts#L4)
|
|
64
64
|
|
|
65
65
|
___
|
|
66
66
|
|
|
@@ -70,7 +70,7 @@ ___
|
|
|
70
70
|
|
|
71
71
|
#### Defined in
|
|
72
72
|
|
|
73
|
-
[src/BoundingBox.ts:4](https://github.com/Immugio/three-math-extensions/blob/
|
|
73
|
+
[src/BoundingBox.ts:4](https://github.com/Immugio/three-math-extensions/blob/66cba15/src/BoundingBox.ts#L4)
|
|
74
74
|
|
|
75
75
|
___
|
|
76
76
|
|
|
@@ -80,7 +80,7 @@ ___
|
|
|
80
80
|
|
|
81
81
|
#### Defined in
|
|
82
82
|
|
|
83
|
-
[src/BoundingBox.ts:4](https://github.com/Immugio/three-math-extensions/blob/
|
|
83
|
+
[src/BoundingBox.ts:4](https://github.com/Immugio/three-math-extensions/blob/66cba15/src/BoundingBox.ts#L4)
|
|
84
84
|
|
|
85
85
|
## Accessors
|
|
86
86
|
|
|
@@ -94,7 +94,7 @@ ___
|
|
|
94
94
|
|
|
95
95
|
#### Defined in
|
|
96
96
|
|
|
97
|
-
[src/BoundingBox.ts:11](https://github.com/Immugio/three-math-extensions/blob/
|
|
97
|
+
[src/BoundingBox.ts:11](https://github.com/Immugio/three-math-extensions/blob/66cba15/src/BoundingBox.ts#L11)
|
|
98
98
|
|
|
99
99
|
## Methods
|
|
100
100
|
|
|
@@ -114,4 +114,4 @@ ___
|
|
|
114
114
|
|
|
115
115
|
#### Defined in
|
|
116
116
|
|
|
117
|
-
[src/BoundingBox.ts:7](https://github.com/Immugio/three-math-extensions/blob/
|
|
117
|
+
[src/BoundingBox.ts:7](https://github.com/Immugio/three-math-extensions/blob/66cba15/src/BoundingBox.ts#L7)
|