@ac-kit/math-linear 0.2.0 → 0.3.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.
- package/CHANGELOG.md +268 -0
- package/README.md +229 -16
- package/dist/_brand.d.ts +14 -0
- package/dist/_brand.d.ts.map +1 -0
- package/dist/_brand.js +2 -0
- package/dist/_brand.js.map +1 -0
- package/dist/_invert.d.ts +19 -0
- package/dist/_invert.d.ts.map +1 -0
- package/dist/_invert.js +48 -0
- package/dist/_invert.js.map +1 -0
- package/dist/_slerp.d.ts +15 -0
- package/dist/_slerp.d.ts.map +1 -1
- package/dist/_slerp.js +47 -0
- package/dist/_slerp.js.map +1 -1
- package/dist/_strided-range.d.ts +23 -0
- package/dist/_strided-range.d.ts.map +1 -0
- package/dist/_strided-range.js +75 -0
- package/dist/_strided-range.js.map +1 -0
- package/dist/_trs.d.ts +38 -0
- package/dist/_trs.d.ts.map +1 -0
- package/dist/_trs.js +132 -0
- package/dist/_trs.js.map +1 -0
- package/dist/affine2-array.d.ts +53 -0
- package/dist/affine2-array.d.ts.map +1 -0
- package/dist/affine2-array.js +107 -0
- package/dist/affine2-array.js.map +1 -0
- package/dist/affine2-componentwise.d.ts +28 -0
- package/dist/affine2-componentwise.d.ts.map +1 -0
- package/dist/affine2-componentwise.js +66 -0
- package/dist/affine2-componentwise.js.map +1 -0
- package/dist/affine2.d.ts +144 -0
- package/dist/affine2.d.ts.map +1 -0
- package/dist/affine2.js +375 -0
- package/dist/affine2.js.map +1 -0
- package/dist/affine3-array.d.ts +53 -0
- package/dist/affine3-array.d.ts.map +1 -0
- package/dist/affine3-array.js +137 -0
- package/dist/affine3-array.js.map +1 -0
- package/dist/affine3-componentwise.d.ts +32 -0
- package/dist/affine3-componentwise.d.ts.map +1 -0
- package/dist/affine3-componentwise.js +100 -0
- package/dist/affine3-componentwise.js.map +1 -0
- package/dist/affine3.d.ts +192 -0
- package/dist/affine3.d.ts.map +1 -0
- package/dist/affine3.js +718 -0
- package/dist/affine3.js.map +1 -0
- package/dist/checked/index.d.ts +35 -0
- package/dist/checked/index.d.ts.map +1 -0
- package/dist/checked/index.js +58 -0
- package/dist/checked/index.js.map +1 -0
- package/dist/euler.d.ts +65 -0
- package/dist/euler.d.ts.map +1 -0
- package/dist/euler.js +217 -0
- package/dist/euler.js.map +1 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -1
- package/dist/kl-activations.d.ts.map +1 -1
- package/dist/kl-activations.js +4 -3
- package/dist/kl-activations.js.map +1 -1
- package/dist/mat2x2-array.d.ts +36 -0
- package/dist/mat2x2-array.d.ts.map +1 -0
- package/dist/mat2x2-array.js +71 -0
- package/dist/mat2x2-array.js.map +1 -0
- package/dist/mat2x2-componentwise.d.ts +86 -0
- package/dist/mat2x2-componentwise.d.ts.map +1 -0
- package/dist/mat2x2-componentwise.js +199 -0
- package/dist/mat2x2-componentwise.js.map +1 -0
- package/dist/mat2x2.d.ts +67 -25
- package/dist/mat2x2.d.ts.map +1 -1
- package/dist/mat2x2.js +150 -94
- package/dist/mat2x2.js.map +1 -1
- package/dist/mat3x3-array.d.ts +36 -0
- package/dist/mat3x3-array.d.ts.map +1 -0
- package/dist/mat3x3-array.js +91 -0
- package/dist/mat3x3-array.js.map +1 -0
- package/dist/mat3x3-componentwise.d.ts +86 -0
- package/dist/mat3x3-componentwise.d.ts.map +1 -0
- package/dist/mat3x3-componentwise.js +299 -0
- package/dist/mat3x3-componentwise.js.map +1 -0
- package/dist/mat3x3.d.ts +131 -48
- package/dist/mat3x3.d.ts.map +1 -1
- package/dist/mat3x3.js +434 -193
- package/dist/mat3x3.js.map +1 -1
- package/dist/mat4x4-array.d.ts +46 -0
- package/dist/mat4x4-array.d.ts.map +1 -0
- package/dist/mat4x4-array.js +133 -0
- package/dist/mat4x4-array.js.map +1 -0
- package/dist/mat4x4-componentwise.d.ts +87 -0
- package/dist/mat4x4-componentwise.d.ts.map +1 -0
- package/dist/mat4x4-componentwise.js +434 -0
- package/dist/mat4x4-componentwise.js.map +1 -0
- package/dist/mat4x4.d.ts +195 -67
- package/dist/mat4x4.d.ts.map +1 -1
- package/dist/mat4x4.js +849 -335
- package/dist/mat4x4.js.map +1 -1
- package/dist/projection.d.ts +98 -0
- package/dist/projection.d.ts.map +1 -0
- package/dist/projection.js +369 -0
- package/dist/projection.js.map +1 -0
- package/dist/quaternion-array.d.ts +47 -0
- package/dist/quaternion-array.d.ts.map +1 -0
- package/dist/quaternion-array.js +86 -0
- package/dist/quaternion-array.js.map +1 -0
- package/dist/quaternion.d.ts +104 -22
- package/dist/quaternion.d.ts.map +1 -1
- package/dist/quaternion.js +294 -181
- package/dist/quaternion.js.map +1 -1
- package/dist/transform.d.ts +220 -0
- package/dist/transform.d.ts.map +1 -0
- package/dist/transform.js +412 -0
- package/dist/transform.js.map +1 -0
- package/dist/tridiagonal.d.ts +52 -0
- package/dist/tridiagonal.d.ts.map +1 -0
- package/dist/tridiagonal.js +90 -0
- package/dist/tridiagonal.js.map +1 -0
- package/dist/upload.d.ts +55 -0
- package/dist/upload.d.ts.map +1 -0
- package/dist/upload.js +129 -0
- package/dist/upload.js.map +1 -0
- package/dist/vec2-array-componentwise.d.ts +189 -0
- package/dist/vec2-array-componentwise.d.ts.map +1 -0
- package/dist/vec2-array-componentwise.js +424 -0
- package/dist/vec2-array-componentwise.js.map +1 -0
- package/dist/vec2-array.d.ts +53 -0
- package/dist/vec2-array.d.ts.map +1 -0
- package/dist/vec2-array.js +123 -0
- package/dist/vec2-array.js.map +1 -0
- package/dist/vec2-componentwise.d.ts +311 -0
- package/dist/vec2-componentwise.d.ts.map +1 -0
- package/dist/vec2-componentwise.js +542 -0
- package/dist/vec2-componentwise.js.map +1 -0
- package/dist/vec2.d.ts +97 -82
- package/dist/vec2.d.ts.map +1 -1
- package/dist/vec2.js +121 -216
- package/dist/vec2.js.map +1 -1
- package/dist/vec3-array-componentwise.d.ts +189 -0
- package/dist/vec3-array-componentwise.d.ts.map +1 -0
- package/dist/vec3-array-componentwise.js +458 -0
- package/dist/vec3-array-componentwise.js.map +1 -0
- package/dist/vec3-array.d.ts +102 -0
- package/dist/vec3-array.d.ts.map +1 -0
- package/dist/vec3-array.js +299 -0
- package/dist/vec3-array.js.map +1 -0
- package/dist/vec3-componentwise.d.ts +310 -0
- package/dist/vec3-componentwise.d.ts.map +1 -0
- package/dist/vec3-componentwise.js +594 -0
- package/dist/vec3-componentwise.js.map +1 -0
- package/dist/vec3.d.ts +177 -87
- package/dist/vec3.d.ts.map +1 -1
- package/dist/vec3.js +366 -273
- package/dist/vec3.js.map +1 -1
- package/dist/vec4-array-componentwise.d.ts +155 -0
- package/dist/vec4-array-componentwise.d.ts.map +1 -0
- package/dist/vec4-array-componentwise.js +401 -0
- package/dist/vec4-array-componentwise.js.map +1 -0
- package/dist/vec4-array.d.ts +12 -0
- package/dist/vec4-array.d.ts.map +1 -0
- package/dist/vec4-array.js +43 -0
- package/dist/vec4-array.js.map +1 -0
- package/dist/vec4-componentwise.d.ts +299 -0
- package/dist/vec4-componentwise.d.ts.map +1 -0
- package/dist/vec4-componentwise.js +637 -0
- package/dist/vec4-componentwise.js.map +1 -0
- package/dist/vec4.d.ts +57 -53
- package/dist/vec4.d.ts.map +1 -1
- package/dist/vec4.js +94 -246
- package/dist/vec4.js.map +1 -1
- package/dist/view-basis.d.ts +15 -0
- package/dist/view-basis.d.ts.map +1 -0
- package/dist/view-basis.js +29 -0
- package/dist/view-basis.js.map +1 -0
- package/dist/viewport.d.ts +114 -0
- package/dist/viewport.d.ts.map +1 -0
- package/dist/viewport.js +250 -0
- package/dist/viewport.js.map +1 -0
- package/package.json +18 -9
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
import { type ComparatorResult, type IsCloseToOptions, type RoundOptions } from "@ac-kit/core";
|
|
2
|
+
import type { ReadonlyVec2, Vec2 } from "./vec2.js";
|
|
3
|
+
/**
|
|
4
|
+
* Creates the zero vector `[0, 0]`.
|
|
5
|
+
*
|
|
6
|
+
* Allocates; keep it out of hot loops.
|
|
7
|
+
*/
|
|
8
|
+
export declare function vec2Create(): Vec2;
|
|
9
|
+
/**
|
|
10
|
+
* Creates the vector `[x, y]`. Like every creator it starts from an array of
|
|
11
|
+
* doubles, so a vector made of whole numbers is still `PACKED_DOUBLE_ELEMENTS`
|
|
12
|
+
* in V8, where an array literal such as `[1, 2, 3]` is an array of small
|
|
13
|
+
* integers that a shared `out` would turn into a generic array for good.
|
|
14
|
+
*
|
|
15
|
+
* Allocates; keep it out of hot loops.
|
|
16
|
+
*/
|
|
17
|
+
export declare function vec2Of(x: number, y: number): Vec2;
|
|
18
|
+
/**
|
|
19
|
+
* Creates a copy of `a`. Like every creator it starts from a clean array, so a
|
|
20
|
+
* clone of an array of small integers is an array of doubles.
|
|
21
|
+
*
|
|
22
|
+
* Allocates; keep it out of hot loops.
|
|
23
|
+
*/
|
|
24
|
+
export declare function vec2Clone(a: ReadonlyVec2): Vec2;
|
|
25
|
+
/**
|
|
26
|
+
* The checked way in from untyped data (JSON, messages, arrays of unknown
|
|
27
|
+
* origin): `source[offset … offset + 2)` copied into `out`, each element that
|
|
28
|
+
* is not a number written as `NaN`, an index below zero or at or past
|
|
29
|
+
* `source.length` too, so `out` never holds a non-number. Test the result with
|
|
30
|
+
* {@link vec2IsFinite} when `NaN` must not get through. A cold path: a
|
|
31
|
+
* `Float64Array` of vectors is read with {@link vec2Load}. O(1).
|
|
32
|
+
*
|
|
33
|
+
* `source` may be `out` itself: the 2 elements are read before the first write.
|
|
34
|
+
*
|
|
35
|
+
* @param out The vector to fill.
|
|
36
|
+
* @param source The array to read, of any length and any content.
|
|
37
|
+
* @param offset The index of the first component in `source`.
|
|
38
|
+
* @returns `out`.
|
|
39
|
+
*/
|
|
40
|
+
export declare function vec2FromArray(out: Vec2, source: ArrayLike<number>, offset?: number): Vec2;
|
|
41
|
+
/** Writes the vector `[x, y]` into `out`. */
|
|
42
|
+
export declare function vec2Set(out: Vec2, x: number, y: number): Vec2;
|
|
43
|
+
/** Writes a copy of `a` into `out`. */
|
|
44
|
+
export declare function vec2Copy(out: Vec2, a: ReadonlyVec2): Vec2;
|
|
45
|
+
/** Writes the zero vector `[0, 0]` into `out`. */
|
|
46
|
+
export declare function vec2Zero(out: Vec2): Vec2;
|
|
47
|
+
/** Writes `a + b` into `out`. `out` may be `a` or `b`. */
|
|
48
|
+
export declare function vec2Add(out: Vec2, a: ReadonlyVec2, b: ReadonlyVec2): Vec2;
|
|
49
|
+
/** Writes `a − b` into `out`. `out` may be `a` or `b`. */
|
|
50
|
+
export declare function vec2Subtract(out: Vec2, a: ReadonlyVec2, b: ReadonlyVec2): Vec2;
|
|
51
|
+
/**
|
|
52
|
+
* Writes the component-wise product of `a` and `b` into `out`: not the dot
|
|
53
|
+
* product, and not a cross product. `out` may be `a` or `b`.
|
|
54
|
+
*/
|
|
55
|
+
export declare function vec2Multiply(out: Vec2, a: ReadonlyVec2, b: ReadonlyVec2): Vec2;
|
|
56
|
+
/**
|
|
57
|
+
* Writes the component-wise quotient `a / b` into `out`. A zero component of
|
|
58
|
+
* `b` gives `±Infinity`, or `NaN` for `0 / 0`; nothing throws. `out` may be `a`
|
|
59
|
+
* or `b`.
|
|
60
|
+
*/
|
|
61
|
+
export declare function vec2Divide(out: Vec2, a: ReadonlyVec2, b: ReadonlyVec2): Vec2;
|
|
62
|
+
/**
|
|
63
|
+
* Writes `a` with `scalar` added to every component into `out`. `out` may be
|
|
64
|
+
* `a`.
|
|
65
|
+
*/
|
|
66
|
+
export declare function vec2AddScalar(out: Vec2, a: ReadonlyVec2, scalar: number): Vec2;
|
|
67
|
+
/** Writes `a · scalar` into `out`. `out` may be `a`. */
|
|
68
|
+
export declare function vec2MultiplyScalar(out: Vec2, a: ReadonlyVec2, scalar: number): Vec2;
|
|
69
|
+
/**
|
|
70
|
+
* Writes `a / scalar` into `out`. A zero `scalar` gives `±Infinity` or `NaN`
|
|
71
|
+
* components, not an exception. `out` may be `a`.
|
|
72
|
+
*/
|
|
73
|
+
export declare function vec2DivideScalar(out: Vec2, a: ReadonlyVec2, scalar: number): Vec2;
|
|
74
|
+
/**
|
|
75
|
+
* Writes `a + b · scale` into `out`: two roundings per component, not a fused
|
|
76
|
+
* multiply-add. `out` may be `a` or `b`.
|
|
77
|
+
*/
|
|
78
|
+
export declare function vec2AddScaled(out: Vec2, a: ReadonlyVec2, b: ReadonlyVec2, scale: number): Vec2;
|
|
79
|
+
/** Writes `−a` into `out`. `out` may be `a`. */
|
|
80
|
+
export declare function vec2Negate(out: Vec2, a: ReadonlyVec2): Vec2;
|
|
81
|
+
/**
|
|
82
|
+
* Writes the absolute value of every component of `a` into `out`. `out` may be
|
|
83
|
+
* `a`.
|
|
84
|
+
*/
|
|
85
|
+
export declare function vec2Abs(out: Vec2, a: ReadonlyVec2): Vec2;
|
|
86
|
+
/**
|
|
87
|
+
* Writes `a` with every component rounded by `@ac-kit/core`'s `round` into
|
|
88
|
+
* `out`: `options` choose the method (round, floor, ceil, trunc) and the digits
|
|
89
|
+
* kept, and none rounds to whole numbers. `out` may be `a`.
|
|
90
|
+
*/
|
|
91
|
+
export declare function vec2Round(out: Vec2, a: ReadonlyVec2, options?: RoundOptions): Vec2;
|
|
92
|
+
/**
|
|
93
|
+
* Writes the component-wise minimum of `a` and `b` into `out`, as `Math.min`
|
|
94
|
+
* takes it: a `NaN` gives `NaN`, and `−0` is below `+0`. `out` may be `a` or
|
|
95
|
+
* `b`.
|
|
96
|
+
*/
|
|
97
|
+
export declare function vec2Min(out: Vec2, a: ReadonlyVec2, b: ReadonlyVec2): Vec2;
|
|
98
|
+
/**
|
|
99
|
+
* Writes the component-wise maximum of `a` and `b` into `out`, as `Math.max`
|
|
100
|
+
* takes it: a `NaN` gives `NaN`, and `+0` is above `−0`. `out` may be `a` or
|
|
101
|
+
* `b`.
|
|
102
|
+
*/
|
|
103
|
+
export declare function vec2Max(out: Vec2, a: ReadonlyVec2, b: ReadonlyVec2): Vec2;
|
|
104
|
+
/**
|
|
105
|
+
* Writes `a` limited component-wise to `[min, max]` into `out`. Where a `min`
|
|
106
|
+
* component is above its `max`, the `max` wins, and a `NaN` gives `NaN`:
|
|
107
|
+
* nothing throws, unlike `@ac-kit/core`'s `clamp`. `out` may be any of the
|
|
108
|
+
* arguments.
|
|
109
|
+
*/
|
|
110
|
+
export declare function vec2Clamp(out: Vec2, a: ReadonlyVec2, min: ReadonlyVec2, max: ReadonlyVec2): Vec2;
|
|
111
|
+
/**
|
|
112
|
+
* Writes `a` with every component limited to `[min, max]` into `out`. Where
|
|
113
|
+
* `min` is above `max` the `max` wins, and a `NaN` gives `NaN`: nothing throws,
|
|
114
|
+
* unlike `@ac-kit/core`'s `clamp`. `out` may be `a`.
|
|
115
|
+
*/
|
|
116
|
+
export declare function vec2ClampScalar(out: Vec2, a: ReadonlyVec2, min: number, max: number): Vec2;
|
|
117
|
+
/**
|
|
118
|
+
* Writes `a + (b − a)·t` into `out`, each component by `@ac-kit/math-scalar`'s
|
|
119
|
+
* `lerp`: exactly `a` at `t = 0`, and `b` at `t = 1` up to rounding when `a`
|
|
120
|
+
* and `b` differ greatly in magnitude. A `t` outside `[0, 1]` extrapolates.
|
|
121
|
+
* `out` may be `a` or `b`.
|
|
122
|
+
*/
|
|
123
|
+
export declare function vec2Lerp(out: Vec2, a: ReadonlyVec2, b: ReadonlyVec2, t: number): Vec2;
|
|
124
|
+
/**
|
|
125
|
+
* Exact component-wise equality: `−0` equals `+0`, and `NaN` equals nothing,
|
|
126
|
+
* itself included. See {@link vec2IsClose} for a tolerant test.
|
|
127
|
+
* {@link vec2CompareLexicographic} returns `0` for exactly the pairs this calls
|
|
128
|
+
* equal (leaving `NaN` aside).
|
|
129
|
+
*/
|
|
130
|
+
export declare function vec2Equals(a: ReadonlyVec2, b: ReadonlyVec2): boolean;
|
|
131
|
+
/**
|
|
132
|
+
* Component-wise approximate equality, each pair compared by `@ac-kit/core`'s
|
|
133
|
+
* `isCloseTo` with `options`: none means exact.
|
|
134
|
+
*
|
|
135
|
+
* Not transitive, so it is not an equality in the sense a `Set` or `Map` needs,
|
|
136
|
+
* and never a basis for ordering — use {@link vec2Equals} there. The tolerance
|
|
137
|
+
* is required: a vector carries no units of its own, so only the caller knows
|
|
138
|
+
* what counts as close.
|
|
139
|
+
*/
|
|
140
|
+
export declare function vec2IsClose(a: ReadonlyVec2, b: ReadonlyVec2, options: IsCloseToOptions): boolean;
|
|
141
|
+
/**
|
|
142
|
+
* Whether every component is a finite number: the check to run after parsing
|
|
143
|
+
* untrusted data or before an upload, as operations never check. A component
|
|
144
|
+
* that is not a number at all (a vector built by a caller who bypassed the
|
|
145
|
+
* types) counts as not finite.
|
|
146
|
+
*/
|
|
147
|
+
export declare function vec2IsFinite(a: ReadonlyVec2): boolean;
|
|
148
|
+
/**
|
|
149
|
+
* Writes element `index` of `array`, the numbers at `[index·2, index·2 + 2)`,
|
|
150
|
+
* into `out`. Each component is written as `+array[i]`, so an index past the
|
|
151
|
+
* end of `array` gives `NaN`, never `undefined`: the vector stays clean
|
|
152
|
+
* whatever the caller does. Checking the index is the job of the checked
|
|
153
|
+
* layer.
|
|
154
|
+
*
|
|
155
|
+
* The vector is copied: it is never a view of `array`. O(1).
|
|
156
|
+
*/
|
|
157
|
+
export declare function vec2Load(out: Vec2, array: Float64Array, index: number): Vec2;
|
|
158
|
+
/**
|
|
159
|
+
* Writes `value` into `array` as element `index`, at `[index·2, index·2 + 2)`.
|
|
160
|
+
* An element past the end of `array` writes nothing, as a typed array drops an
|
|
161
|
+
* out-of-range write. O(1).
|
|
162
|
+
*/
|
|
163
|
+
export declare function vec2Store(array: Float64Array, index: number, value: ReadonlyVec2): void;
|
|
164
|
+
/**
|
|
165
|
+
* Like {@link vec2Load} for interleaved data: element `index` starts at `offset +
|
|
166
|
+
* index·stride`, both counted in numbers, and its 2 components follow one
|
|
167
|
+
* another. An index past the end gives `NaN` components. O(1).
|
|
168
|
+
*/
|
|
169
|
+
export declare function vec2LoadStrided(out: Vec2, array: Float64Array, offset: number, stride: number, index: number): Vec2;
|
|
170
|
+
/**
|
|
171
|
+
* Like {@link vec2Store} for interleaved data: element `index` starts at `offset +
|
|
172
|
+
* index·stride`, both counted in numbers. A component past the end of `array`
|
|
173
|
+
* writes nothing. O(1).
|
|
174
|
+
*/
|
|
175
|
+
export declare function vec2StoreStrided(array: Float64Array, offset: number, stride: number, index: number, value: ReadonlyVec2): void;
|
|
176
|
+
/**
|
|
177
|
+
* Narrows `value` to binary32 and writes its 2 components into `array` from
|
|
178
|
+
* element `offset` on, unrolled: the way to stage a vertex, instance or uniform
|
|
179
|
+
* value for the GPU, where `array.set` costs several times as much for one
|
|
180
|
+
* value. A component past the end of `array` writes nothing. O(1).
|
|
181
|
+
*/
|
|
182
|
+
export declare function vec2StoreFloat32(array: Float32Array, offset: number, value: ReadonlyVec2): void;
|
|
183
|
+
/**
|
|
184
|
+
* Whether every number of `array` is finite: the check for a buffer of vec2
|
|
185
|
+
* elements read from untrusted data or about to be uploaded. The length is not
|
|
186
|
+
* required to be a multiple of 2 (see `assertFiniteBuffer` for that). O(n).
|
|
187
|
+
*/
|
|
188
|
+
export declare function vec2ArrayIsFinite(array: Float64Array): boolean;
|
|
189
|
+
/**
|
|
190
|
+
* The inner product `Σ aᵢ·bᵢ`, in plain arithmetic: where the terms cancel its
|
|
191
|
+
* error can exceed the result, and {@link vec2DotPrecise} is the form to use
|
|
192
|
+
* there.
|
|
193
|
+
*/
|
|
194
|
+
export declare function vec2Dot(a: ReadonlyVec2, b: ReadonlyVec2): number;
|
|
195
|
+
/**
|
|
196
|
+
* The inner product with the rounding error of every product and every addition
|
|
197
|
+
* recovered and folded back in (Ogita–Rump–Oishi's compensated dot product,
|
|
198
|
+
* computed by `@ac-kit/math-scalar`'s `sumOfProducts`; the two terms are summed
|
|
199
|
+
* in the order `sumOfProducts` uses, not `dotPrecise`'s, so the two can differ
|
|
200
|
+
* in the last bit): as accurate as a dot product in doubled precision rounded
|
|
201
|
+
* once, so it survives the cancellation that leaves {@link vec2Dot} with none of
|
|
202
|
+
* its digits. A few times the cost of the plain form.
|
|
203
|
+
*/
|
|
204
|
+
export declare function vec2DotPrecise(a: ReadonlyVec2, b: ReadonlyVec2): number;
|
|
205
|
+
/**
|
|
206
|
+
* The length `√(Σ aᵢ²)`, right when the largest component lies between about
|
|
207
|
+
* `1e−150` and `1e150`. Beyond, the squares overflow (above about `1.3e154`),
|
|
208
|
+
* or underflow and lose their digits to the subnormal range (below about
|
|
209
|
+
* `1.5e−154`), and the result is `Infinity`, `0` or wrong: use
|
|
210
|
+
* {@link vec2LengthScaled}.
|
|
211
|
+
*/
|
|
212
|
+
export declare function vec2Length(a: ReadonlyVec2): number;
|
|
213
|
+
/**
|
|
214
|
+
* The squared length `Σ aᵢ²`, without the square root, right when the largest
|
|
215
|
+
* component lies between about `1e−150` and `1e150`: beyond, it overflows to
|
|
216
|
+
* `Infinity` or loses its digits to the subnormal range.
|
|
217
|
+
*/
|
|
218
|
+
export declare function vec2LengthSquared(a: ReadonlyVec2): number;
|
|
219
|
+
/**
|
|
220
|
+
* The length at any magnitude: every component is divided by the largest first,
|
|
221
|
+
* so the squares stay in range where {@link vec2Length} returns `0` or
|
|
222
|
+
* `Infinity` beyond about `1e±150`. Zero for the zero vector, `Infinity` for an
|
|
223
|
+
* infinite component, `NaN` for a `NaN` one. About three times the cost.
|
|
224
|
+
*/
|
|
225
|
+
export declare function vec2LengthScaled(a: ReadonlyVec2): number;
|
|
226
|
+
/** The Manhattan length `Σ |aᵢ|`: the distance along the axes. */
|
|
227
|
+
export declare function vec2LengthManhattan(a: ReadonlyVec2): number;
|
|
228
|
+
/** The Chebyshev length `max |aᵢ|`: the largest move along one axis. */
|
|
229
|
+
export declare function vec2LengthChebyshev(a: ReadonlyVec2): number;
|
|
230
|
+
/**
|
|
231
|
+
* The Euclidean distance `|a − b|`, right when the largest difference lies
|
|
232
|
+
* between about `1e−150` and `1e150`; beyond, the squares overflow or lose
|
|
233
|
+
* their digits as in {@link vec2Length}: take {@link vec2LengthScaled} of `a − b`
|
|
234
|
+
* (from {@link vec2Subtract}) instead.
|
|
235
|
+
*/
|
|
236
|
+
export declare function vec2Distance(a: ReadonlyVec2, b: ReadonlyVec2): number;
|
|
237
|
+
/**
|
|
238
|
+
* The squared distance `|a − b|²`, without the square root, right when the
|
|
239
|
+
* largest difference lies between about `1e−150` and `1e150`: beyond, it
|
|
240
|
+
* overflows to `Infinity` or loses its digits.
|
|
241
|
+
*/
|
|
242
|
+
export declare function vec2DistanceSquared(a: ReadonlyVec2, b: ReadonlyVec2): number;
|
|
243
|
+
/** The Manhattan distance `Σ |aᵢ − bᵢ|`: the distance along the axes. */
|
|
244
|
+
export declare function vec2DistanceManhattan(a: ReadonlyVec2, b: ReadonlyVec2): number;
|
|
245
|
+
/** The Chebyshev distance `max |aᵢ − bᵢ|`: the largest move along one axis. */
|
|
246
|
+
export declare function vec2DistanceChebyshev(a: ReadonlyVec2, b: ReadonlyVec2): number;
|
|
247
|
+
/**
|
|
248
|
+
* Writes `a / |a|` into `out`: the unit vector in the same direction, from one
|
|
249
|
+
* reciprocal of the length multiplied in. The zero vector stays zero, and a
|
|
250
|
+
* `NaN` component gives `NaN` throughout. Right when the largest component lies
|
|
251
|
+
* between about `1e−150` and `1e150`; beyond, the squared length overflows,
|
|
252
|
+
* underflows or loses its digits to the subnormal range, and the result is
|
|
253
|
+
* zeros or wrong: use {@link vec2NormalizeScaled}. `out` may be `a`.
|
|
254
|
+
*/
|
|
255
|
+
export declare function vec2Normalize(out: Vec2, a: ReadonlyVec2): Vec2;
|
|
256
|
+
/**
|
|
257
|
+
* Writes `a / |a|` into `out` at any magnitude, subnormal and near the largest
|
|
258
|
+
* binary64 included: the components are divided by the largest first, so the
|
|
259
|
+
* squares stay in range (see {@link vec2Normalize} for the plain form). The zero
|
|
260
|
+
* vector stays zero; `NaN` and infinite components give `NaN` throughout. About
|
|
261
|
+
* three times the cost. `out` may be `a`.
|
|
262
|
+
*/
|
|
263
|
+
export declare function vec2NormalizeScaled(out: Vec2, a: ReadonlyVec2): Vec2;
|
|
264
|
+
/**
|
|
265
|
+
* Writes `a` with its length limited to `[min, max]` into `out`, the direction
|
|
266
|
+
* kept. The zero vector stays zero whatever `min` is, a `min` above `max` gives
|
|
267
|
+
* `max`, and a `NaN` gives `NaN`. The length is that of {@link vec2Length}, so
|
|
268
|
+
* the result is right when the largest component lies between about `1e−150`
|
|
269
|
+
* and `1e150`. Beyond, a vector whose length overflows (components above about
|
|
270
|
+
* `1.3e154`) comes back as the zero vector instead of being limited to `max`,
|
|
271
|
+
* and one whose squares underflow (below about `1.5e−154`) comes back unchanged
|
|
272
|
+
* instead of being lengthened to `min`: limit {@link vec2LengthScaled} yourself
|
|
273
|
+
* and scale {@link vec2NormalizeScaled} by it. `out` may be `a`.
|
|
274
|
+
*/
|
|
275
|
+
export declare function vec2ClampLength(out: Vec2, a: ReadonlyVec2, min: number, max: number): Vec2;
|
|
276
|
+
/**
|
|
277
|
+
* Writes the projection of `a` onto the line along `onto`, `onto · (a·onto) /
|
|
278
|
+
* (onto·onto)`, into `out`. `onto` need not be a unit vector; a zero `onto`
|
|
279
|
+
* gives `NaN`. Right when the largest component of `onto` lies between about
|
|
280
|
+
* `1e−150` and `1e150`, where `onto·onto` stays in range: above about `1.3e154`
|
|
281
|
+
* it overflows and the projection is the zero vector, and below about
|
|
282
|
+
* `1.5e−154` it underflows and the result is not finite. Beyond, normalise
|
|
283
|
+
* `onto` with {@link vec2NormalizeScaled} first. `out` may be `a` or `onto`.
|
|
284
|
+
*/
|
|
285
|
+
export declare function vec2Project(out: Vec2, a: ReadonlyVec2, onto: ReadonlyVec2): Vec2;
|
|
286
|
+
/**
|
|
287
|
+
* Writes `a` minus its projection onto `onto` into `out`: the part of `a`
|
|
288
|
+
* perpendicular to `onto`. A zero `onto` gives `NaN`. Right when the largest
|
|
289
|
+
* component of `onto` lies between about `1e−150` and `1e150`, as for
|
|
290
|
+
* {@link vec2Project}: beyond, the result is `a` (the projection is zero) or not
|
|
291
|
+
* finite; normalise `onto` with {@link vec2NormalizeScaled} first. `out` may be
|
|
292
|
+
* `a` or `onto`.
|
|
293
|
+
*/
|
|
294
|
+
export declare function vec2Reject(out: Vec2, a: ReadonlyVec2, onto: ReadonlyVec2): Vec2;
|
|
295
|
+
/**
|
|
296
|
+
* Writes `a` mirrored across the line whose normal is `normal`, `a −
|
|
297
|
+
* 2(a·normal)·normal`, into `out`. `normal` must be a unit vector: it is not
|
|
298
|
+
* normalised here. `out` may be `a` or `normal`.
|
|
299
|
+
*/
|
|
300
|
+
export declare function vec2Reflect(out: Vec2, a: ReadonlyVec2, normal: ReadonlyVec2): Vec2;
|
|
301
|
+
/**
|
|
302
|
+
* Orders vectors lexicographically: by x, then by y. Exact, so it returns `0`
|
|
303
|
+
* for exactly the pairs {@link vec2Equals} calls equal, and a total order
|
|
304
|
+
* whatever the components: `NaN` sorts after every number and equals itself
|
|
305
|
+
* (where `vec2Equals` says it equals nothing), and `−0` equals `+0`. Fit for a
|
|
306
|
+
* sort comparator or an ordered container.
|
|
307
|
+
*
|
|
308
|
+
* @returns `−1` when `a` comes first, `1` when `b` does, `0` when neither.
|
|
309
|
+
*/
|
|
310
|
+
export declare function vec2CompareLexicographic(a: ReadonlyVec2, b: ReadonlyVec2): ComparatorResult;
|
|
311
|
+
//# sourceMappingURL=vec2-componentwise.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vec2-componentwise.d.ts","sourceRoot":"","sources":["../src/vec2-componentwise.ts"],"names":[],"mappings":"AAEA,OAAO,EAEN,KAAK,gBAAgB,EAErB,KAAK,gBAAgB,EAGrB,KAAK,YAAY,EACjB,MAAM,cAAc,CAAC;AAGtB,OAAO,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAQpD;;;;GAIG;AACH,wBAAgB,UAAU,IAAI,IAAI,CAKjC;AAED;;;;;;;G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