@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,114 @@
|
|
|
1
|
+
import type { Brand_ } from "./_brand.js";
|
|
2
|
+
import type { ReadonlyMat4x4 } from "./mat4x4.js";
|
|
3
|
+
import type { ReadonlyVec2, Vec2 } from "./vec2.js";
|
|
4
|
+
import type { ReadonlyVec3, Vec3 } from "./vec3.js";
|
|
5
|
+
/**
|
|
6
|
+
* A rectangle of the render target in pixels, `[x, y, width, height]`: the
|
|
7
|
+
* origin is the top-left corner and y points down, as in a framebuffer and in
|
|
8
|
+
* DOM events. Pixel `i` covers `[i, i + 1)`, and normalised device coordinates
|
|
9
|
+
* `−1` map to the left and top edges, not to a pixel centre. A plain array of
|
|
10
|
+
* four binary64 numbers carrying a type-level brand.
|
|
11
|
+
*
|
|
12
|
+
* Only {@link viewportCreate}, {@link viewportOf}, {@link viewportClone},
|
|
13
|
+
* {@link viewportFromArray} and the functions that write an `out` make one; see
|
|
14
|
+
* {@link Vec3} for the rules that bind callers who bypass the types.
|
|
15
|
+
*/
|
|
16
|
+
export type Viewport = [x: number, y: number, width: number, height: number] & Brand_<"Viewport">;
|
|
17
|
+
/** A {@link Viewport} that is only read. */
|
|
18
|
+
export type ReadonlyViewport = readonly [
|
|
19
|
+
x: number,
|
|
20
|
+
y: number,
|
|
21
|
+
width: number,
|
|
22
|
+
height: number
|
|
23
|
+
] & Brand_<"Viewport">;
|
|
24
|
+
/**
|
|
25
|
+
* Creates the empty viewport `[0, 0, 0, 0]`.
|
|
26
|
+
*
|
|
27
|
+
* Allocates; keep it out of hot loops.
|
|
28
|
+
*/
|
|
29
|
+
export declare function viewportCreate(): Viewport;
|
|
30
|
+
/**
|
|
31
|
+
* Creates the viewport with its top-left corner at `[x, y]` and the size `width
|
|
32
|
+
* × height`, in pixels.
|
|
33
|
+
*
|
|
34
|
+
* Allocates; keep it out of hot loops.
|
|
35
|
+
*/
|
|
36
|
+
export declare function viewportOf(x: number, y: number, width: number, height: number): Viewport;
|
|
37
|
+
/**
|
|
38
|
+
* Creates a copy of `viewport`. Like every creator it starts from a clean
|
|
39
|
+
* array.
|
|
40
|
+
*
|
|
41
|
+
* Allocates; keep it out of hot loops.
|
|
42
|
+
*/
|
|
43
|
+
export declare function viewportClone(viewport: ReadonlyViewport): Viewport;
|
|
44
|
+
/** Writes the viewport `[x, y, width, height]` into `out`. */
|
|
45
|
+
export declare function viewportSet(out: Viewport, x: number, y: number, width: number, height: number): Viewport;
|
|
46
|
+
/**
|
|
47
|
+
* The checked way in from untyped data (JSON, messages, arrays of unknown
|
|
48
|
+
* origin): `source[offset … offset + 4)` copied into `out`, each element that
|
|
49
|
+
* is not a number written as `NaN`, an index past the end of `source` too, so
|
|
50
|
+
* `out` never holds a non-number. A cold path. O(1).
|
|
51
|
+
*
|
|
52
|
+
* `source` may be `out` itself: the four elements are read before the first
|
|
53
|
+
* write.
|
|
54
|
+
*
|
|
55
|
+
* @param out The viewport to fill.
|
|
56
|
+
* @param source The array to read, of any length and any content.
|
|
57
|
+
* @param offset The index of the `x` entry in `source`.
|
|
58
|
+
* @returns `out`.
|
|
59
|
+
*/
|
|
60
|
+
export declare function viewportFromArray(out: Viewport, source: ArrayLike<number>, offset?: number): Viewport;
|
|
61
|
+
/**
|
|
62
|
+
* Whether every entry is a finite number: the check to run after parsing
|
|
63
|
+
* untrusted data or before an upload, as operations never check. An entry that
|
|
64
|
+
* is not a number at all counts as not finite.
|
|
65
|
+
*/
|
|
66
|
+
export declare function viewportIsFinite(viewport: ReadonlyViewport): boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Writes the pixel position of the normalised device coordinates `ndc` into
|
|
69
|
+
* `out`: `x` from `−1` at the left edge to `1` at the right edge of the
|
|
70
|
+
* viewport, `y` from `1` at the top edge to `−1` at the bottom edge (NDC has
|
|
71
|
+
* `y` up, pixels `y` down), so the corners land exactly on the edges, not on
|
|
72
|
+
* pixel centres. The depth is not touched here. `out` may be `ndc`.
|
|
73
|
+
*/
|
|
74
|
+
export declare function vec2NdcToViewport(out: Vec2, ndc: ReadonlyVec2, viewport: ReadonlyViewport): Vec2;
|
|
75
|
+
/**
|
|
76
|
+
* Writes the normalised device coordinates of the pixel position `point` into
|
|
77
|
+
* `out`, the inverse of {@link vec2NdcToViewport}: the left and top edges are
|
|
78
|
+
* `−1` and `1`, the right and bottom edges `1` and `−1`. A viewport of zero
|
|
79
|
+
* width or height gives non-finite coordinates and nothing throws. `out` may be
|
|
80
|
+
* `point`.
|
|
81
|
+
*/
|
|
82
|
+
export declare function vec2ViewportToNdc(out: Vec2, point: ReadonlyVec2, viewport: ReadonlyViewport): Vec2;
|
|
83
|
+
/**
|
|
84
|
+
* Writes the position of the world point `point` on the screen into `out`: `[x
|
|
85
|
+
* px, y px, depth]`, the pixel position as {@link vec2NdcToViewport} and the
|
|
86
|
+
* depth in the range of the projection that built `viewProjection` (`0` at the
|
|
87
|
+
* near plane to `1` at the far plane for `"zero-to-one"`, `−1` to `1` for
|
|
88
|
+
* `"negative-one-to-one"`, `1` to `0` for `"one-to-zero"`). A point on or
|
|
89
|
+
* behind the eye (`w ≤ 0`, where the divide would mirror it onto the screen)
|
|
90
|
+
* gives `NaN` throughout, never a throw; so does `NaN`. `out` may be `point`.
|
|
91
|
+
*/
|
|
92
|
+
export declare function vec3ProjectToViewport(out: Vec3, point: ReadonlyVec3, viewProjection: ReadonlyMat4x4, viewport: ReadonlyViewport): Vec3;
|
|
93
|
+
/**
|
|
94
|
+
* Writes the world point at the screen position `point`, `[x px, y px, depth]`,
|
|
95
|
+
* into `out`: the inverse of {@link vec3ProjectToViewport}, given the inverse of
|
|
96
|
+
* the matrix that projected (`mat4x4Invert` of the view-projection) and a depth
|
|
97
|
+
* in the range of that projection. The result is divided by its `w`, which is
|
|
98
|
+
* `0` where the depth is that of the eye plane of a perspective projection: the
|
|
99
|
+
* coordinates are then non-finite, never a throw. `out` may be `point`.
|
|
100
|
+
*/
|
|
101
|
+
export declare function vec3UnprojectFromViewport(out: Vec3, point: ReadonlyVec3, inverseViewProjection: ReadonlyMat4x4, viewport: ReadonlyViewport): Vec3;
|
|
102
|
+
/**
|
|
103
|
+
* Writes the screen position of every point of `input`, three numbers each,
|
|
104
|
+
* into `out`, as {@link vec3ProjectToViewport} does one at a time (`NaN` for a
|
|
105
|
+
* point on or behind the eye): the kernel for labels and markers. The two
|
|
106
|
+
* arrays hold the same number of points, a multiple of three numbers; `out` may
|
|
107
|
+
* be `input` itself (in place) but not a partially overlapping view of it.
|
|
108
|
+
* O(n).
|
|
109
|
+
*
|
|
110
|
+
* @throws {RangeError} When `input.length` is not a multiple of 3 or `out` has
|
|
111
|
+
* another length.
|
|
112
|
+
*/
|
|
113
|
+
export declare function vec3ArrayProjectToViewport<T extends Float64Array>(out: T, input: Float64Array, viewProjection: ReadonlyMat4x4, viewport: ReadonlyViewport): T;
|
|
114
|
+
//# sourceMappingURL=viewport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"viewport.d.ts","sourceRoot":"","sources":["../src/viewport.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEpD;;;;;;;;;;GAUG;AACH,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,GAC3E,MAAM,CAAC,UAAU,CAAC,CAAC;AAEpB,4CAA4C;AAC5C,MAAM,MAAM,gBAAgB,GAAG,SAAS;IACvC,CAAC,EAAE,MAAM;IACT,CAAC,EAAE,MAAM;IACT,KAAK,EAAE,MAAM;IACb,MAAM,EAAE,MAAM;CACd,GACA,MAAM,CAAC,UAAU,CAAC,CAAC;AAQpB;;;;GAIG;AACH,wBAAgB,cAAc,IAAI,QAAQ,CAOzC;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CACzB,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,KAAK,E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AAY,EACnB,cAAc,EAAE,cAAc,EAC9B,QAAQ,EAAE,gBAAgB,GACxB,CAAC,CA8CH"}
|
package/dist/viewport.js
ADDED
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import { numberAtOrNaN } from "@ac-kit/core";
|
|
2
|
+
/**
|
|
3
|
+
* Every creator copies this array, which holds non-integer doubles and is never
|
|
4
|
+
* exposed: nothing a caller does can change the element kind it copies.
|
|
5
|
+
*/
|
|
6
|
+
const TEMPLATE_ = [0.5, 0.5, 0.5, 0.5];
|
|
7
|
+
/**
|
|
8
|
+
* Creates the empty viewport `[0, 0, 0, 0]`.
|
|
9
|
+
*
|
|
10
|
+
* Allocates; keep it out of hot loops.
|
|
11
|
+
*/
|
|
12
|
+
export function viewportCreate() {
|
|
13
|
+
const out = TEMPLATE_.slice();
|
|
14
|
+
out[0] = 0;
|
|
15
|
+
out[1] = 0;
|
|
16
|
+
out[2] = 0;
|
|
17
|
+
out[3] = 0;
|
|
18
|
+
return out;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Creates the viewport with its top-left corner at `[x, y]` and the size `width
|
|
22
|
+
* × height`, in pixels.
|
|
23
|
+
*
|
|
24
|
+
* Allocates; keep it out of hot loops.
|
|
25
|
+
*/
|
|
26
|
+
export function viewportOf(x, y, width, height) {
|
|
27
|
+
const out = TEMPLATE_.slice();
|
|
28
|
+
out[0] = x;
|
|
29
|
+
out[1] = y;
|
|
30
|
+
out[2] = width;
|
|
31
|
+
out[3] = height;
|
|
32
|
+
return out;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Creates a copy of `viewport`. Like every creator it starts from a clean
|
|
36
|
+
* array.
|
|
37
|
+
*
|
|
38
|
+
* Allocates; keep it out of hot loops.
|
|
39
|
+
*/
|
|
40
|
+
export function viewportClone(viewport) {
|
|
41
|
+
const out = TEMPLATE_.slice();
|
|
42
|
+
out[0] = viewport[0];
|
|
43
|
+
out[1] = viewport[1];
|
|
44
|
+
out[2] = viewport[2];
|
|
45
|
+
out[3] = viewport[3];
|
|
46
|
+
return out;
|
|
47
|
+
}
|
|
48
|
+
/** Writes the viewport `[x, y, width, height]` into `out`. */
|
|
49
|
+
export function viewportSet(out, x, y, width, height) {
|
|
50
|
+
out[0] = x;
|
|
51
|
+
out[1] = y;
|
|
52
|
+
out[2] = width;
|
|
53
|
+
out[3] = height;
|
|
54
|
+
return out;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* The checked way in from untyped data (JSON, messages, arrays of unknown
|
|
58
|
+
* origin): `source[offset … offset + 4)` copied into `out`, each element that
|
|
59
|
+
* is not a number written as `NaN`, an index past the end of `source` too, so
|
|
60
|
+
* `out` never holds a non-number. A cold path. O(1).
|
|
61
|
+
*
|
|
62
|
+
* `source` may be `out` itself: the four elements are read before the first
|
|
63
|
+
* write.
|
|
64
|
+
*
|
|
65
|
+
* @param out The viewport to fill.
|
|
66
|
+
* @param source The array to read, of any length and any content.
|
|
67
|
+
* @param offset The index of the `x` entry in `source`.
|
|
68
|
+
* @returns `out`.
|
|
69
|
+
*/
|
|
70
|
+
export function viewportFromArray(out, source, offset = 0) {
|
|
71
|
+
const x = numberAtOrNaN(source, offset);
|
|
72
|
+
const y = numberAtOrNaN(source, offset + 1);
|
|
73
|
+
const width = numberAtOrNaN(source, offset + 2);
|
|
74
|
+
const height = numberAtOrNaN(source, offset + 3);
|
|
75
|
+
out[0] = x;
|
|
76
|
+
out[1] = y;
|
|
77
|
+
out[2] = width;
|
|
78
|
+
out[3] = height;
|
|
79
|
+
return out;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Whether every entry is a finite number: the check to run after parsing
|
|
83
|
+
* untrusted data or before an upload, as operations never check. An entry that
|
|
84
|
+
* is not a number at all counts as not finite.
|
|
85
|
+
*/
|
|
86
|
+
export function viewportIsFinite(viewport) {
|
|
87
|
+
return (Number.isFinite(viewport[0]) &&
|
|
88
|
+
Number.isFinite(viewport[1]) &&
|
|
89
|
+
Number.isFinite(viewport[2]) &&
|
|
90
|
+
Number.isFinite(viewport[3]));
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Writes the pixel position of the normalised device coordinates `ndc` into
|
|
94
|
+
* `out`: `x` from `−1` at the left edge to `1` at the right edge of the
|
|
95
|
+
* viewport, `y` from `1` at the top edge to `−1` at the bottom edge (NDC has
|
|
96
|
+
* `y` up, pixels `y` down), so the corners land exactly on the edges, not on
|
|
97
|
+
* pixel centres. The depth is not touched here. `out` may be `ndc`.
|
|
98
|
+
*/
|
|
99
|
+
export function vec2NdcToViewport(out, ndc, viewport) {
|
|
100
|
+
const x = ndc[0];
|
|
101
|
+
const y = ndc[1];
|
|
102
|
+
out[0] = viewport[0] + (x + 1) * 0.5 * viewport[2];
|
|
103
|
+
out[1] = viewport[1] + (1 - y) * 0.5 * viewport[3];
|
|
104
|
+
return out;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Writes the normalised device coordinates of the pixel position `point` into
|
|
108
|
+
* `out`, the inverse of {@link vec2NdcToViewport}: the left and top edges are
|
|
109
|
+
* `−1` and `1`, the right and bottom edges `1` and `−1`. A viewport of zero
|
|
110
|
+
* width or height gives non-finite coordinates and nothing throws. `out` may be
|
|
111
|
+
* `point`.
|
|
112
|
+
*/
|
|
113
|
+
export function vec2ViewportToNdc(out, point, viewport) {
|
|
114
|
+
const x = point[0];
|
|
115
|
+
const y = point[1];
|
|
116
|
+
out[0] = ((x - viewport[0]) / viewport[2]) * 2 - 1;
|
|
117
|
+
out[1] = 1 - ((y - viewport[1]) / viewport[3]) * 2;
|
|
118
|
+
return out;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Writes the position of the world point `point` on the screen into `out`: `[x
|
|
122
|
+
* px, y px, depth]`, the pixel position as {@link vec2NdcToViewport} and the
|
|
123
|
+
* depth in the range of the projection that built `viewProjection` (`0` at the
|
|
124
|
+
* near plane to `1` at the far plane for `"zero-to-one"`, `−1` to `1` for
|
|
125
|
+
* `"negative-one-to-one"`, `1` to `0` for `"one-to-zero"`). A point on or
|
|
126
|
+
* behind the eye (`w ≤ 0`, where the divide would mirror it onto the screen)
|
|
127
|
+
* gives `NaN` throughout, never a throw; so does `NaN`. `out` may be `point`.
|
|
128
|
+
*/
|
|
129
|
+
export function vec3ProjectToViewport(out, point, viewProjection, viewport) {
|
|
130
|
+
const x = point[0];
|
|
131
|
+
const y = point[1];
|
|
132
|
+
const z = point[2];
|
|
133
|
+
const w = viewProjection[3] * x +
|
|
134
|
+
viewProjection[7] * y +
|
|
135
|
+
viewProjection[11] * z +
|
|
136
|
+
viewProjection[15];
|
|
137
|
+
if (!(w > 0)) {
|
|
138
|
+
out[0] = Number.NaN;
|
|
139
|
+
out[1] = Number.NaN;
|
|
140
|
+
out[2] = Number.NaN;
|
|
141
|
+
return out;
|
|
142
|
+
}
|
|
143
|
+
const clipX = viewProjection[0] * x +
|
|
144
|
+
viewProjection[4] * y +
|
|
145
|
+
viewProjection[8] * z +
|
|
146
|
+
viewProjection[12];
|
|
147
|
+
const clipY = viewProjection[1] * x +
|
|
148
|
+
viewProjection[5] * y +
|
|
149
|
+
viewProjection[9] * z +
|
|
150
|
+
viewProjection[13];
|
|
151
|
+
const clipZ = viewProjection[2] * x +
|
|
152
|
+
viewProjection[6] * y +
|
|
153
|
+
viewProjection[10] * z +
|
|
154
|
+
viewProjection[14];
|
|
155
|
+
out[0] = viewport[0] + (clipX / w + 1) * 0.5 * viewport[2];
|
|
156
|
+
out[1] = viewport[1] + (1 - clipY / w) * 0.5 * viewport[3];
|
|
157
|
+
out[2] = clipZ / w;
|
|
158
|
+
return out;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Writes the world point at the screen position `point`, `[x px, y px, depth]`,
|
|
162
|
+
* into `out`: the inverse of {@link vec3ProjectToViewport}, given the inverse of
|
|
163
|
+
* the matrix that projected (`mat4x4Invert` of the view-projection) and a depth
|
|
164
|
+
* in the range of that projection. The result is divided by its `w`, which is
|
|
165
|
+
* `0` where the depth is that of the eye plane of a perspective projection: the
|
|
166
|
+
* coordinates are then non-finite, never a throw. `out` may be `point`.
|
|
167
|
+
*/
|
|
168
|
+
export function vec3UnprojectFromViewport(out, point, inverseViewProjection, viewport) {
|
|
169
|
+
const x = ((point[0] - viewport[0]) / viewport[2]) * 2 - 1;
|
|
170
|
+
const y = 1 - ((point[1] - viewport[1]) / viewport[3]) * 2;
|
|
171
|
+
const z = point[2];
|
|
172
|
+
const w = inverseViewProjection[3] * x +
|
|
173
|
+
inverseViewProjection[7] * y +
|
|
174
|
+
inverseViewProjection[11] * z +
|
|
175
|
+
inverseViewProjection[15];
|
|
176
|
+
const worldX = inverseViewProjection[0] * x +
|
|
177
|
+
inverseViewProjection[4] * y +
|
|
178
|
+
inverseViewProjection[8] * z +
|
|
179
|
+
inverseViewProjection[12];
|
|
180
|
+
const worldY = inverseViewProjection[1] * x +
|
|
181
|
+
inverseViewProjection[5] * y +
|
|
182
|
+
inverseViewProjection[9] * z +
|
|
183
|
+
inverseViewProjection[13];
|
|
184
|
+
const worldZ = inverseViewProjection[2] * x +
|
|
185
|
+
inverseViewProjection[6] * y +
|
|
186
|
+
inverseViewProjection[10] * z +
|
|
187
|
+
inverseViewProjection[14];
|
|
188
|
+
out[0] = worldX / w;
|
|
189
|
+
out[1] = worldY / w;
|
|
190
|
+
out[2] = worldZ / w;
|
|
191
|
+
return out;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Writes the screen position of every point of `input`, three numbers each,
|
|
195
|
+
* into `out`, as {@link vec3ProjectToViewport} does one at a time (`NaN` for a
|
|
196
|
+
* point on or behind the eye): the kernel for labels and markers. The two
|
|
197
|
+
* arrays hold the same number of points, a multiple of three numbers; `out` may
|
|
198
|
+
* be `input` itself (in place) but not a partially overlapping view of it.
|
|
199
|
+
* O(n).
|
|
200
|
+
*
|
|
201
|
+
* @throws {RangeError} When `input.length` is not a multiple of 3 or `out` has
|
|
202
|
+
* another length.
|
|
203
|
+
*/
|
|
204
|
+
export function vec3ArrayProjectToViewport(out, input, viewProjection, viewport) {
|
|
205
|
+
const length = input.length;
|
|
206
|
+
if (length % 3 !== 0 || out.length !== length) {
|
|
207
|
+
throw new RangeError(`vec3ArrayProjectToViewport: out has ${out.length} numbers for ${length} in input, which must be a multiple of 3.`);
|
|
208
|
+
}
|
|
209
|
+
const m0 = viewProjection[0];
|
|
210
|
+
const m1 = viewProjection[1];
|
|
211
|
+
const m2 = viewProjection[2];
|
|
212
|
+
const m3 = viewProjection[3];
|
|
213
|
+
const m4 = viewProjection[4];
|
|
214
|
+
const m5 = viewProjection[5];
|
|
215
|
+
const m6 = viewProjection[6];
|
|
216
|
+
const m7 = viewProjection[7];
|
|
217
|
+
const m8 = viewProjection[8];
|
|
218
|
+
const m9 = viewProjection[9];
|
|
219
|
+
const m10 = viewProjection[10];
|
|
220
|
+
const m11 = viewProjection[11];
|
|
221
|
+
const m12 = viewProjection[12];
|
|
222
|
+
const m13 = viewProjection[13];
|
|
223
|
+
const m14 = viewProjection[14];
|
|
224
|
+
const m15 = viewProjection[15];
|
|
225
|
+
const left = viewport[0];
|
|
226
|
+
const top = viewport[1];
|
|
227
|
+
const width = viewport[2];
|
|
228
|
+
const height = viewport[3];
|
|
229
|
+
for (let index = 0; index < length; index += 3) {
|
|
230
|
+
const x = input[index];
|
|
231
|
+
const y = input[index + 1];
|
|
232
|
+
const z = input[index + 2];
|
|
233
|
+
const w = m3 * x + m7 * y + m11 * z + m15;
|
|
234
|
+
if (w > 0) {
|
|
235
|
+
const clipX = m0 * x + m4 * y + m8 * z + m12;
|
|
236
|
+
const clipY = m1 * x + m5 * y + m9 * z + m13;
|
|
237
|
+
const clipZ = m2 * x + m6 * y + m10 * z + m14;
|
|
238
|
+
out[index] = left + (clipX / w + 1) * 0.5 * width;
|
|
239
|
+
out[index + 1] = top + (1 - clipY / w) * 0.5 * height;
|
|
240
|
+
out[index + 2] = clipZ / w;
|
|
241
|
+
}
|
|
242
|
+
else {
|
|
243
|
+
out[index] = Number.NaN;
|
|
244
|
+
out[index + 1] = Number.NaN;
|
|
245
|
+
out[index + 2] = Number.NaN;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
return out;
|
|
249
|
+
}
|
|
250
|
+
//# sourceMappingURL=viewport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"viewport.js","sourceRoot":"","sources":["../src/viewport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AA8B7C;;;GAGG;AACH,MAAM,SAAS,GAAsB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;AAE1D;;;;GAIG;AACH,MAAM,UAAU,cAAc;IAC7B,MAAM,GAAG,GAAG,SAAS,CAAC,KAAK,EAAc,CAAC;IAC1C,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACX,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACX,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACX,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACX,OAAO,GAAG,CAAC;AACZ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CACzB,CAAS,EACT,CAAS,EACT,KAAa,EACb,MAAc;IAEd,MAAM,GAAG,GAAG,SAAS,CAAC,KAAK,EAAc,CAAC;IAC1C,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACX,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACX,GAAG,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;IACf,GAAG,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC;IAChB,OAAO,GAAG,CAAC;AACZ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,QAA0B;IACvD,MAAM,GAAG,GAAG,SAAS,CAAC,KAAK,EAAc,CAA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AAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ac-kit/math-linear",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Linear algebra over IEEE 754 binary64: vectors, matrices and quaternions of fixed, small dimension.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"linear-algebra",
|
|
@@ -26,12 +26,14 @@
|
|
|
26
26
|
"sideEffects": false,
|
|
27
27
|
"main": "./dist/index.js",
|
|
28
28
|
"exports": {
|
|
29
|
-
".": "./dist/index.js"
|
|
29
|
+
".": "./dist/index.js",
|
|
30
|
+
"./checked": "./dist/checked/index.js"
|
|
30
31
|
},
|
|
31
32
|
"publishConfig": {
|
|
32
33
|
"main": "./dist/index.js",
|
|
33
34
|
"exports": {
|
|
34
|
-
".": "./dist/index.js"
|
|
35
|
+
".": "./dist/index.js",
|
|
36
|
+
"./checked": "./dist/checked/index.js"
|
|
35
37
|
},
|
|
36
38
|
"access": "public"
|
|
37
39
|
},
|
|
@@ -40,25 +42,32 @@
|
|
|
40
42
|
"compile:check": "tsc -noEmit -p ./tsconfig.json",
|
|
41
43
|
"clean": "rimraf dist",
|
|
42
44
|
"build": "yarn clean && yarn compile",
|
|
45
|
+
"generate:componentwise": "node --import tsx ./scripts/generate-componentwise.ts",
|
|
46
|
+
"generate:check": "node --import tsx ./scripts/generate-componentwise.ts --check",
|
|
43
47
|
"test": "yarn run -T vitest run",
|
|
44
48
|
"prepack": "yarn build"
|
|
45
49
|
},
|
|
46
50
|
"dependencies": {
|
|
47
|
-
"@ac-kit/core": "^0.
|
|
48
|
-
"@ac-kit/math-complex": "^0.
|
|
49
|
-
"@ac-kit/math-scalar": "^0.
|
|
51
|
+
"@ac-kit/core": "^0.12.0",
|
|
52
|
+
"@ac-kit/math-complex": "^0.2.0",
|
|
53
|
+
"@ac-kit/math-scalar": "^0.3.0",
|
|
50
54
|
"@types/web": "^0.0.367"
|
|
51
55
|
},
|
|
52
56
|
"devDependencies": {
|
|
57
|
+
"@ac-kit/codegen-util": "0.1.0",
|
|
58
|
+
"@ac-kit/math-random": "0.4.0",
|
|
59
|
+
"@ac-kit/test-util": "0.4.0",
|
|
53
60
|
"@ac-kit/tsconfig": "0.1.0",
|
|
54
61
|
"@ac-kit/typedoc-config": "0.1.0",
|
|
55
|
-
"@ac-kit/vitest-config": "0.
|
|
62
|
+
"@ac-kit/vitest-config": "0.2.0",
|
|
63
|
+
"@types/node": "26.6.11",
|
|
56
64
|
"@typescript/native": "typescript@7.0.2",
|
|
57
65
|
"rimraf": "6.1.4",
|
|
66
|
+
"tsx": "4.23.15",
|
|
58
67
|
"typedoc": "0.28.20",
|
|
59
68
|
"typescript": "@typescript/typescript6@6.0.2",
|
|
60
|
-
"vite": "8.
|
|
61
|
-
"vitest": "5.1.
|
|
69
|
+
"vite": "8.4.0",
|
|
70
|
+
"vitest": "5.1.2"
|
|
62
71
|
},
|
|
63
72
|
"engines": {
|
|
64
73
|
"node": ">=24"
|