@flighthq/geometry 0.1.0

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.
Files changed (125) hide show
  1. package/dist/aabb.d.ts +88 -0
  2. package/dist/aabb.d.ts.map +1 -0
  3. package/dist/aabb.js +230 -0
  4. package/dist/aabb.js.map +1 -0
  5. package/dist/boundingSphere.d.ts +62 -0
  6. package/dist/boundingSphere.d.ts.map +1 -0
  7. package/dist/boundingSphere.js +188 -0
  8. package/dist/boundingSphere.js.map +1 -0
  9. package/dist/capsule.d.ts +38 -0
  10. package/dist/capsule.d.ts.map +1 -0
  11. package/dist/capsule.js +215 -0
  12. package/dist/capsule.js.map +1 -0
  13. package/dist/frustum.d.ts +49 -0
  14. package/dist/frustum.d.ts.map +1 -0
  15. package/dist/frustum.js +149 -0
  16. package/dist/frustum.js.map +1 -0
  17. package/dist/index.d.ts +25 -0
  18. package/dist/index.d.ts.map +1 -0
  19. package/dist/index.js +25 -0
  20. package/dist/index.js.map +1 -0
  21. package/dist/matrix.d.ts +152 -0
  22. package/dist/matrix.d.ts.map +1 -0
  23. package/dist/matrix.js +488 -0
  24. package/dist/matrix.js.map +1 -0
  25. package/dist/matrix3.d.ts +63 -0
  26. package/dist/matrix3.d.ts.map +1 -0
  27. package/dist/matrix3.js +408 -0
  28. package/dist/matrix3.js.map +1 -0
  29. package/dist/matrix3Pool.d.ts +6 -0
  30. package/dist/matrix3Pool.d.ts.map +1 -0
  31. package/dist/matrix3Pool.js +26 -0
  32. package/dist/matrix3Pool.js.map +1 -0
  33. package/dist/matrix4.d.ts +238 -0
  34. package/dist/matrix4.d.ts.map +1 -0
  35. package/dist/matrix4.js +931 -0
  36. package/dist/matrix4.js.map +1 -0
  37. package/dist/matrix4Pool.d.ts +6 -0
  38. package/dist/matrix4Pool.d.ts.map +1 -0
  39. package/dist/matrix4Pool.js +26 -0
  40. package/dist/matrix4Pool.js.map +1 -0
  41. package/dist/matrixPool.d.ts +6 -0
  42. package/dist/matrixPool.d.ts.map +1 -0
  43. package/dist/matrixPool.js +26 -0
  44. package/dist/matrixPool.js.map +1 -0
  45. package/dist/obb.d.ts +44 -0
  46. package/dist/obb.d.ts.map +1 -0
  47. package/dist/obb.js +248 -0
  48. package/dist/obb.js.map +1 -0
  49. package/dist/plane.d.ts +66 -0
  50. package/dist/plane.d.ts.map +1 -0
  51. package/dist/plane.js +140 -0
  52. package/dist/plane.js.map +1 -0
  53. package/dist/quaternion.d.ts +128 -0
  54. package/dist/quaternion.d.ts.map +1 -0
  55. package/dist/quaternion.js +508 -0
  56. package/dist/quaternion.js.map +1 -0
  57. package/dist/quaternionPool.d.ts +6 -0
  58. package/dist/quaternionPool.d.ts.map +1 -0
  59. package/dist/quaternionPool.js +29 -0
  60. package/dist/quaternionPool.js.map +1 -0
  61. package/dist/ray3d.d.ts +69 -0
  62. package/dist/ray3d.d.ts.map +1 -0
  63. package/dist/ray3d.js +264 -0
  64. package/dist/ray3d.js.map +1 -0
  65. package/dist/rectangle.d.ts +56 -0
  66. package/dist/rectangle.d.ts.map +1 -0
  67. package/dist/rectangle.js +235 -0
  68. package/dist/rectangle.js.map +1 -0
  69. package/dist/rectanglePool.d.ts +6 -0
  70. package/dist/rectanglePool.d.ts.map +1 -0
  71. package/dist/rectanglePool.js +29 -0
  72. package/dist/rectanglePool.js.map +1 -0
  73. package/dist/typedarray.d.ts +4 -0
  74. package/dist/typedarray.d.ts.map +1 -0
  75. package/dist/typedarray.js +25 -0
  76. package/dist/typedarray.js.map +1 -0
  77. package/dist/vector2.d.ts +130 -0
  78. package/dist/vector2.d.ts.map +1 -0
  79. package/dist/vector2.js +250 -0
  80. package/dist/vector2.js.map +1 -0
  81. package/dist/vector2Pool.d.ts +6 -0
  82. package/dist/vector2Pool.d.ts.map +1 -0
  83. package/dist/vector2Pool.js +20 -0
  84. package/dist/vector2Pool.js.map +1 -0
  85. package/dist/vector3.d.ts +220 -0
  86. package/dist/vector3.d.ts.map +1 -0
  87. package/dist/vector3.js +380 -0
  88. package/dist/vector3.js.map +1 -0
  89. package/dist/vector3Pool.d.ts +6 -0
  90. package/dist/vector3Pool.d.ts.map +1 -0
  91. package/dist/vector3Pool.js +28 -0
  92. package/dist/vector3Pool.js.map +1 -0
  93. package/dist/vector4.d.ts +180 -0
  94. package/dist/vector4.d.ts.map +1 -0
  95. package/dist/vector4.js +333 -0
  96. package/dist/vector4.js.map +1 -0
  97. package/dist/vector4Pool.d.ts +6 -0
  98. package/dist/vector4Pool.d.ts.map +1 -0
  99. package/dist/vector4Pool.js +29 -0
  100. package/dist/vector4Pool.js.map +1 -0
  101. package/package.json +38 -0
  102. package/src/aabb.test.ts +341 -0
  103. package/src/boundingSphere.test.ts +247 -0
  104. package/src/capsule.test.ts +157 -0
  105. package/src/frustum.test.ts +160 -0
  106. package/src/matrix.test.ts +1111 -0
  107. package/src/matrix3.test.ts +752 -0
  108. package/src/matrix3Pool.test.ts +73 -0
  109. package/src/matrix4.test.ts +1627 -0
  110. package/src/matrix4Pool.test.ts +71 -0
  111. package/src/matrixPool.test.ts +69 -0
  112. package/src/obb.test.ts +183 -0
  113. package/src/plane.test.ts +225 -0
  114. package/src/quaternion.test.ts +531 -0
  115. package/src/quaternionPool.test.ts +64 -0
  116. package/src/ray3d.test.ts +297 -0
  117. package/src/rectangle.test.ts +982 -0
  118. package/src/rectanglePool.test.ts +71 -0
  119. package/src/typedarray.test.ts +118 -0
  120. package/src/vector2.test.ts +958 -0
  121. package/src/vector2Pool.test.ts +65 -0
  122. package/src/vector3.test.ts +749 -0
  123. package/src/vector3Pool.test.ts +68 -0
  124. package/src/vector4.test.ts +660 -0
  125. package/src/vector4Pool.test.ts +71 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typedarray.d.ts","sourceRoot":"","sources":["../src/typedarray.ts"],"names":[],"mappings":"AAAA,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,GAAG,YAAY,CAKvF;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,GAAG,UAAU,CAKjF;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,GAAG,WAAW,CAKpF"}
@@ -0,0 +1,25 @@
1
+ export function reserveFloat32Array(array, capacity) {
2
+ if (array.length >= capacity)
3
+ return array;
4
+ const out = new Float32Array(capacity);
5
+ if (array)
6
+ out.set(array);
7
+ return out;
8
+ }
9
+ export function reserveInt16Array(array, capacity) {
10
+ if (array.length >= capacity)
11
+ return array;
12
+ const out = new Int16Array(capacity);
13
+ if (array)
14
+ out.set(array);
15
+ return out;
16
+ }
17
+ export function reserveUint16Array(array, capacity) {
18
+ if (array.length >= capacity)
19
+ return array;
20
+ const out = new Uint16Array(capacity);
21
+ if (array)
22
+ out.set(array);
23
+ return out;
24
+ }
25
+ //# sourceMappingURL=typedarray.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typedarray.js","sourceRoot":"","sources":["../src/typedarray.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,mBAAmB,CAAC,KAAmB,EAAE,QAAgB;IACvE,IAAI,KAAK,CAAC,MAAM,IAAI,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC3C,MAAM,GAAG,GAAG,IAAI,YAAY,CAAC,QAAQ,CAAC,CAAC;IACvC,IAAI,KAAK;QAAE,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAC1B,OAAO,GAAG,CAAC;AACb,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,KAAiB,EAAE,QAAgB;IACnE,IAAI,KAAK,CAAC,MAAM,IAAI,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC3C,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,QAAQ,CAAC,CAAC;IACrC,IAAI,KAAK;QAAE,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAC1B,OAAO,GAAG,CAAC;AACb,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,KAAkB,EAAE,QAAgB;IACrE,IAAI,KAAK,CAAC,MAAM,IAAI,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC3C,MAAM,GAAG,GAAG,IAAI,WAAW,CAAC,QAAQ,CAAC,CAAC;IACtC,IAAI,KAAK;QAAE,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAC1B,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,130 @@
1
+ import type { Vector2, Vector2Like, Vector3Like } from '@flighthq/types';
2
+ export declare function addVector2(out: Vector2Like, a: Readonly<Vector2Like>, b: Readonly<Vector2Like>): void;
3
+ /**
4
+ * Clamps each component of a Vector2Like independently to [min, max].
5
+ *
6
+ * Safe when `out` aliases `value`, `min`, or `max`.
7
+ */
8
+ export declare function clampVector2(out: Vector2Like, value: Readonly<Vector2Like>, min: Readonly<Vector2Like>, max: Readonly<Vector2Like>): void;
9
+ export declare function cloneVector2(source: Readonly<Vector2Like>): Vector2;
10
+ export declare function copyVector2(out: Vector2Like, source: Readonly<Vector2Like>): void;
11
+ /**
12
+ * The Vector2Like object represents a location in a two-dimensional coordinate
13
+ * system, where _x_ represents the horizontal axis and _y_
14
+ * represents the vertical axis.
15
+ *
16
+ * Invariants:
17
+ *
18
+ * - `length = Math.sqrt(x ** 2 + y ** 2)`
19
+ * - `lengthSquared = x ** 2 + y ** 2`
20
+ *
21
+ * @see Rectangle
22
+ * @see Matrix
23
+ */
24
+ export declare function createVector2(x?: number, y?: number): Vector2;
25
+ export declare function createVector2FromPolar(length: number, angle: number): Vector2;
26
+ /**
27
+ * Component-wise division of two vectors (Hadamard division). Each component of
28
+ * `source` is divided by the corresponding component of `divisor`. Components with a
29
+ * zero divisor produce `0` in the output.
30
+ *
31
+ * Safe when `out` aliases `source` or `divisor`.
32
+ */
33
+ export declare function divideVector2(out: Vector2Like, source: Readonly<Vector2Like>, divisor: Readonly<Vector2Like>): void;
34
+ export declare function equalsVector2(a: Readonly<Vector2Like> | null | undefined, b: Readonly<Vector2Like> | null | undefined): boolean;
35
+ /**
36
+ * Returns the angle in radians between two vectors. The returned angle is the
37
+ * smallest radian the first Vector2Like object rotates until it aligns with the
38
+ * second Vector2Like object.
39
+ **/
40
+ export declare function getVector2AngleBetween(a: Readonly<Vector2Like>, b: Readonly<Vector2Like>): number;
41
+ export declare function getVector2Distance(a: Readonly<Vector2Like>, b: Readonly<Vector2Like>): number;
42
+ /**
43
+ * Returns the distance (squared) between two Vector2Like objects.
44
+ *
45
+ * This avoids Math.sqrt for better performance.
46
+ **/
47
+ export declare function getVector2DistanceSquared(a: Readonly<Vector2Like>, b: Readonly<Vector2Like>): number;
48
+ /**
49
+ * If the current Vector2Like object and the one specified as the parameter are unit
50
+ * vertices, this method returns the cosine of the angle between the two vertices.
51
+ * Unit vertices are vertices that point to the same direction but their length is
52
+ * one. They remove the length of the vector as a factor in the result. You can use
53
+ * the `normalize()` method to convert a vector to a unit vector.
54
+ **/
55
+ export declare function getVector2Dot(a: Readonly<Vector2Like>, b: Readonly<Vector2Like>): number;
56
+ export declare function getVector2Length(source: Readonly<Vector2Like>): number;
57
+ export declare function getVector2LengthSquared(source: Readonly<Vector2Like>): number;
58
+ /**
59
+ * Linear interpolation between points a and b
60
+ */
61
+ export declare function interpolateVector2(out: Vector2Like, a: Readonly<Vector2Like>, b: Readonly<Vector2Like>, t: number): void;
62
+ /**
63
+ * Writes the per-component maximum of two vectors.
64
+ *
65
+ * Safe when `out` aliases `a` or `b`.
66
+ */
67
+ export declare function maxVector2(out: Vector2Like, a: Readonly<Vector2Like>, b: Readonly<Vector2Like>): void;
68
+ /**
69
+ * Writes the per-component minimum of two vectors.
70
+ *
71
+ * Safe when `out` aliases `a` or `b`.
72
+ */
73
+ export declare function minVector2(out: Vector2Like, a: Readonly<Vector2Like>, b: Readonly<Vector2Like>): void;
74
+ /**
75
+ * Component-wise product of two vectors (Hadamard product).
76
+ *
77
+ * Safe when `out` aliases `a` or `b`.
78
+ */
79
+ export declare function multiplyVector2(out: Vector2Like, a: Readonly<Vector2Like>, b: Readonly<Vector2Like>): void;
80
+ /**
81
+ * Compares the elements of the current Vector2Like object with the elements of a
82
+ * specified Vector2Like object to determine whether they are nearly equal.
83
+ *
84
+ * The two Vector2Like objects are nearly equal if the value of all the elements of the two
85
+ * vertices are equal, or the result of the comparison is within the tolerance range.
86
+ **/
87
+ export declare function nearEqualsVector2(a: Readonly<Vector2Like>, b: Readonly<Vector2Like>, tolerance?: number): boolean;
88
+ /**
89
+ * Sets the current Vector2Like object to its inverse. The inverse object is also
90
+ * considered the opposite of the original object. The value of the `x` and `y`
91
+ * properties of the current Vector2Like object is changed to -x and -y.
92
+ **/
93
+ export declare function negateVector2(out: Vector2Like, source: Readonly<Vector2Like>): void;
94
+ /**
95
+ * Converts a Vector2Like object to a unit vector by dividing both elements
96
+ * (x, y) by the length of the vector.
97
+ *
98
+ * Returns the original length.
99
+ **/
100
+ export declare function normalizeVector2(out: Vector2Like, source: Readonly<Vector2Like>): number;
101
+ export declare function offsetVector2(out: Vector2Like, source: Readonly<Vector2Like>, dx: number, dy: number): void;
102
+ /**
103
+ * Reflects an incident vector about a unit normal. The result is the reflection of
104
+ * `incident` across the line whose normal is `normal`.
105
+ *
106
+ * Formula: out = incident - 2 * dot(incident, normal) * normal
107
+ *
108
+ * Safe when `out` aliases `incident` or `normal`.
109
+ */
110
+ export declare function reflectVector2(out: Vector2Like, incident: Readonly<Vector2Like>, normal: Readonly<Vector2Like>): void;
111
+ /**
112
+ * Scales the current Vector2Like object by a scalar, a magnitude. The Vector2Like object's
113
+ * x and y elements are multiplied by the provided scalar number.
114
+ **/
115
+ export declare function scaleVector2(out: Vector2Like, source: Readonly<Vector2Like>, scalar: number): void;
116
+ export declare function scaleVector2ToLength(out: Vector2Like, source: Readonly<Vector2Like>, length: number): void;
117
+ export declare function setVector2(out: Vector2Like, x: number, y: number): void;
118
+ export declare function setVector2FromFloat32Array(out: Vector2Like, offset: number, source: Readonly<Float32Array>): void;
119
+ export declare function setVector2FromPolar(out: Vector2Like, length: number, angle: number): void;
120
+ /**
121
+ * Copies the x and y components of a Vector3Like into a Vector2Like, dropping the z component.
122
+ *
123
+ * Safe when `out` aliases the same memory as `source`.
124
+ */
125
+ export declare function setVector2FromVector3(out: Vector2Like, source: Readonly<Vector3Like>): void;
126
+ export declare function subtractVector2(out: Vector2Like, source: Readonly<Vector2Like>, other: Readonly<Vector2Like>): void;
127
+ export declare function writeVector2ToFloat32Array(out: Float32Array, offset: number, source: Readonly<Vector2Like>): void;
128
+ export declare const VECTOR2_X_AXIS: Readonly<Vector2>;
129
+ export declare const VECTOR2_Y_AXIS: Readonly<Vector2>;
130
+ //# sourceMappingURL=vector2.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vector2.d.ts","sourceRoot":"","sources":["../src/vector2.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEzE,wBAAgB,UAAU,CAAC,GAAG,EAAE,WAAW,EAAE,CAAC,EAAE,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC,EAAE,QAAQ,CAAC,WAAW,CAAC,GAAG,IAAI,CAGrG;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAC1B,GAAG,EAAE,WAAW,EAChB,KAAK,EAAE,QAAQ,CAAC,WAAW,CAAC,EAC5B,GAAG,EAAE,QAAQ,CAAC,WAAW,CAAC,EAC1B,GAAG,EAAE,QAAQ,CAAC,WAAW,CAAC,GACzB,IAAI,CASN;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,QAAQ,CAAC,WAAW,CAAC,GAAG,OAAO,CAEnE;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,CAAC,WAAW,CAAC,GAAG,IAAI,CAGjF;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,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,MAAM,cAAc,EAAE,QAAQ,CAAC,OAAO,CAAuB,CAAC;AACrE,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,OAAO,CAAuB,CAAC"}
@@ -0,0 +1,250 @@
1
+ import { createEntity } from '@flighthq/entity';
2
+ export function addVector2(out, a, b) {
3
+ out.x = a.x + b.x;
4
+ out.y = a.y + b.y;
5
+ }
6
+ /**
7
+ * Clamps each component of a Vector2Like independently to [min, max].
8
+ *
9
+ * Safe when `out` aliases `value`, `min`, or `max`.
10
+ */
11
+ export function clampVector2(out, value, min, max) {
12
+ const vx = value.x, vy = value.y;
13
+ const minX = min.x, minY = min.y;
14
+ const maxX = max.x, maxY = max.y;
15
+ out.x = vx < minX ? minX : vx > maxX ? maxX : vx;
16
+ out.y = vy < minY ? minY : vy > maxY ? maxY : vy;
17
+ }
18
+ export function cloneVector2(source) {
19
+ return createVector2(source.x, source.y);
20
+ }
21
+ export function copyVector2(out, source) {
22
+ out.x = source.x;
23
+ out.y = source.y;
24
+ }
25
+ /**
26
+ * The Vector2Like object represents a location in a two-dimensional coordinate
27
+ * system, where _x_ represents the horizontal axis and _y_
28
+ * represents the vertical axis.
29
+ *
30
+ * Invariants:
31
+ *
32
+ * - `length = Math.sqrt(x ** 2 + y ** 2)`
33
+ * - `lengthSquared = x ** 2 + y ** 2`
34
+ *
35
+ * @see Rectangle
36
+ * @see Matrix
37
+ */
38
+ export function createVector2(x, y) {
39
+ return createEntity({ x: x ?? 0, y: y ?? 0 });
40
+ }
41
+ export function createVector2FromPolar(length, angle) {
42
+ const out = createVector2();
43
+ setVector2FromPolar(out, length, angle);
44
+ return out;
45
+ }
46
+ /**
47
+ * Component-wise division of two vectors (Hadamard division). Each component of
48
+ * `source` is divided by the corresponding component of `divisor`. Components with a
49
+ * zero divisor produce `0` in the output.
50
+ *
51
+ * Safe when `out` aliases `source` or `divisor`.
52
+ */
53
+ export function divideVector2(out, source, divisor) {
54
+ const sx = source.x, sy = source.y;
55
+ const dx = divisor.x, dy = divisor.y;
56
+ out.x = dx !== 0 ? sx / dx : 0;
57
+ out.y = dy !== 0 ? sy / dy : 0;
58
+ }
59
+ export function equalsVector2(a, b) {
60
+ if (!a || !b)
61
+ return false;
62
+ return a === b || (a.x === b.x && a.y === b.y);
63
+ }
64
+ /**
65
+ * Returns the angle in radians between two vectors. The returned angle is the
66
+ * smallest radian the first Vector2Like object rotates until it aligns with the
67
+ * second Vector2Like object.
68
+ **/
69
+ export function getVector2AngleBetween(a, b) {
70
+ const la = getVector2Length(a);
71
+ const lb = getVector2Length(b);
72
+ if (la === 0 || lb === 0)
73
+ return NaN; // undefined angle
74
+ const _dot = getVector2Dot(a, b) / (la * lb);
75
+ // clamp dot to [-1, 1] to avoid floating point errors
76
+ return Math.acos(Math.min(1, Math.max(-1, _dot)));
77
+ }
78
+ export function getVector2Distance(a, b) {
79
+ const dx = a.x - b.x;
80
+ const dy = a.y - b.y;
81
+ return Math.sqrt(dx * dx + dy * dy);
82
+ }
83
+ /**
84
+ * Returns the distance (squared) between two Vector2Like objects.
85
+ *
86
+ * This avoids Math.sqrt for better performance.
87
+ **/
88
+ export function getVector2DistanceSquared(a, b) {
89
+ const dx = a.x - b.x;
90
+ const dy = a.y - b.y;
91
+ return dx ** 2 + dy ** 2;
92
+ }
93
+ /**
94
+ * If the current Vector2Like object and the one specified as the parameter are unit
95
+ * vertices, this method returns the cosine of the angle between the two vertices.
96
+ * Unit vertices are vertices that point to the same direction but their length is
97
+ * one. They remove the length of the vector as a factor in the result. You can use
98
+ * the `normalize()` method to convert a vector to a unit vector.
99
+ **/
100
+ export function getVector2Dot(a, b) {
101
+ return a.x * b.x + a.y * b.y;
102
+ }
103
+ export function getVector2Length(source) {
104
+ return Math.sqrt(source.x ** 2 + source.y ** 2);
105
+ }
106
+ export function getVector2LengthSquared(source) {
107
+ return source.x ** 2 + source.y ** 2;
108
+ }
109
+ /**
110
+ * Linear interpolation between points a and b
111
+ */
112
+ export function interpolateVector2(out, a, b, t) {
113
+ out.x = a.x + t * (b.x - a.x);
114
+ out.y = a.y + t * (b.y - a.y);
115
+ }
116
+ /**
117
+ * Writes the per-component maximum of two vectors.
118
+ *
119
+ * Safe when `out` aliases `a` or `b`.
120
+ */
121
+ export function maxVector2(out, a, b) {
122
+ out.x = a.x > b.x ? a.x : b.x;
123
+ out.y = a.y > b.y ? a.y : b.y;
124
+ }
125
+ /**
126
+ * Writes the per-component minimum of two vectors.
127
+ *
128
+ * Safe when `out` aliases `a` or `b`.
129
+ */
130
+ export function minVector2(out, a, b) {
131
+ out.x = a.x < b.x ? a.x : b.x;
132
+ out.y = a.y < b.y ? a.y : b.y;
133
+ }
134
+ /**
135
+ * Component-wise product of two vectors (Hadamard product).
136
+ *
137
+ * Safe when `out` aliases `a` or `b`.
138
+ */
139
+ export function multiplyVector2(out, a, b) {
140
+ out.x = a.x * b.x;
141
+ out.y = a.y * b.y;
142
+ }
143
+ /**
144
+ * Compares the elements of the current Vector2Like object with the elements of a
145
+ * specified Vector2Like object to determine whether they are nearly equal.
146
+ *
147
+ * The two Vector2Like objects are nearly equal if the value of all the elements of the two
148
+ * vertices are equal, or the result of the comparison is within the tolerance range.
149
+ **/
150
+ export function nearEqualsVector2(a, b, tolerance = 1e-6) {
151
+ return Math.abs(a.x - b.x) < tolerance && Math.abs(a.y - b.y) < tolerance;
152
+ }
153
+ /**
154
+ * Sets the current Vector2Like object to its inverse. The inverse object is also
155
+ * considered the opposite of the original object. The value of the `x` and `y`
156
+ * properties of the current Vector2Like object is changed to -x and -y.
157
+ **/
158
+ export function negateVector2(out, source) {
159
+ out.x = source.x * -1;
160
+ out.y = source.y * -1;
161
+ }
162
+ /**
163
+ * Converts a Vector2Like object to a unit vector by dividing both elements
164
+ * (x, y) by the length of the vector.
165
+ *
166
+ * Returns the original length.
167
+ **/
168
+ export function normalizeVector2(out, source) {
169
+ const l = getVector2Length(source);
170
+ if (l !== 0) {
171
+ out.x = source.x / l;
172
+ out.y = source.y / l;
173
+ }
174
+ else {
175
+ out.x = 0;
176
+ out.y = 0;
177
+ }
178
+ return l;
179
+ }
180
+ export function offsetVector2(out, source, dx, dy) {
181
+ out.x = source.x + dx;
182
+ out.y = source.y + dy;
183
+ }
184
+ /**
185
+ * Reflects an incident vector about a unit normal. The result is the reflection of
186
+ * `incident` across the line whose normal is `normal`.
187
+ *
188
+ * Formula: out = incident - 2 * dot(incident, normal) * normal
189
+ *
190
+ * Safe when `out` aliases `incident` or `normal`.
191
+ */
192
+ export function reflectVector2(out, incident, normal) {
193
+ const ix = incident.x, iy = incident.y;
194
+ const nx = normal.x, ny = normal.y;
195
+ const twoDot = 2 * (ix * nx + iy * ny);
196
+ out.x = ix - twoDot * nx;
197
+ out.y = iy - twoDot * ny;
198
+ }
199
+ /**
200
+ * Scales the current Vector2Like object by a scalar, a magnitude. The Vector2Like object's
201
+ * x and y elements are multiplied by the provided scalar number.
202
+ **/
203
+ export function scaleVector2(out, source, scalar) {
204
+ out.x = source.x * scalar;
205
+ out.y = source.y * scalar;
206
+ }
207
+ export function scaleVector2ToLength(out, source, length) {
208
+ const currentLength = getVector2Length(source);
209
+ if (currentLength === 0) {
210
+ out.x = 0;
211
+ out.y = 0;
212
+ }
213
+ else {
214
+ const scale = length / currentLength;
215
+ out.x = source.x * scale;
216
+ out.y = source.y * scale;
217
+ }
218
+ }
219
+ export function setVector2(out, x, y) {
220
+ out.x = x;
221
+ out.y = y;
222
+ }
223
+ export function setVector2FromFloat32Array(out, offset, source) {
224
+ out.x = source[offset];
225
+ out.y = source[offset + 1];
226
+ }
227
+ export function setVector2FromPolar(out, length, angle) {
228
+ out.x = length * Math.cos(angle);
229
+ out.y = length * Math.sin(angle);
230
+ }
231
+ /**
232
+ * Copies the x and y components of a Vector3Like into a Vector2Like, dropping the z component.
233
+ *
234
+ * Safe when `out` aliases the same memory as `source`.
235
+ */
236
+ export function setVector2FromVector3(out, source) {
237
+ out.x = source.x;
238
+ out.y = source.y;
239
+ }
240
+ export function subtractVector2(out, source, other) {
241
+ out.x = source.x - other.x;
242
+ out.y = source.y - other.y;
243
+ }
244
+ export function writeVector2ToFloat32Array(out, offset, source) {
245
+ out[offset] = source.x;
246
+ out[offset + 1] = source.y;
247
+ }
248
+ export const VECTOR2_X_AXIS = createVector2(1, 0);
249
+ export const VECTOR2_Y_AXIS = createVector2(0, 1);
250
+ //# sourceMappingURL=vector2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vector2.js","sourceRoot":"","sources":["../src/vector2.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAGhD,MAAM,UAAU,UAAU,CAAC,GAAgB,EAAE,CAAwB,EAAE,CAAwB;IAC7F,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAClB,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AACpB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAC1B,GAAgB,EAChB,KAA4B,EAC5B,GAA0B,EAC1B,GAA0B;IAE1B,MAAM,EAAE,GAAG,KAAK,CAAC,CAAC,EAChB,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC;IACf,MAAM,IAAI,GAAG,GAAG,CAAC,CAAC,EAChB,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC;IACf,MAAM,IAAI,GAAG,GAAG,CAAC,CAAC,EAChB,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC;IACf,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;IACjD,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,IA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CAAC;IACjC,GAAG,CAAC,CAAC,GAAG,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACnC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,GAAgB,EAAE,MAA6B;IACnF,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC;IACjB,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC;AACnB,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,GAAgB,EAAE,MAA6B,EAAE,KAA4B;IAC3G,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;IAC3B,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;AAC7B,CAAC;AAED,MAAM,UAAU,0BAA0B,CAAC,GAAiB,EAAE,MAAc,EAAE,MAA6B;IACzG,GAAG,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC;IACvB,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC;AAC7B,CAAC;AAED,MAAM,CAAC,MAAM,cAAc,GAAsB,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACrE,MAAM,CAAC,MAAM,cAAc,GAAsB,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type { Vector2 } from '@flighthq/types';
2
+ export declare function acquireEmptyVector2(): Vector2;
3
+ export declare function acquireVector2(): Vector2;
4
+ export declare function clearVector2Pool(): void;
5
+ export declare function releaseVector2(v: Vector2): void;
6
+ //# sourceMappingURL=vector2Pool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vector2Pool.d.ts","sourceRoot":"","sources":["../src/vector2Pool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAI/C,wBAAgB,mBAAmB,IAAI,OAAO,CAK7C;AAED,wBAAgB,cAAc,IAAI,OAAO,CAExC;AAED,wBAAgB,gBAAgB,IAAI,IAAI,CAEvC;AAED,wBAAgB,cAAc,CAAC,CAAC,EAAE,OAAO,GAAG,IAAI,CAG/C"}
@@ -0,0 +1,20 @@
1
+ import { createVector2 } from './vector2';
2
+ export function acquireEmptyVector2() {
3
+ const v = acquireVector2();
4
+ v.x = 0;
5
+ v.y = 0;
6
+ return v;
7
+ }
8
+ export function acquireVector2() {
9
+ return pool.length > 0 ? pool.pop() : createVector2();
10
+ }
11
+ export function clearVector2Pool() {
12
+ pool.length = 0;
13
+ }
14
+ export function releaseVector2(v) {
15
+ if (!v)
16
+ return;
17
+ pool.push(v);
18
+ }
19
+ const pool = [];
20
+ //# sourceMappingURL=vector2Pool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vector2Pool.js","sourceRoot":"","sources":["../src/vector2Pool.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C,MAAM,UAAU,mBAAmB;IACjC,MAAM,CAAC,GAAG,cAAc,EAAE,CAAC;IAC3B,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACR,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACR,OAAO,CAAC,CAAC;AACX,CAAC;AAED,MAAM,UAAU,cAAc;IAC5B,OAAO,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAE,IAAI,CAAC,GAAG,EAAc,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC;AACrE,CAAC;AAED,MAAM,UAAU,gBAAgB;IAC9B,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,CAAU;IACvC,IAAI,CAAC,CAAC;QAAE,OAAO;IACf,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACf,CAAC;AAED,MAAM,IAAI,GAAc,EAAE,CAAC"}