@immugio/three-math-extensions 0.2.10 → 0.2.11
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 +13 -2
- package/cjs/Line2D.js +18 -0
- package/cjs/Vec2.js +11 -0
- package/cjs/directions.js +12 -0
- package/cjs/directions2d.js +10 -0
- package/cjs/index.js +5 -1
- package/esm/Line2D.js +18 -0
- package/esm/Vec2.js +11 -0
- package/esm/directions.js +9 -0
- package/esm/directions2d.js +7 -0
- package/esm/index.js +2 -0
- package/package.json +1 -1
- package/src/Line2D.ts +22 -0
- package/src/Vec2.ts +17 -4
- package/src/directions.ts +10 -0
- package/src/directions2d.ts +8 -0
- package/src/index.ts +3 -1
- package/types/Line2D.d.ts +8 -0
- package/types/Vec2.d.ts +6 -0
- package/types/directions.d.ts +9 -0
- package/types/directions2d.d.ts +7 -0
- package/types/index.d.ts +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -7,7 +7,7 @@ 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.11](https://github.com/Immugio/three-math-extensions/compare/16.15.10...0.2.11)
|
|
11
11
|
|
|
12
12
|
### Commits
|
|
13
13
|
|
|
@@ -17,21 +17,32 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
17
17
|
- Improve documentation [`d0fcb51`](https://github.com/Immugio/three-math-extensions/commit/d0fcb5132f127b4382ac5f7291575a061b8ec121)
|
|
18
18
|
- Vec3, Line3D - update documentation [`67d9c32`](https://github.com/Immugio/three-math-extensions/commit/67d9c328e08cc0a5599932d2f0529e97f31c9213)
|
|
19
19
|
- Add Polygon [`629cff8`](https://github.com/Immugio/three-math-extensions/commit/629cff8ecbb963477e8ea76d7f8b16d95435cbad)
|
|
20
|
+
- Line2D.isCloserToHorizontal [`b6f1429`](https://github.com/Immugio/three-math-extensions/commit/b6f14292d1d2765f7314c45e4c74be91280ac764)
|
|
21
|
+
- Add Vec2.angleTo and tests [`dcf1e53`](https://github.com/Immugio/three-math-extensions/commit/dcf1e531aecf8c115f323e14e5e44059e5c5d15c)
|
|
20
22
|
- Add Vec2.signedAngle [`863c8f2`](https://github.com/Immugio/three-math-extensions/commit/863c8f27f11288cbda535e21bb688206259269ed)
|
|
21
23
|
- Add Vec2.fromPoints to accept multiple points [`a261402`](https://github.com/Immugio/three-math-extensions/commit/a2614027cf5fb8263189b48f7e0bb9a23a552c15)
|
|
22
24
|
- Add Vec2.parallelTo [`989874d`](https://github.com/Immugio/three-math-extensions/commit/989874dcfe122d3ee84d8d56d79cb88e4e441736)
|
|
23
25
|
- Line2D.intersect - enable line segments intersection only [`1f1470e`](https://github.com/Immugio/three-math-extensions/commit/1f1470e1cf00118e643f5c44a135e0baf6b76d41)
|
|
26
|
+
- Add Line2D.projectOn [`4c52c5c`](https://github.com/Immugio/three-math-extensions/commit/4c52c5c2e649fbddb72ce3fca60cfd3f1319f72f)
|
|
24
27
|
- Polygon from bounding size [`eae6701`](https://github.com/Immugio/three-math-extensions/commit/eae67012f57f426f8b5259b765000447ce06d608)
|
|
25
28
|
- Line2D and Line3D to return this instead of specific type [`761ef6a`](https://github.com/Immugio/three-math-extensions/commit/761ef6a9d8cc4e35120b666576794e521aa3b991)
|
|
26
29
|
- Line2D.in3DSpace added [`a6ce0ec`](https://github.com/Immugio/three-math-extensions/commit/a6ce0ecb67f5c7b2a75fcc283c28af626153a4af)
|
|
27
30
|
- Line2D.hasIntersectionWithAngle to support optional tolerance [`b313bbe`](https://github.com/Immugio/three-math-extensions/commit/b313bbe118d435d53750deefd9a9e29ba6ec5c71)
|
|
28
31
|
- Line2D.hasIntersectionWithAngle - modulo all angles [`5409aa0`](https://github.com/Immugio/three-math-extensions/commit/5409aa0bc41510efa86d548e91837e44e5b6c343)
|
|
32
|
+
- Use Vec2 instead of Vector2 [`7e6a6ea`](https://github.com/Immugio/three-math-extensions/commit/7e6a6ea272f4441ef4bc78b3fdec23fc783fa1db)
|
|
29
33
|
- Update release instructions [`5b41a2e`](https://github.com/Immugio/three-math-extensions/commit/5b41a2ed7e15450dbb6088a7f7ed0031a013badc)
|
|
30
34
|
- Add Polygon to exports [`ed66775`](https://github.com/Immugio/three-math-extensions/commit/ed66775c33e961835b23843222b822cfd9c16b1d)
|
|
31
35
|
- Vec2.fromPoint and Vec3.fromPoint should accept null [`4b871af`](https://github.com/Immugio/three-math-extensions/commit/4b871af297bdcbe8584f1e2b99d602247b77687c)
|
|
36
|
+
- Documentation update [`d5c7a07`](https://github.com/Immugio/three-math-extensions/commit/d5c7a0765f6097f5d3a3be01967d4059f19682fb)
|
|
32
37
|
- Excluded files from build [`ec70614`](https://github.com/Immugio/three-math-extensions/commit/ec70614bc7df7a98f854c7a6693365118e04faf7)
|
|
33
38
|
|
|
34
|
-
## [16.15.10](https://github.com/Immugio/three-math-extensions/compare/0.2.
|
|
39
|
+
## [16.15.10](https://github.com/Immugio/three-math-extensions/compare/0.2.10...16.15.10) - 2023-01-02
|
|
40
|
+
|
|
41
|
+
## [0.2.10](https://github.com/Immugio/three-math-extensions/compare/0.2.9...0.2.10) - 2023-05-30
|
|
42
|
+
|
|
43
|
+
### Commits
|
|
44
|
+
|
|
45
|
+
- Add isPointInPolygon [`a59eb4b`](https://github.com/Immugio/three-math-extensions/commit/a59eb4be026f17a3106070ae626a0588cd4f4411)
|
|
35
46
|
|
|
36
47
|
## [0.2.9](https://github.com/Immugio/three-math-extensions/compare/0.2.8...0.2.9) - 2023-05-22
|
|
37
48
|
|
package/cjs/Line2D.js
CHANGED
|
@@ -6,6 +6,7 @@ const Vec2_1 = require("./Vec2");
|
|
|
6
6
|
const three_2 = require("three");
|
|
7
7
|
const MathConstants_1 = require("./MathConstants");
|
|
8
8
|
const Line3D_1 = require("./Line3D");
|
|
9
|
+
const directions2d_1 = require("./directions2d");
|
|
9
10
|
const _startP = /*@__PURE__*/ new Vec2_1.Vec2();
|
|
10
11
|
const _startEnd = /*@__PURE__*/ new Vec2_1.Vec2();
|
|
11
12
|
class Line2D {
|
|
@@ -316,6 +317,16 @@ class Line2D {
|
|
|
316
317
|
}
|
|
317
318
|
return result;
|
|
318
319
|
}
|
|
320
|
+
/**
|
|
321
|
+
* Returns a new line that is the projection of this line onto @other. Uses `closestPointToPoint` to find the projection.
|
|
322
|
+
* @param other
|
|
323
|
+
* @param clampToLine
|
|
324
|
+
*/
|
|
325
|
+
projectOn(other, clampToLine) {
|
|
326
|
+
const p1 = other.closestPointToPoint(this.start, clampToLine, new Vec2_1.Vec2());
|
|
327
|
+
const p2 = other.closestPointToPoint(this.end, clampToLine, new Vec2_1.Vec2());
|
|
328
|
+
return p1.distanceTo(this.start) < p2.distanceTo(this.start) ? new Line2D(p1, p2) : new Line2D(p2, p1);
|
|
329
|
+
}
|
|
319
330
|
/**
|
|
320
331
|
* Divides the Line3D into a number of segments of the given length.
|
|
321
332
|
* Clone the line, does not modify.
|
|
@@ -562,6 +573,13 @@ class Line2D {
|
|
|
562
573
|
}
|
|
563
574
|
return null;
|
|
564
575
|
}
|
|
576
|
+
get isCloserToHorizontal() {
|
|
577
|
+
const direction = this.direction;
|
|
578
|
+
return direction.angleTo(directions2d_1.directions2d.Right) < Math.PI / 4 || direction.angleTo(directions2d_1.directions2d.Left) < Math.PI / 4;
|
|
579
|
+
}
|
|
580
|
+
get isCloserToVertical() {
|
|
581
|
+
return !this.isCloserToHorizontal;
|
|
582
|
+
}
|
|
565
583
|
/**
|
|
566
584
|
* Project the line to 2D space. For start and end points Vec2.y becomes Vec3.z. and Vec3.y is provided as an argument.
|
|
567
585
|
* @param y - The y value of the new Vec3 instance.
|
package/cjs/Vec2.js
CHANGED
|
@@ -73,6 +73,17 @@ class Vec2 extends three_1.Vector2 {
|
|
|
73
73
|
const signed_angle = Math.atan2(this.y, this.x) - Math.atan2(0, 1);
|
|
74
74
|
return (0, normalizeAngleRadians_1.normalizeAngleRadians)(signed_angle);
|
|
75
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* Returns the angle between this vector and the given vector, the return value is between 0 and PI
|
|
78
|
+
* Both vectors are expected to be normalized
|
|
79
|
+
* @param other Vector2 normalized vector
|
|
80
|
+
*/
|
|
81
|
+
angleTo(other) {
|
|
82
|
+
// Calculate the dot product of the vectors
|
|
83
|
+
const dot = this.dot(other);
|
|
84
|
+
// Calculate the angle in radians between the two vectors
|
|
85
|
+
return Math.acos(Math.min(Math.max(dot, -1.0), 1.0));
|
|
86
|
+
}
|
|
76
87
|
/**
|
|
77
88
|
* 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
89
|
* @param other Vector2
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.directions = void 0;
|
|
4
|
+
const Vec3_1 = require("./Vec3");
|
|
5
|
+
exports.directions = {
|
|
6
|
+
North: new Vec3_1.Vec3(0, 0, -1),
|
|
7
|
+
South: new Vec3_1.Vec3(0, 0, 1),
|
|
8
|
+
East: new Vec3_1.Vec3(1, 0, 0),
|
|
9
|
+
West: new Vec3_1.Vec3(-1, 0, 0),
|
|
10
|
+
Up: new Vec3_1.Vec3(0, 1, 0),
|
|
11
|
+
Down: new Vec3_1.Vec3(0, -1, 0)
|
|
12
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.directions2d = void 0;
|
|
4
|
+
const Vec2_1 = require("./Vec2");
|
|
5
|
+
exports.directions2d = {
|
|
6
|
+
Up: new Vec2_1.Vec2(0, -1),
|
|
7
|
+
Down: new Vec2_1.Vec2(0, 1),
|
|
8
|
+
Left: new Vec2_1.Vec2(-1, 0),
|
|
9
|
+
Right: new Vec2_1.Vec2(1, 0)
|
|
10
|
+
};
|
package/cjs/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
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;
|
|
3
|
+
exports.directions2d = exports.directions = 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");
|
|
@@ -25,3 +25,7 @@ var MathConstants_1 = require("./MathConstants");
|
|
|
25
25
|
Object.defineProperty(exports, "TwoPI", { enumerable: true, get: function () { return MathConstants_1.TwoPI; } });
|
|
26
26
|
var isPointInPolygon_1 = require("./isPointInPolygon");
|
|
27
27
|
Object.defineProperty(exports, "isPointInPolygon", { enumerable: true, get: function () { return isPointInPolygon_1.isPointInPolygon; } });
|
|
28
|
+
var directions_1 = require("./directions");
|
|
29
|
+
Object.defineProperty(exports, "directions", { enumerable: true, get: function () { return directions_1.directions; } });
|
|
30
|
+
var directions2d_1 = require("./directions2d");
|
|
31
|
+
Object.defineProperty(exports, "directions2d", { enumerable: true, get: function () { return directions2d_1.directions2d; } });
|
package/esm/Line2D.js
CHANGED
|
@@ -3,6 +3,7 @@ import { Vec2 } from "./Vec2";
|
|
|
3
3
|
import { MathUtils } from "three";
|
|
4
4
|
import { TwoPI } from "./MathConstants";
|
|
5
5
|
import { Line3D } from "./Line3D";
|
|
6
|
+
import { directions2d } from "./directions2d";
|
|
6
7
|
const _startP = /*@__PURE__*/ new Vec2();
|
|
7
8
|
const _startEnd = /*@__PURE__*/ new Vec2();
|
|
8
9
|
export class Line2D {
|
|
@@ -313,6 +314,16 @@ export class Line2D {
|
|
|
313
314
|
}
|
|
314
315
|
return result;
|
|
315
316
|
}
|
|
317
|
+
/**
|
|
318
|
+
* Returns a new line that is the projection of this line onto @other. Uses `closestPointToPoint` to find the projection.
|
|
319
|
+
* @param other
|
|
320
|
+
* @param clampToLine
|
|
321
|
+
*/
|
|
322
|
+
projectOn(other, clampToLine) {
|
|
323
|
+
const p1 = other.closestPointToPoint(this.start, clampToLine, new Vec2());
|
|
324
|
+
const p2 = other.closestPointToPoint(this.end, clampToLine, new Vec2());
|
|
325
|
+
return p1.distanceTo(this.start) < p2.distanceTo(this.start) ? new Line2D(p1, p2) : new Line2D(p2, p1);
|
|
326
|
+
}
|
|
316
327
|
/**
|
|
317
328
|
* Divides the Line3D into a number of segments of the given length.
|
|
318
329
|
* Clone the line, does not modify.
|
|
@@ -559,6 +570,13 @@ export class Line2D {
|
|
|
559
570
|
}
|
|
560
571
|
return null;
|
|
561
572
|
}
|
|
573
|
+
get isCloserToHorizontal() {
|
|
574
|
+
const direction = this.direction;
|
|
575
|
+
return direction.angleTo(directions2d.Right) < Math.PI / 4 || direction.angleTo(directions2d.Left) < Math.PI / 4;
|
|
576
|
+
}
|
|
577
|
+
get isCloserToVertical() {
|
|
578
|
+
return !this.isCloserToHorizontal;
|
|
579
|
+
}
|
|
562
580
|
/**
|
|
563
581
|
* Project the line to 2D space. For start and end points Vec2.y becomes Vec3.z. and Vec3.y is provided as an argument.
|
|
564
582
|
* @param y - The y value of the new Vec3 instance.
|
package/esm/Vec2.js
CHANGED
|
@@ -70,6 +70,17 @@ export class Vec2 extends Vector2 {
|
|
|
70
70
|
const signed_angle = Math.atan2(this.y, this.x) - Math.atan2(0, 1);
|
|
71
71
|
return normalizeAngleRadians(signed_angle);
|
|
72
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* Returns the angle between this vector and the given vector, the return value is between 0 and PI
|
|
75
|
+
* Both vectors are expected to be normalized
|
|
76
|
+
* @param other Vector2 normalized vector
|
|
77
|
+
*/
|
|
78
|
+
angleTo(other) {
|
|
79
|
+
// Calculate the dot product of the vectors
|
|
80
|
+
const dot = this.dot(other);
|
|
81
|
+
// Calculate the angle in radians between the two vectors
|
|
82
|
+
return Math.acos(Math.min(Math.max(dot, -1.0), 1.0));
|
|
83
|
+
}
|
|
73
84
|
/**
|
|
74
85
|
* check if the angle between the two vectors is close enough to 0 or 180 degrees (same or opposite direction) within the given tolerance
|
|
75
86
|
* @param other Vector2
|
package/esm/index.js
CHANGED
|
@@ -10,3 +10,5 @@ export { normalizeAngleDegrees } from "./normalizeAngleDegrees";
|
|
|
10
10
|
export { normalizeAngleRadians } from "./normalizeAngleRadians";
|
|
11
11
|
export { TwoPI } from "./MathConstants";
|
|
12
12
|
export { isPointInPolygon } from "./isPointInPolygon";
|
|
13
|
+
export { directions } from "./directions";
|
|
14
|
+
export { directions2d } from "./directions2d";
|
package/package.json
CHANGED
package/src/Line2D.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { Vec2 } from "./Vec2";
|
|
|
4
4
|
import { MathUtils } from "three";
|
|
5
5
|
import { TwoPI } from "./MathConstants";
|
|
6
6
|
import { Line3D } from "./Line3D";
|
|
7
|
+
import {directions2d} from "./directions2d";
|
|
7
8
|
|
|
8
9
|
const _startP = /*@__PURE__*/ new Vec2();
|
|
9
10
|
const _startEnd = /*@__PURE__*/ new Vec2();
|
|
@@ -368,6 +369,18 @@ export class Line2D {
|
|
|
368
369
|
return result;
|
|
369
370
|
}
|
|
370
371
|
|
|
372
|
+
/**
|
|
373
|
+
* Returns a new line that is the projection of this line onto @other. Uses `closestPointToPoint` to find the projection.
|
|
374
|
+
* @param other
|
|
375
|
+
* @param clampToLine
|
|
376
|
+
*/
|
|
377
|
+
public projectOn(other: Line2D, clampToLine: boolean): Line2D {
|
|
378
|
+
const p1 = other.closestPointToPoint(this.start, clampToLine, new Vec2());
|
|
379
|
+
const p2 = other.closestPointToPoint(this.end, clampToLine, new Vec2());
|
|
380
|
+
|
|
381
|
+
return p1.distanceTo(this.start) < p2.distanceTo(this.start) ? new Line2D(p1, p2) : new Line2D(p2, p1);
|
|
382
|
+
}
|
|
383
|
+
|
|
371
384
|
/**
|
|
372
385
|
* Divides the Line3D into a number of segments of the given length.
|
|
373
386
|
* Clone the line, does not modify.
|
|
@@ -660,6 +673,15 @@ export class Line2D {
|
|
|
660
673
|
return null;
|
|
661
674
|
}
|
|
662
675
|
|
|
676
|
+
public get isCloserToHorizontal(): boolean {
|
|
677
|
+
const direction = this.direction;
|
|
678
|
+
return direction.angleTo(directions2d.Right) < Math.PI / 4 || direction.angleTo(directions2d.Left) < Math.PI / 4;
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
public get isCloserToVertical(): boolean {
|
|
682
|
+
return !this.isCloserToHorizontal;
|
|
683
|
+
}
|
|
684
|
+
|
|
663
685
|
/**
|
|
664
686
|
* Project the line to 2D space. For start and end points Vec2.y becomes Vec3.z. and Vec3.y is provided as an argument.
|
|
665
687
|
* @param y - The y value of the new Vec3 instance.
|
package/src/Vec2.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import {Vector2} from "three";
|
|
2
|
+
import {Vec3} from "./Vec3";
|
|
3
|
+
import {Point2} from "./Point2";
|
|
4
|
+
import {normalizeAngleRadians} from "./normalizeAngleRadians";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Vec2 represents a 2D vector. It extends `Vector2` from the `threejs` library.
|
|
@@ -81,6 +81,19 @@ export class Vec2 extends Vector2 {
|
|
|
81
81
|
return normalizeAngleRadians(signed_angle);
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
+
/**
|
|
85
|
+
* Returns the angle between this vector and the given vector, the return value is between 0 and PI
|
|
86
|
+
* Both vectors are expected to be normalized
|
|
87
|
+
* @param other Vector2 normalized vector
|
|
88
|
+
*/
|
|
89
|
+
public angleTo(other: Vector2): number {
|
|
90
|
+
// Calculate the dot product of the vectors
|
|
91
|
+
const dot = this.dot(other);
|
|
92
|
+
|
|
93
|
+
// Calculate the angle in radians between the two vectors
|
|
94
|
+
return Math.acos(Math.min(Math.max(dot, -1.0), 1.0));
|
|
95
|
+
}
|
|
96
|
+
|
|
84
97
|
/**
|
|
85
98
|
* check if the angle between the two vectors is close enough to 0 or 180 degrees (same or opposite direction) within the given tolerance
|
|
86
99
|
* @param other Vector2
|
package/src/index.ts
CHANGED
|
@@ -11,4 +11,6 @@ export { normalizeAngleRadians } from "./normalizeAngleRadians";
|
|
|
11
11
|
export { TwoPI } from "./MathConstants";
|
|
12
12
|
export { Point2 } from "./Point2";
|
|
13
13
|
export { Point3 } from "./Point3";
|
|
14
|
-
export { isPointInPolygon } from "./isPointInPolygon";
|
|
14
|
+
export { isPointInPolygon } from "./isPointInPolygon";
|
|
15
|
+
export { directions } from "./directions";
|
|
16
|
+
export { directions2d } from "./directions2d";
|
package/types/Line2D.d.ts
CHANGED
|
@@ -138,6 +138,12 @@ export declare class Line2D {
|
|
|
138
138
|
* @param lines
|
|
139
139
|
*/
|
|
140
140
|
static joinLines(lines: Line2D[]): Line2D[];
|
|
141
|
+
/**
|
|
142
|
+
* Returns a new line that is the projection of this line onto @other. Uses `closestPointToPoint` to find the projection.
|
|
143
|
+
* @param other
|
|
144
|
+
* @param clampToLine
|
|
145
|
+
*/
|
|
146
|
+
projectOn(other: Line2D, clampToLine: boolean): Line2D;
|
|
141
147
|
/**
|
|
142
148
|
* Divides the Line3D into a number of segments of the given length.
|
|
143
149
|
* Clone the line, does not modify.
|
|
@@ -212,6 +218,8 @@ export declare class Line2D {
|
|
|
212
218
|
* @param distanceTolerance number
|
|
213
219
|
*/
|
|
214
220
|
hasIntersectionWithAngle(other: Line2D, expectedAngleInRads: number, angleTolerance?: number, distanceTolerance?: number): Vec2;
|
|
221
|
+
get isCloserToHorizontal(): boolean;
|
|
222
|
+
get isCloserToVertical(): boolean;
|
|
215
223
|
/**
|
|
216
224
|
* Project the line to 2D space. For start and end points Vec2.y becomes Vec3.z. and Vec3.y is provided as an argument.
|
|
217
225
|
* @param y - The y value of the new Vec3 instance.
|
package/types/Vec2.d.ts
CHANGED
|
@@ -44,6 +44,12 @@ export declare class Vec2 extends Vector2 {
|
|
|
44
44
|
* Returns the angle between this vector and positive x-axis, the return value is between 0 and 2PI
|
|
45
45
|
*/
|
|
46
46
|
signedAngle(): number;
|
|
47
|
+
/**
|
|
48
|
+
* Returns the angle between this vector and the given vector, the return value is between 0 and PI
|
|
49
|
+
* Both vectors are expected to be normalized
|
|
50
|
+
* @param other Vector2 normalized vector
|
|
51
|
+
*/
|
|
52
|
+
angleTo(other: Vector2): number;
|
|
47
53
|
/**
|
|
48
54
|
* check if the angle between the two vectors is close enough to 0 or 180 degrees (same or opposite direction) within the given tolerance
|
|
49
55
|
* @param other Vector2
|
package/types/index.d.ts
CHANGED
|
@@ -12,3 +12,5 @@ export { TwoPI } from "./MathConstants";
|
|
|
12
12
|
export { Point2 } from "./Point2";
|
|
13
13
|
export { Point3 } from "./Point3";
|
|
14
14
|
export { isPointInPolygon } from "./isPointInPolygon";
|
|
15
|
+
export { directions } from "./directions";
|
|
16
|
+
export { directions2d } from "./directions2d";
|