@immugio/three-math-extensions 0.2.5 → 0.2.7
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 +20 -16
- package/README.md +82 -2
- package/cjs/Line2D.js +33 -31
- package/cjs/MathConstants.js +4 -0
- package/cjs/Vec2.js +21 -0
- package/cjs/index.js +3 -1
- package/cjs/normalizeAngleDegrees.js +4 -0
- package/cjs/normalizeAngleRadians.js +7 -3
- package/docs/classes/BoundingBox.md +7 -7
- package/docs/classes/Line2D.md +80 -81
- package/docs/classes/Line3D.md +35 -35
- package/docs/classes/Polygon.md +38 -16
- package/docs/classes/Rectangle.md +18 -18
- package/docs/classes/Size2.md +3 -3
- package/docs/classes/Vec2.md +23 -6
- package/docs/classes/Vec3.md +12 -12
- package/docs/interfaces/Point2.md +30 -0
- package/docs/interfaces/Point3.md +41 -0
- package/docs/modules.md +68 -0
- package/esm/Line2D.js +33 -31
- package/esm/MathConstants.js +1 -0
- package/esm/Vec2.js +21 -0
- package/esm/index.js +1 -0
- package/esm/normalizeAngleDegrees.js +4 -0
- package/esm/normalizeAngleRadians.js +7 -3
- package/package.json +1 -1
- package/src/Line2D.ts +39 -34
- package/src/MathConstants.ts +1 -0
- package/src/Vec2.ts +26 -0
- package/src/index.ts +4 -1
- package/src/normalizeAngleDegrees.ts +4 -0
- package/src/normalizeAngleRadians.ts +11 -5
- package/types/Line2D.d.ts +10 -14
- package/types/MathConstants.d.ts +1 -0
- package/types/Vec2.d.ts +11 -0
- package/types/index.d.ts +3 -0
- package/types/normalizeAngleDegrees.d.ts +4 -0
- package/types/normalizeAngleRadians.d.ts +4 -0
- package/HowToRelease.txt +0 -13
package/CHANGELOG.md
CHANGED
|
@@ -7,20 +7,37 @@ 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.7](https://github.com/Immugio/three-math-extensions/compare/16.15.10...0.2.7)
|
|
11
11
|
|
|
12
12
|
### Commits
|
|
13
13
|
|
|
14
14
|
- Add Rectangle, update Polygon [`58ee875`](https://github.com/Immugio/three-math-extensions/commit/58ee87539af8f9ade186e5250cba9e01926da514)
|
|
15
|
+
- Improve Line2D.closestPointToPoint, add Vec2.signedAngle [`151f214`](https://github.com/Immugio/three-math-extensions/commit/151f21462e0358057ad8e9d75d5782563a1061f6)
|
|
16
|
+
- Improve documentation [`d0fcb51`](https://github.com/Immugio/three-math-extensions/commit/d0fcb5132f127b4382ac5f7291575a061b8ec121)
|
|
15
17
|
- Vec3, Line3D - update documentation [`67d9c32`](https://github.com/Immugio/three-math-extensions/commit/67d9c328e08cc0a5599932d2f0529e97f31c9213)
|
|
16
18
|
- Add Polygon [`629cff8`](https://github.com/Immugio/three-math-extensions/commit/629cff8ecbb963477e8ea76d7f8b16d95435cbad)
|
|
17
19
|
- Add Vec2.signedAngle [`863c8f2`](https://github.com/Immugio/three-math-extensions/commit/863c8f27f11288cbda535e21bb688206259269ed)
|
|
20
|
+
- Add Vec2.fromPoints to accept multiple points [`a261402`](https://github.com/Immugio/three-math-extensions/commit/a2614027cf5fb8263189b48f7e0bb9a23a552c15)
|
|
21
|
+
- Add Vec2.parallelTo [`989874d`](https://github.com/Immugio/three-math-extensions/commit/989874dcfe122d3ee84d8d56d79cb88e4e441736)
|
|
18
22
|
- Polygon from bounding size [`eae6701`](https://github.com/Immugio/three-math-extensions/commit/eae67012f57f426f8b5259b765000447ce06d608)
|
|
19
23
|
- Line2D and Line3D to return this instead of specific type [`761ef6a`](https://github.com/Immugio/three-math-extensions/commit/761ef6a9d8cc4e35120b666576794e521aa3b991)
|
|
24
|
+
- Line2D.hasIntersectionWithAngle to support optional tolerance [`b313bbe`](https://github.com/Immugio/three-math-extensions/commit/b313bbe118d435d53750deefd9a9e29ba6ec5c71)
|
|
25
|
+
- Line2D.hasIntersectionWithAngle - modulo all angles [`5409aa0`](https://github.com/Immugio/three-math-extensions/commit/5409aa0bc41510efa86d548e91837e44e5b6c343)
|
|
20
26
|
- Add Polygon to exports [`ed66775`](https://github.com/Immugio/three-math-extensions/commit/ed66775c33e961835b23843222b822cfd9c16b1d)
|
|
21
27
|
- Vec2.fromPoint and Vec3.fromPoint should accept null [`4b871af`](https://github.com/Immugio/three-math-extensions/commit/4b871af297bdcbe8584f1e2b99d602247b77687c)
|
|
28
|
+
- Excluded files from build [`ec70614`](https://github.com/Immugio/three-math-extensions/commit/ec70614bc7df7a98f854c7a6693365118e04faf7)
|
|
22
29
|
|
|
23
|
-
## [16.15.10](https://github.com/Immugio/three-math-extensions/compare/0.2.
|
|
30
|
+
## [16.15.10](https://github.com/Immugio/three-math-extensions/compare/0.2.6...16.15.10) - 2023-01-02
|
|
31
|
+
|
|
32
|
+
## [0.2.6](https://github.com/Immugio/three-math-extensions/compare/0.2.5...0.2.6) - 2023-04-14
|
|
33
|
+
|
|
34
|
+
### Commits
|
|
35
|
+
|
|
36
|
+
- Improve Line2D.closestPointToPoint, add Vec2.signedAngle [`151f214`](https://github.com/Immugio/three-math-extensions/commit/151f21462e0358057ad8e9d75d5782563a1061f6)
|
|
37
|
+
- Improve documentation [`d0fcb51`](https://github.com/Immugio/three-math-extensions/commit/d0fcb5132f127b4382ac5f7291575a061b8ec121)
|
|
38
|
+
- Excluded files from build [`ec70614`](https://github.com/Immugio/three-math-extensions/commit/ec70614bc7df7a98f854c7a6693365118e04faf7)
|
|
39
|
+
|
|
40
|
+
## [0.2.5](https://github.com/Immugio/three-math-extensions/compare/0.2.4...0.2.5) - 2023-04-11
|
|
24
41
|
|
|
25
42
|
## [0.2.4](https://github.com/Immugio/three-math-extensions/compare/0.2.3...0.2.4) - 2023-04-11
|
|
26
43
|
|
|
@@ -132,19 +149,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
132
149
|
|
|
133
150
|
- Release 0.0.4 - tag pattern 4 [`ab9ad4e`](https://github.com/Immugio/three-math-extensions/commit/ab9ad4e49477a991482ed6d4d3a3ca4687a70b44)
|
|
134
151
|
|
|
135
|
-
##
|
|
136
|
-
|
|
137
|
-
## [0.0.6](https://github.com/Immugio/three-math-extensions/compare/0.0.4...0.0.6) - 2022-11-24
|
|
138
|
-
|
|
139
|
-
### Commits
|
|
140
|
-
|
|
141
|
-
- Improve API, minor bug fix, improve test coverage [`881a5f0`](https://github.com/Immugio/three-math-extensions/commit/881a5f096823f0d5fd90faa76cd602f076291bc5)
|
|
142
|
-
- Add .npmignore [`f58329a`](https://github.com/Immugio/three-math-extensions/commit/f58329a86b96589bb574d6ebed37d4cc4474663a)
|
|
143
|
-
- Correct change log version [`c6244bf`](https://github.com/Immugio/three-math-extensions/commit/c6244bf1488ad21bcc5589d1dff62c41d8182d48)
|
|
144
|
-
- Release 0.0.4 - tag pattern 6 [`c1c5454`](https://github.com/Immugio/three-math-extensions/commit/c1c54541ed400e1ad49bf42fe8926cd5293efefd)
|
|
145
|
-
- Release 0.0.4 - tag pattern 5 [`5245eed`](https://github.com/Immugio/three-math-extensions/commit/5245eed60195103e989c0fadf9bd642f39ef4589)
|
|
146
|
-
|
|
147
|
-
## 0.0.4 - 2022-11-21
|
|
152
|
+
## 0.0.7 - 2022-11-21
|
|
148
153
|
|
|
149
154
|
### Commits
|
|
150
155
|
|
|
@@ -161,7 +166,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
161
166
|
- Edit publish script condition [`dc77d89`](https://github.com/Immugio/three-math-extensions/commit/dc77d8978d87daab8732d6429ad1b01ba0ca6f97)
|
|
162
167
|
- CI to use node version 16 [`dc42650`](https://github.com/Immugio/three-math-extensions/commit/dc426508939de922cc0316b7652bbd09aeed4610)
|
|
163
168
|
- Action rename [`26a1f01`](https://github.com/Immugio/three-math-extensions/commit/26a1f014827faab2c02d30ca8ed18dac8f9ff8af)
|
|
164
|
-
- Release 0.0.4 - tag pattern 4 [`ab9ad4e`](https://github.com/Immugio/three-math-extensions/commit/ab9ad4e49477a991482ed6d4d3a3ca4687a70b44)
|
|
165
169
|
- Release 0.0.4 - tag pattern 3 [`d7d4c8f`](https://github.com/Immugio/three-math-extensions/commit/d7d4c8f546e6550868ddd06a5213fdec6c68bcd2)
|
|
166
170
|
- Release 0.0.4 - tag pattern 2 [`0dcf801`](https://github.com/Immugio/three-math-extensions/commit/0dcf80190bd67a3ca93d45131a403201ab39e00f)
|
|
167
171
|
- Release 0.0.4 - tag pattern [`e7f2f76`](https://github.com/Immugio/three-math-extensions/commit/e7f2f76aa247e1c51f0522c300a7aaf07253039c)
|
package/README.md
CHANGED
|
@@ -1,8 +1,88 @@
|
|
|
1
|
-
# Set of utilities for 2d and 3d
|
|
1
|
+
# Set of utilities for 2d and 3d math built on top of three.js
|
|
2
2
|
|
|
3
3
|
[](https://github.com/Immugio/three-math-extensions/actions/workflows/build.yml)
|
|
4
4
|
|
|
5
|
+
[@immugio/three-math-extensions](README.md) / Exports
|
|
6
|
+
|
|
7
|
+
# @immugio/three-math-extensions
|
|
8
|
+
|
|
9
|
+
## Table of contents
|
|
10
|
+
|
|
11
|
+
### Classes
|
|
12
|
+
|
|
13
|
+
- [BoundingBox](docs/classes/BoundingBox.md)
|
|
5
14
|
- [Line2D](docs/classes/Line2D.md)
|
|
6
15
|
- [Line3D](docs/classes/Line3D.md)
|
|
16
|
+
- [Polygon](docs/classes/Polygon.md)
|
|
17
|
+
- [Rectangle](docs/classes/Rectangle.md)
|
|
18
|
+
- [Size2](docs/classes/Size2.md)
|
|
7
19
|
- [Vec2](docs/classes/Vec2.md)
|
|
8
|
-
- [Vec3](docs/classes/Vec3.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)
|
package/cjs/Line2D.js
CHANGED
|
@@ -3,6 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Line2D = void 0;
|
|
4
4
|
const three_1 = require("three");
|
|
5
5
|
const Vec2_1 = require("./Vec2");
|
|
6
|
+
const three_2 = require("three");
|
|
7
|
+
const MathConstants_1 = require("./MathConstants");
|
|
8
|
+
const _startP = /*@__PURE__*/ new Vec2_1.Vec2();
|
|
9
|
+
const _startEnd = /*@__PURE__*/ new Vec2_1.Vec2();
|
|
6
10
|
class Line2D {
|
|
7
11
|
start;
|
|
8
12
|
end;
|
|
@@ -329,34 +333,28 @@ class Line2D {
|
|
|
329
333
|
return result;
|
|
330
334
|
}
|
|
331
335
|
/**
|
|
332
|
-
* Returns the closest point
|
|
336
|
+
* Returns the closest point on the line to the given point.
|
|
333
337
|
* @param point
|
|
338
|
+
* @param clampToLine boolean (optional)
|
|
339
|
+
* @param target Vec2 (optional)
|
|
334
340
|
*/
|
|
335
|
-
|
|
336
|
-
const
|
|
337
|
-
|
|
338
|
-
const startEnd2 = startEnd.dot(startEnd);
|
|
339
|
-
const startEnd_startP = startEnd.dot(startP);
|
|
340
|
-
return startEnd_startP / startEnd2;
|
|
341
|
+
closestPointToPoint(point, clampToLine, target) {
|
|
342
|
+
const t = this.closestPointToPointParameter(point, clampToLine);
|
|
343
|
+
return this.delta(target || new Vec2_1.Vec2()).multiplyScalar(t).add(this.start);
|
|
341
344
|
}
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
* @param point
|
|
345
|
-
*/
|
|
346
|
-
closestPointOnInfiniteLine(point) {
|
|
347
|
-
const t = this.closestPointToPointParameterOnInfiniteLine(point);
|
|
348
|
-
return new Vec2_1.Vec2().subVectors(this.end, this.start).multiplyScalar(t).add(this.start);
|
|
345
|
+
delta(target) {
|
|
346
|
+
return target.subVectors(this.end, this.start);
|
|
349
347
|
}
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
if (
|
|
357
|
-
|
|
348
|
+
closestPointToPointParameter(point, clampToLine) {
|
|
349
|
+
_startP.subVectors(point, this.start);
|
|
350
|
+
_startEnd.subVectors(this.end, this.start);
|
|
351
|
+
const startEnd2 = _startEnd.dot(_startEnd);
|
|
352
|
+
const startEnd_startP = _startEnd.dot(_startP);
|
|
353
|
+
let t = startEnd_startP / startEnd2;
|
|
354
|
+
if (clampToLine) {
|
|
355
|
+
t = three_2.MathUtils.clamp(t, 0, 1);
|
|
358
356
|
}
|
|
359
|
-
return
|
|
357
|
+
return t;
|
|
360
358
|
}
|
|
361
359
|
/**
|
|
362
360
|
* Returns the distance between the **infinite** line and the point.
|
|
@@ -466,11 +464,11 @@ class Line2D {
|
|
|
466
464
|
return;
|
|
467
465
|
}
|
|
468
466
|
if (!this.isPointOnLineSection(lineToTrim.start)) {
|
|
469
|
-
const closest = this.
|
|
467
|
+
const closest = this.closestPointToPoint(lineToTrim.start, true);
|
|
470
468
|
lineToTrim.start.copy(closest);
|
|
471
469
|
}
|
|
472
470
|
if (!this.isPointOnLineSection(lineToTrim.end)) {
|
|
473
|
-
const closest = this.
|
|
471
|
+
const closest = this.closestPointToPoint(lineToTrim.end, true);
|
|
474
472
|
lineToTrim.end.copy(closest);
|
|
475
473
|
}
|
|
476
474
|
}
|
|
@@ -534,17 +532,21 @@ class Line2D {
|
|
|
534
532
|
return new Vec2_1.Vec2(x, y);
|
|
535
533
|
}
|
|
536
534
|
/**
|
|
537
|
-
* Check that the
|
|
535
|
+
* Check that the line section intersect and that they are in the specified angle to each other
|
|
538
536
|
* @param other Line
|
|
539
537
|
* @param expectedAngleInRads number
|
|
538
|
+
* @param angleTolerance number
|
|
539
|
+
* @param distanceTolerance number
|
|
540
540
|
*/
|
|
541
|
-
hasIntersectionWithAngle(other, expectedAngleInRads) {
|
|
542
|
-
const angle = this.direction.angle();
|
|
543
|
-
const otherAngle = other.direction.angle();
|
|
541
|
+
hasIntersectionWithAngle(other, expectedAngleInRads, angleTolerance = Number.EPSILON, distanceTolerance = Number.EPSILON) {
|
|
542
|
+
const angle = this.direction.angle() % MathConstants_1.TwoPI;
|
|
543
|
+
const otherAngle = other.direction.angle() % MathConstants_1.TwoPI;
|
|
544
544
|
const actualAngle = Math.abs(angle - otherAngle);
|
|
545
|
-
if (Math.abs(actualAngle - expectedAngleInRads)
|
|
545
|
+
if (Math.abs(actualAngle - expectedAngleInRads) <= angleTolerance) {
|
|
546
546
|
const intersection = this.intersect(other);
|
|
547
|
-
if (intersection &&
|
|
547
|
+
if (intersection &&
|
|
548
|
+
this.closestPointToPoint(intersection, true).distanceTo(intersection) <= distanceTolerance &&
|
|
549
|
+
other.closestPointToPoint(intersection, true).distanceTo(intersection) <= distanceTolerance) {
|
|
548
550
|
return intersection;
|
|
549
551
|
}
|
|
550
552
|
}
|
package/cjs/Vec2.js
CHANGED
|
@@ -16,6 +16,13 @@ class Vec2 extends three_1.Vector2 {
|
|
|
16
16
|
static fromPoint(point) {
|
|
17
17
|
return new Vec2(point?.x, point?.y);
|
|
18
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Creates a new Vec2[] array from arguments of {x, y} objects.
|
|
21
|
+
* @param points - The ...{x, y} instances.
|
|
22
|
+
*/
|
|
23
|
+
static fromPoints(...points) {
|
|
24
|
+
return points?.map(p => Vec2.fromPoint(p)) ?? [];
|
|
25
|
+
}
|
|
19
26
|
/**
|
|
20
27
|
* Moves this Vec2 instance towards the target Vec2 by the given amount.
|
|
21
28
|
* @param target - The target Vec2.
|
|
@@ -66,5 +73,19 @@ class Vec2 extends three_1.Vector2 {
|
|
|
66
73
|
const signed_angle = Math.atan2(this.y, this.x) - Math.atan2(0, 1);
|
|
67
74
|
return (0, normalizeAngleRadians_1.normalizeAngleRadians)(signed_angle);
|
|
68
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* check if the angle between the two vectors is close enough to 0 or 180 degrees (same or opposite direction) within the given tolerance
|
|
78
|
+
* @param other Vector2
|
|
79
|
+
* @param toleranceRadians number angle tolerance in radians
|
|
80
|
+
*/
|
|
81
|
+
parallelTo(other, toleranceRadians = 0) {
|
|
82
|
+
const v1 = this.clone().normalize(); // Normalize both vectors to remove magnitude influence
|
|
83
|
+
const v2 = other.clone().normalize();
|
|
84
|
+
const dotProduct = v1.dot(v2); // Calculate the dot product to find the cosine of the angle between the vectors
|
|
85
|
+
// Calculate the angle in radians
|
|
86
|
+
const angle = Math.acos(dotProduct);
|
|
87
|
+
// Check if the angle is within the tolerance of 0 or 180 degrees (Math.PI)
|
|
88
|
+
return Math.abs(angle) <= toleranceRadians || Math.abs(angle - Math.PI) <= toleranceRadians;
|
|
89
|
+
}
|
|
69
90
|
}
|
|
70
91
|
exports.Vec2 = Vec2;
|
package/cjs/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.normalizeAngleRadians = exports.normalizeAngleDegrees = exports.Rectangle = exports.BoundingBox = exports.Polygon = exports.Size2 = exports.Line3D = exports.Line2D = exports.Vec3 = exports.Vec2 = void 0;
|
|
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;
|
|
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");
|
|
@@ -21,3 +21,5 @@ var normalizeAngleDegrees_1 = require("./normalizeAngleDegrees");
|
|
|
21
21
|
Object.defineProperty(exports, "normalizeAngleDegrees", { enumerable: true, get: function () { return normalizeAngleDegrees_1.normalizeAngleDegrees; } });
|
|
22
22
|
var normalizeAngleRadians_1 = require("./normalizeAngleRadians");
|
|
23
23
|
Object.defineProperty(exports, "normalizeAngleRadians", { enumerable: true, get: function () { return normalizeAngleRadians_1.normalizeAngleRadians; } });
|
|
24
|
+
var MathConstants_1 = require("./MathConstants");
|
|
25
|
+
Object.defineProperty(exports, "TwoPI", { enumerable: true, get: function () { return MathConstants_1.TwoPI; } });
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.normalizeAngleDegrees = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Normalizes an angle in degrees to the range [0, 360].
|
|
6
|
+
* @param angle in degrees
|
|
7
|
+
*/
|
|
4
8
|
function normalizeAngleDegrees(angle) {
|
|
5
9
|
return ((angle % 360) + 360) % 360;
|
|
6
10
|
}
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.normalizeAngleRadians = void 0;
|
|
4
|
+
const MathConstants_1 = require("./MathConstants");
|
|
5
|
+
/**
|
|
6
|
+
* Normalize an angle in radians to the range of 0 to 2π.
|
|
7
|
+
* @param angle in radians
|
|
8
|
+
*/
|
|
4
9
|
function normalizeAngleRadians(angle) {
|
|
5
|
-
|
|
6
|
-
angle = angle % twoPi; // Use modulus to get the angle within the range of 0 to 2π
|
|
10
|
+
angle = angle % MathConstants_1.TwoPI; // Use modulus to get the angle within the range of 0 to 2π
|
|
7
11
|
if (angle < 0) { // Add 2π if the angle is negative
|
|
8
|
-
angle = angle +
|
|
12
|
+
angle = angle + MathConstants_1.TwoPI;
|
|
9
13
|
}
|
|
10
14
|
return angle;
|
|
11
15
|
}
|
|
@@ -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/151f214/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/151f214/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/151f214/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/151f214/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/151f214/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/151f214/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/151f214/src/BoundingBox.ts#L7)
|