@immugio/three-math-extensions 0.3.4 → 0.3.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 +23 -1
- package/cjs/Line2D.js +90 -13
- package/cjs/Polygon.js +3 -0
- package/docs/classes/BoundingBox.md +121 -121
- package/docs/classes/Line2D.md +1366 -1366
- package/docs/classes/Line3D.md +831 -831
- package/docs/classes/Polygon.md +297 -297
- package/docs/classes/Rectangle.md +291 -291
- package/docs/classes/Size2.md +55 -55
- package/docs/classes/Vec2.md +282 -282
- package/docs/classes/Vec3.md +338 -338
- package/docs/interfaces/Point2.md +30 -30
- package/docs/interfaces/Point3.md +41 -41
- package/docs/modules.md +209 -209
- package/eslint.config.mjs +111 -111
- package/esm/Line2D.js +90 -13
- package/esm/Polygon.js +3 -0
- package/package.json +62 -62
- package/src/BoundingBox.ts +13 -13
- package/src/Line2D.ts +951 -857
- package/src/Line3D.ts +586 -586
- package/src/MathConstants.ts +1 -1
- package/src/Point2.ts +3 -3
- package/src/Point3.ts +4 -4
- package/src/Polygon.ts +290 -286
- package/src/Rectangle.ts +92 -92
- package/src/Size2.ts +3 -3
- package/src/Vec2.ts +124 -124
- package/src/Vec3.ts +167 -167
- package/src/containsPoint.ts +65 -65
- package/src/directions.ts +9 -9
- package/src/directions2d.ts +7 -7
- package/src/ensurePolygonClockwise.ts +9 -9
- package/src/extendOrTrimPolylinesAtIntersections.ts +10 -10
- package/src/getPolygonArea.ts +21 -21
- package/src/index.ts +24 -24
- package/src/isContinuousClosedShape.ts +24 -24
- package/src/isPointInPolygon.ts +23 -23
- package/src/isPolygonClockwise.ts +15 -15
- package/src/normalizeAngleDegrees.ts +6 -6
- package/src/normalizeAngleRadians.ts +14 -14
- package/src/offsetPolyline.ts +26 -26
- package/src/polygonPerimeter.ts +13 -13
- package/src/sortLinesByConnections.ts +45 -45
- package/types/Line2D.d.ts +12 -5
package/docs/classes/Vec2.md
CHANGED
|
@@ -1,282 +1,282 @@
|
|
|
1
|
-
[@immugio/three-math-extensions](../../README.md) / [Exports](../modules.md) / Vec2
|
|
2
|
-
|
|
3
|
-
# Class: Vec2
|
|
4
|
-
|
|
5
|
-
Vec2 represents a 2D vector. It extends `Vector2` from the `threejs` library.
|
|
6
|
-
|
|
7
|
-
## Hierarchy
|
|
8
|
-
|
|
9
|
-
- `Vector2`
|
|
10
|
-
|
|
11
|
-
↳ **`Vec2`**
|
|
12
|
-
|
|
13
|
-
## Table of contents
|
|
14
|
-
|
|
15
|
-
### Constructors
|
|
16
|
-
|
|
17
|
-
- [constructor](Vec2.md#constructor)
|
|
18
|
-
|
|
19
|
-
### Methods
|
|
20
|
-
|
|
21
|
-
- [addX](Vec2.md#addx)
|
|
22
|
-
- [addY](Vec2.md#addy)
|
|
23
|
-
- [in3DSpace](Vec2.md#in3dspace)
|
|
24
|
-
- [isNear](Vec2.md#isnear)
|
|
25
|
-
- [moveTowards](Vec2.md#movetowards)
|
|
26
|
-
- [parallelTo](Vec2.md#parallelto)
|
|
27
|
-
- [roundIfCloseToInteger](Vec2.md#roundifclosetointeger)
|
|
28
|
-
- [signedAngle](Vec2.md#signedangle)
|
|
29
|
-
- [fromPoint](Vec2.md#frompoint)
|
|
30
|
-
- [fromPoints](Vec2.md#frompoints)
|
|
31
|
-
|
|
32
|
-
## Constructors
|
|
33
|
-
|
|
34
|
-
### constructor
|
|
35
|
-
|
|
36
|
-
• **new Vec2**(`x?`, `y?`): [`Vec2`](Vec2.md)
|
|
37
|
-
|
|
38
|
-
#### Parameters
|
|
39
|
-
|
|
40
|
-
| Name | Type |
|
|
41
|
-
| :------ | :------ |
|
|
42
|
-
| `x?` | `number` |
|
|
43
|
-
| `y?` | `number` |
|
|
44
|
-
|
|
45
|
-
#### Returns
|
|
46
|
-
|
|
47
|
-
[`Vec2`](Vec2.md)
|
|
48
|
-
|
|
49
|
-
#### Inherited from
|
|
50
|
-
|
|
51
|
-
Vector2.constructor
|
|
52
|
-
|
|
53
|
-
#### Defined in
|
|
54
|
-
|
|
55
|
-
node_modules/@types/three/src/math/Vector2.d.ts:140
|
|
56
|
-
|
|
57
|
-
## Methods
|
|
58
|
-
|
|
59
|
-
### addX
|
|
60
|
-
|
|
61
|
-
▸ **addX**(`x`): [`Vec2`](Vec2.md)
|
|
62
|
-
|
|
63
|
-
Adds x amount to this Vec3 instance and return this
|
|
64
|
-
|
|
65
|
-
#### Parameters
|
|
66
|
-
|
|
67
|
-
| Name | Type |
|
|
68
|
-
| :------ | :------ |
|
|
69
|
-
| `x` | `number` |
|
|
70
|
-
|
|
71
|
-
#### Returns
|
|
72
|
-
|
|
73
|
-
[`Vec2`](Vec2.md)
|
|
74
|
-
|
|
75
|
-
#### Defined in
|
|
76
|
-
|
|
77
|
-
[src/Vec2.ts:53](https://github.com/Immugio/three-math-extensions/blob/e397290/src/Vec2.ts#L53)
|
|
78
|
-
|
|
79
|
-
___
|
|
80
|
-
|
|
81
|
-
### addY
|
|
82
|
-
|
|
83
|
-
▸ **addY**(`y`): [`Vec2`](Vec2.md)
|
|
84
|
-
|
|
85
|
-
Adds y amount to this Vec3 instance and return this
|
|
86
|
-
|
|
87
|
-
#### Parameters
|
|
88
|
-
|
|
89
|
-
| Name | Type |
|
|
90
|
-
| :------ | :------ |
|
|
91
|
-
| `y` | `number` |
|
|
92
|
-
|
|
93
|
-
#### Returns
|
|
94
|
-
|
|
95
|
-
[`Vec2`](Vec2.md)
|
|
96
|
-
|
|
97
|
-
#### Defined in
|
|
98
|
-
|
|
99
|
-
[src/Vec2.ts:44](https://github.com/Immugio/three-math-extensions/blob/e397290/src/Vec2.ts#L44)
|
|
100
|
-
|
|
101
|
-
___
|
|
102
|
-
|
|
103
|
-
### in3DSpace
|
|
104
|
-
|
|
105
|
-
▸ **in3DSpace**(`y?`): [`Vec3`](Vec3.md)
|
|
106
|
-
|
|
107
|
-
Projects this Vec2 instance to a Vec3 instance in 3D space. Vec2.y becomes Vec3.z. and Vec3.y is provided as an argument.
|
|
108
|
-
|
|
109
|
-
#### Parameters
|
|
110
|
-
|
|
111
|
-
| Name | Type | Default value | Description |
|
|
112
|
-
| :------ | :------ | :------ | :------ |
|
|
113
|
-
| `y` | `number` | `0` | The y value of the new Vec3 instance. |
|
|
114
|
-
|
|
115
|
-
#### Returns
|
|
116
|
-
|
|
117
|
-
[`Vec3`](Vec3.md)
|
|
118
|
-
|
|
119
|
-
A new Vec3 instance.
|
|
120
|
-
|
|
121
|
-
#### Defined in
|
|
122
|
-
|
|
123
|
-
[src/Vec2.ts:78](https://github.com/Immugio/three-math-extensions/blob/e397290/src/Vec2.ts#L78)
|
|
124
|
-
|
|
125
|
-
___
|
|
126
|
-
|
|
127
|
-
### isNear
|
|
128
|
-
|
|
129
|
-
▸ **isNear**(`v`, `maxDistance?`): `boolean`
|
|
130
|
-
|
|
131
|
-
Determines if this Vec2 instance is near the target Vec2.
|
|
132
|
-
maxDistance is the maximum distance between the two vectors within which they are considered `near`.
|
|
133
|
-
|
|
134
|
-
#### Parameters
|
|
135
|
-
|
|
136
|
-
| Name | Type | Default value |
|
|
137
|
-
| :------ | :------ | :------ |
|
|
138
|
-
| `v` | `Vector2` | `undefined` |
|
|
139
|
-
| `maxDistance` | `number` | `undefined` |
|
|
140
|
-
|
|
141
|
-
#### Returns
|
|
142
|
-
|
|
143
|
-
`boolean`
|
|
144
|
-
|
|
145
|
-
#### Defined in
|
|
146
|
-
|
|
147
|
-
[src/Vec2.ts:86](https://github.com/Immugio/three-math-extensions/blob/e397290/src/Vec2.ts#L86)
|
|
148
|
-
|
|
149
|
-
___
|
|
150
|
-
|
|
151
|
-
### moveTowards
|
|
152
|
-
|
|
153
|
-
▸ **moveTowards**(`target`, `amount`): [`Vec2`](Vec2.md)
|
|
154
|
-
|
|
155
|
-
Moves this Vec2 instance towards the target Vec2 by the given amount.
|
|
156
|
-
|
|
157
|
-
#### Parameters
|
|
158
|
-
|
|
159
|
-
| Name | Type | Description |
|
|
160
|
-
| :------ | :------ | :------ |
|
|
161
|
-
| `target` | `Vector2` | The target Vec2. |
|
|
162
|
-
| `amount` | `number` | The distance to move. |
|
|
163
|
-
|
|
164
|
-
#### Returns
|
|
165
|
-
|
|
166
|
-
[`Vec2`](Vec2.md)
|
|
167
|
-
|
|
168
|
-
This Vec2 instance.
|
|
169
|
-
|
|
170
|
-
#### Defined in
|
|
171
|
-
|
|
172
|
-
[src/Vec2.ts:34](https://github.com/Immugio/three-math-extensions/blob/e397290/src/Vec2.ts#L34)
|
|
173
|
-
|
|
174
|
-
___
|
|
175
|
-
|
|
176
|
-
### parallelTo
|
|
177
|
-
|
|
178
|
-
▸ **parallelTo**(`other`, `toleranceRadians?`): `boolean`
|
|
179
|
-
|
|
180
|
-
check if the angle between the two vectors is close enough to 0 or 180 degrees (same or opposite direction) within the given tolerance
|
|
181
|
-
|
|
182
|
-
#### Parameters
|
|
183
|
-
|
|
184
|
-
| Name | Type | Default value | Description |
|
|
185
|
-
| :------ | :------ | :------ | :------ |
|
|
186
|
-
| `other` | `Vector2` | `undefined` | Vector2 |
|
|
187
|
-
| `toleranceRadians` | `number` | `0` | number angle tolerance in radians |
|
|
188
|
-
|
|
189
|
-
#### Returns
|
|
190
|
-
|
|
191
|
-
`boolean`
|
|
192
|
-
|
|
193
|
-
#### Defined in
|
|
194
|
-
|
|
195
|
-
[src/Vec2.ts:107](https://github.com/Immugio/three-math-extensions/blob/e397290/src/Vec2.ts#L107)
|
|
196
|
-
|
|
197
|
-
___
|
|
198
|
-
|
|
199
|
-
### roundIfCloseToInteger
|
|
200
|
-
|
|
201
|
-
▸ **roundIfCloseToInteger**(`max?`): [`Vec2`](Vec2.md)
|
|
202
|
-
|
|
203
|
-
Rounds the x and y values of this Vec2 instance if they are close to an integer value.
|
|
204
|
-
|
|
205
|
-
#### Parameters
|
|
206
|
-
|
|
207
|
-
| Name | Type | Default value | Description |
|
|
208
|
-
| :------ | :------ | :------ | :------ |
|
|
209
|
-
| `max` | `number` | `0.000000000001` | The maximum difference between the value and the nearest integer. |
|
|
210
|
-
|
|
211
|
-
#### Returns
|
|
212
|
-
|
|
213
|
-
[`Vec2`](Vec2.md)
|
|
214
|
-
|
|
215
|
-
This Vec2 instance.
|
|
216
|
-
|
|
217
|
-
#### Defined in
|
|
218
|
-
|
|
219
|
-
[src/Vec2.ts:63](https://github.com/Immugio/three-math-extensions/blob/e397290/src/Vec2.ts#L63)
|
|
220
|
-
|
|
221
|
-
___
|
|
222
|
-
|
|
223
|
-
### signedAngle
|
|
224
|
-
|
|
225
|
-
▸ **signedAngle**(): `number`
|
|
226
|
-
|
|
227
|
-
Returns the angle between this vector and positive x-axis, the return value is between 0 and 2PI
|
|
228
|
-
|
|
229
|
-
#### Returns
|
|
230
|
-
|
|
231
|
-
`number`
|
|
232
|
-
|
|
233
|
-
#### Defined in
|
|
234
|
-
|
|
235
|
-
[src/Vec2.ts:97](https://github.com/Immugio/three-math-extensions/blob/e397290/src/Vec2.ts#L97)
|
|
236
|
-
|
|
237
|
-
___
|
|
238
|
-
|
|
239
|
-
### fromPoint
|
|
240
|
-
|
|
241
|
-
▸ **fromPoint**(`point`): [`Vec2`](Vec2.md)
|
|
242
|
-
|
|
243
|
-
Creates a new Vec2 instance from an {x, y} object.
|
|
244
|
-
|
|
245
|
-
#### Parameters
|
|
246
|
-
|
|
247
|
-
| Name | Type | Description |
|
|
248
|
-
| :------ | :------ | :------ |
|
|
249
|
-
| `point` | [`Point2`](../interfaces/Point2.md) | The {x, y} instance. |
|
|
250
|
-
|
|
251
|
-
#### Returns
|
|
252
|
-
|
|
253
|
-
[`Vec2`](Vec2.md)
|
|
254
|
-
|
|
255
|
-
A new Vec2 instance.
|
|
256
|
-
|
|
257
|
-
#### Defined in
|
|
258
|
-
|
|
259
|
-
[src/Vec2.ts:16](https://github.com/Immugio/three-math-extensions/blob/e397290/src/Vec2.ts#L16)
|
|
260
|
-
|
|
261
|
-
___
|
|
262
|
-
|
|
263
|
-
### fromPoints
|
|
264
|
-
|
|
265
|
-
▸ **fromPoints**(`...points`): [`Vec2`](Vec2.md)[]
|
|
266
|
-
|
|
267
|
-
Creates a new Vec2[] array from arguments of {x, y} objects.
|
|
268
|
-
*
|
|
269
|
-
|
|
270
|
-
#### Parameters
|
|
271
|
-
|
|
272
|
-
| Name | Type | Description |
|
|
273
|
-
| :------ | :------ | :------ |
|
|
274
|
-
| `...points` | [`Point2`](../interfaces/Point2.md)[] | The ...{x, y} instances. |
|
|
275
|
-
|
|
276
|
-
#### Returns
|
|
277
|
-
|
|
278
|
-
[`Vec2`](Vec2.md)[]
|
|
279
|
-
|
|
280
|
-
#### Defined in
|
|
281
|
-
|
|
282
|
-
[src/Vec2.ts:24](https://github.com/Immugio/three-math-extensions/blob/e397290/src/Vec2.ts#L24)
|
|
1
|
+
[@immugio/three-math-extensions](../../README.md) / [Exports](../modules.md) / Vec2
|
|
2
|
+
|
|
3
|
+
# Class: Vec2
|
|
4
|
+
|
|
5
|
+
Vec2 represents a 2D vector. It extends `Vector2` from the `threejs` library.
|
|
6
|
+
|
|
7
|
+
## Hierarchy
|
|
8
|
+
|
|
9
|
+
- `Vector2`
|
|
10
|
+
|
|
11
|
+
↳ **`Vec2`**
|
|
12
|
+
|
|
13
|
+
## Table of contents
|
|
14
|
+
|
|
15
|
+
### Constructors
|
|
16
|
+
|
|
17
|
+
- [constructor](Vec2.md#constructor)
|
|
18
|
+
|
|
19
|
+
### Methods
|
|
20
|
+
|
|
21
|
+
- [addX](Vec2.md#addx)
|
|
22
|
+
- [addY](Vec2.md#addy)
|
|
23
|
+
- [in3DSpace](Vec2.md#in3dspace)
|
|
24
|
+
- [isNear](Vec2.md#isnear)
|
|
25
|
+
- [moveTowards](Vec2.md#movetowards)
|
|
26
|
+
- [parallelTo](Vec2.md#parallelto)
|
|
27
|
+
- [roundIfCloseToInteger](Vec2.md#roundifclosetointeger)
|
|
28
|
+
- [signedAngle](Vec2.md#signedangle)
|
|
29
|
+
- [fromPoint](Vec2.md#frompoint)
|
|
30
|
+
- [fromPoints](Vec2.md#frompoints)
|
|
31
|
+
|
|
32
|
+
## Constructors
|
|
33
|
+
|
|
34
|
+
### constructor
|
|
35
|
+
|
|
36
|
+
• **new Vec2**(`x?`, `y?`): [`Vec2`](Vec2.md)
|
|
37
|
+
|
|
38
|
+
#### Parameters
|
|
39
|
+
|
|
40
|
+
| Name | Type |
|
|
41
|
+
| :------ | :------ |
|
|
42
|
+
| `x?` | `number` |
|
|
43
|
+
| `y?` | `number` |
|
|
44
|
+
|
|
45
|
+
#### Returns
|
|
46
|
+
|
|
47
|
+
[`Vec2`](Vec2.md)
|
|
48
|
+
|
|
49
|
+
#### Inherited from
|
|
50
|
+
|
|
51
|
+
Vector2.constructor
|
|
52
|
+
|
|
53
|
+
#### Defined in
|
|
54
|
+
|
|
55
|
+
node_modules/@types/three/src/math/Vector2.d.ts:140
|
|
56
|
+
|
|
57
|
+
## Methods
|
|
58
|
+
|
|
59
|
+
### addX
|
|
60
|
+
|
|
61
|
+
▸ **addX**(`x`): [`Vec2`](Vec2.md)
|
|
62
|
+
|
|
63
|
+
Adds x amount to this Vec3 instance and return this
|
|
64
|
+
|
|
65
|
+
#### Parameters
|
|
66
|
+
|
|
67
|
+
| Name | Type |
|
|
68
|
+
| :------ | :------ |
|
|
69
|
+
| `x` | `number` |
|
|
70
|
+
|
|
71
|
+
#### Returns
|
|
72
|
+
|
|
73
|
+
[`Vec2`](Vec2.md)
|
|
74
|
+
|
|
75
|
+
#### Defined in
|
|
76
|
+
|
|
77
|
+
[src/Vec2.ts:53](https://github.com/Immugio/three-math-extensions/blob/e397290/src/Vec2.ts#L53)
|
|
78
|
+
|
|
79
|
+
___
|
|
80
|
+
|
|
81
|
+
### addY
|
|
82
|
+
|
|
83
|
+
▸ **addY**(`y`): [`Vec2`](Vec2.md)
|
|
84
|
+
|
|
85
|
+
Adds y amount to this Vec3 instance and return this
|
|
86
|
+
|
|
87
|
+
#### Parameters
|
|
88
|
+
|
|
89
|
+
| Name | Type |
|
|
90
|
+
| :------ | :------ |
|
|
91
|
+
| `y` | `number` |
|
|
92
|
+
|
|
93
|
+
#### Returns
|
|
94
|
+
|
|
95
|
+
[`Vec2`](Vec2.md)
|
|
96
|
+
|
|
97
|
+
#### Defined in
|
|
98
|
+
|
|
99
|
+
[src/Vec2.ts:44](https://github.com/Immugio/three-math-extensions/blob/e397290/src/Vec2.ts#L44)
|
|
100
|
+
|
|
101
|
+
___
|
|
102
|
+
|
|
103
|
+
### in3DSpace
|
|
104
|
+
|
|
105
|
+
▸ **in3DSpace**(`y?`): [`Vec3`](Vec3.md)
|
|
106
|
+
|
|
107
|
+
Projects this Vec2 instance to a Vec3 instance in 3D space. Vec2.y becomes Vec3.z. and Vec3.y is provided as an argument.
|
|
108
|
+
|
|
109
|
+
#### Parameters
|
|
110
|
+
|
|
111
|
+
| Name | Type | Default value | Description |
|
|
112
|
+
| :------ | :------ | :------ | :------ |
|
|
113
|
+
| `y` | `number` | `0` | The y value of the new Vec3 instance. |
|
|
114
|
+
|
|
115
|
+
#### Returns
|
|
116
|
+
|
|
117
|
+
[`Vec3`](Vec3.md)
|
|
118
|
+
|
|
119
|
+
A new Vec3 instance.
|
|
120
|
+
|
|
121
|
+
#### Defined in
|
|
122
|
+
|
|
123
|
+
[src/Vec2.ts:78](https://github.com/Immugio/three-math-extensions/blob/e397290/src/Vec2.ts#L78)
|
|
124
|
+
|
|
125
|
+
___
|
|
126
|
+
|
|
127
|
+
### isNear
|
|
128
|
+
|
|
129
|
+
▸ **isNear**(`v`, `maxDistance?`): `boolean`
|
|
130
|
+
|
|
131
|
+
Determines if this Vec2 instance is near the target Vec2.
|
|
132
|
+
maxDistance is the maximum distance between the two vectors within which they are considered `near`.
|
|
133
|
+
|
|
134
|
+
#### Parameters
|
|
135
|
+
|
|
136
|
+
| Name | Type | Default value |
|
|
137
|
+
| :------ | :------ | :------ |
|
|
138
|
+
| `v` | `Vector2` | `undefined` |
|
|
139
|
+
| `maxDistance` | `number` | `undefined` |
|
|
140
|
+
|
|
141
|
+
#### Returns
|
|
142
|
+
|
|
143
|
+
`boolean`
|
|
144
|
+
|
|
145
|
+
#### Defined in
|
|
146
|
+
|
|
147
|
+
[src/Vec2.ts:86](https://github.com/Immugio/three-math-extensions/blob/e397290/src/Vec2.ts#L86)
|
|
148
|
+
|
|
149
|
+
___
|
|
150
|
+
|
|
151
|
+
### moveTowards
|
|
152
|
+
|
|
153
|
+
▸ **moveTowards**(`target`, `amount`): [`Vec2`](Vec2.md)
|
|
154
|
+
|
|
155
|
+
Moves this Vec2 instance towards the target Vec2 by the given amount.
|
|
156
|
+
|
|
157
|
+
#### Parameters
|
|
158
|
+
|
|
159
|
+
| Name | Type | Description |
|
|
160
|
+
| :------ | :------ | :------ |
|
|
161
|
+
| `target` | `Vector2` | The target Vec2. |
|
|
162
|
+
| `amount` | `number` | The distance to move. |
|
|
163
|
+
|
|
164
|
+
#### Returns
|
|
165
|
+
|
|
166
|
+
[`Vec2`](Vec2.md)
|
|
167
|
+
|
|
168
|
+
This Vec2 instance.
|
|
169
|
+
|
|
170
|
+
#### Defined in
|
|
171
|
+
|
|
172
|
+
[src/Vec2.ts:34](https://github.com/Immugio/three-math-extensions/blob/e397290/src/Vec2.ts#L34)
|
|
173
|
+
|
|
174
|
+
___
|
|
175
|
+
|
|
176
|
+
### parallelTo
|
|
177
|
+
|
|
178
|
+
▸ **parallelTo**(`other`, `toleranceRadians?`): `boolean`
|
|
179
|
+
|
|
180
|
+
check if the angle between the two vectors is close enough to 0 or 180 degrees (same or opposite direction) within the given tolerance
|
|
181
|
+
|
|
182
|
+
#### Parameters
|
|
183
|
+
|
|
184
|
+
| Name | Type | Default value | Description |
|
|
185
|
+
| :------ | :------ | :------ | :------ |
|
|
186
|
+
| `other` | `Vector2` | `undefined` | Vector2 |
|
|
187
|
+
| `toleranceRadians` | `number` | `0` | number angle tolerance in radians |
|
|
188
|
+
|
|
189
|
+
#### Returns
|
|
190
|
+
|
|
191
|
+
`boolean`
|
|
192
|
+
|
|
193
|
+
#### Defined in
|
|
194
|
+
|
|
195
|
+
[src/Vec2.ts:107](https://github.com/Immugio/three-math-extensions/blob/e397290/src/Vec2.ts#L107)
|
|
196
|
+
|
|
197
|
+
___
|
|
198
|
+
|
|
199
|
+
### roundIfCloseToInteger
|
|
200
|
+
|
|
201
|
+
▸ **roundIfCloseToInteger**(`max?`): [`Vec2`](Vec2.md)
|
|
202
|
+
|
|
203
|
+
Rounds the x and y values of this Vec2 instance if they are close to an integer value.
|
|
204
|
+
|
|
205
|
+
#### Parameters
|
|
206
|
+
|
|
207
|
+
| Name | Type | Default value | Description |
|
|
208
|
+
| :------ | :------ | :------ | :------ |
|
|
209
|
+
| `max` | `number` | `0.000000000001` | The maximum difference between the value and the nearest integer. |
|
|
210
|
+
|
|
211
|
+
#### Returns
|
|
212
|
+
|
|
213
|
+
[`Vec2`](Vec2.md)
|
|
214
|
+
|
|
215
|
+
This Vec2 instance.
|
|
216
|
+
|
|
217
|
+
#### Defined in
|
|
218
|
+
|
|
219
|
+
[src/Vec2.ts:63](https://github.com/Immugio/three-math-extensions/blob/e397290/src/Vec2.ts#L63)
|
|
220
|
+
|
|
221
|
+
___
|
|
222
|
+
|
|
223
|
+
### signedAngle
|
|
224
|
+
|
|
225
|
+
▸ **signedAngle**(): `number`
|
|
226
|
+
|
|
227
|
+
Returns the angle between this vector and positive x-axis, the return value is between 0 and 2PI
|
|
228
|
+
|
|
229
|
+
#### Returns
|
|
230
|
+
|
|
231
|
+
`number`
|
|
232
|
+
|
|
233
|
+
#### Defined in
|
|
234
|
+
|
|
235
|
+
[src/Vec2.ts:97](https://github.com/Immugio/three-math-extensions/blob/e397290/src/Vec2.ts#L97)
|
|
236
|
+
|
|
237
|
+
___
|
|
238
|
+
|
|
239
|
+
### fromPoint
|
|
240
|
+
|
|
241
|
+
▸ **fromPoint**(`point`): [`Vec2`](Vec2.md)
|
|
242
|
+
|
|
243
|
+
Creates a new Vec2 instance from an {x, y} object.
|
|
244
|
+
|
|
245
|
+
#### Parameters
|
|
246
|
+
|
|
247
|
+
| Name | Type | Description |
|
|
248
|
+
| :------ | :------ | :------ |
|
|
249
|
+
| `point` | [`Point2`](../interfaces/Point2.md) | The {x, y} instance. |
|
|
250
|
+
|
|
251
|
+
#### Returns
|
|
252
|
+
|
|
253
|
+
[`Vec2`](Vec2.md)
|
|
254
|
+
|
|
255
|
+
A new Vec2 instance.
|
|
256
|
+
|
|
257
|
+
#### Defined in
|
|
258
|
+
|
|
259
|
+
[src/Vec2.ts:16](https://github.com/Immugio/three-math-extensions/blob/e397290/src/Vec2.ts#L16)
|
|
260
|
+
|
|
261
|
+
___
|
|
262
|
+
|
|
263
|
+
### fromPoints
|
|
264
|
+
|
|
265
|
+
▸ **fromPoints**(`...points`): [`Vec2`](Vec2.md)[]
|
|
266
|
+
|
|
267
|
+
Creates a new Vec2[] array from arguments of {x, y} objects.
|
|
268
|
+
*
|
|
269
|
+
|
|
270
|
+
#### Parameters
|
|
271
|
+
|
|
272
|
+
| Name | Type | Description |
|
|
273
|
+
| :------ | :------ | :------ |
|
|
274
|
+
| `...points` | [`Point2`](../interfaces/Point2.md)[] | The ...{x, y} instances. |
|
|
275
|
+
|
|
276
|
+
#### Returns
|
|
277
|
+
|
|
278
|
+
[`Vec2`](Vec2.md)[]
|
|
279
|
+
|
|
280
|
+
#### Defined in
|
|
281
|
+
|
|
282
|
+
[src/Vec2.ts:24](https://github.com/Immugio/three-math-extensions/blob/e397290/src/Vec2.ts#L24)
|