@ac-kit/math-complex 0.1.9 → 0.2.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 CHANGED
@@ -1,5 +1,82 @@
1
1
  # @ac-kit/math-complex
2
2
 
3
+ ## 0.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 34e8cfa: Quaternions follow the out-first standard. `Quaternion` is a branded
8
+ `[x, y, z, w]` tuple made only by `quaternionCreate` (the identity),
9
+ `quaternionOf`, `quaternionClone` and `quaternionFromArray`, so an array
10
+ literal, a `number[]` or a `Float64Array` no longer type-checks and every
11
+ quaternion is a clean array of doubles for V8. `quaternionFromArray` is the
12
+ checked way in from JSON or messages: an element that is not a number, or lies
13
+ past `source.length`, is stored as `NaN`, never as anything else. `quaternionIsFinite` checks a value after
14
+ parsing. Every operation takes `out` first, writes it, returns it, allocates
15
+ nothing, and accepts any of its inputs as `out`.
16
+
17
+ Operations never throw: `quaternionNormalize` of the zero quaternion is zero and
18
+ `quaternionInvert` of it is `NaN`. Arithmetic is plain: `quaternionMultiply` and
19
+ `quaternionDot` no longer use compensated sums, so results can differ in the
20
+ last bits, and the norm, the normalisation and the inverse are right between
21
+ about `1e-150` and `1e150`. Beyond that, `quaternionLengthScaled`,
22
+ `quaternionNormalizeScaled` and `quaternionInvertScaled` divide by the largest
23
+ component first. `QuaternionNum` keeps its API, built on the scaled forms: the
24
+ tuples it takes and returns are copies, `norm()` is right at any magnitude, and
25
+ `inv()` throws only on the zero quaternion (it threw for `1e-200`, whose inverse
26
+ exists).
27
+
28
+ Migration: `quaternionSub`, `quaternionNeg`, `quaternionInverse` and
29
+ `quaternionLengthSq` become `quaternionSubtract`, `quaternionNegate`,
30
+ `quaternionInvert` and `quaternionLengthSquared`, and every function that
31
+ returns a quaternion takes the destination first (`quaternionMultiply(a, b)` is
32
+ now `quaternionMultiply(quaternionCreate(), a, b)`). `QUATERNION_IDENTITY` is
33
+ gone: use `quaternionCreate()` or `quaternionIdentity(out)`. Literals such as
34
+ `[0, 0, 0, 1]` become `quaternionOf(0, 0, 0, 1)`. Code that caught the error on
35
+ a zero quaternion tests the result instead.
36
+
37
+ ### Patch Changes
38
+
39
+ - Updated dependencies [34e8cfa]
40
+ - Updated dependencies [34e8cfa]
41
+ - Updated dependencies [34e8cfa]
42
+ - Updated dependencies [34e8cfa]
43
+ - Updated dependencies [34e8cfa]
44
+ - Updated dependencies [34e8cfa]
45
+ - Updated dependencies [34e8cfa]
46
+ - Updated dependencies [34e8cfa]
47
+ - Updated dependencies [34e8cfa]
48
+ - Updated dependencies [34e8cfa]
49
+ - Updated dependencies [34e8cfa]
50
+ - Updated dependencies [34e8cfa]
51
+ - Updated dependencies [34e8cfa]
52
+ - Updated dependencies [34e8cfa]
53
+ - Updated dependencies [34e8cfa]
54
+ - Updated dependencies [34e8cfa]
55
+ - Updated dependencies [34e8cfa]
56
+ - Updated dependencies [34e8cfa]
57
+ - Updated dependencies [34e8cfa]
58
+ - Updated dependencies [34e8cfa]
59
+ - Updated dependencies [34e8cfa]
60
+ - Updated dependencies [34e8cfa]
61
+ - Updated dependencies [34e8cfa]
62
+ - Updated dependencies [34e8cfa]
63
+ - Updated dependencies [34e8cfa]
64
+ - Updated dependencies [34e8cfa]
65
+ - @ac-kit/core@0.12.0
66
+ - @ac-kit/math-scalar@0.3.0
67
+ - @ac-kit/math-algebra@0.1.11
68
+
69
+ ## 0.1.10
70
+
71
+ ### Patch Changes
72
+
73
+ - Updated dependencies [065cf8d]
74
+ - Updated dependencies [065cf8d]
75
+ - Updated dependencies [065cf8d]
76
+ - @ac-kit/core@0.11.0
77
+ - @ac-kit/math-algebra@0.1.10
78
+ - @ac-kit/math-scalar@0.2.3
79
+
3
80
  ## 0.1.9
4
81
 
5
82
  ### Patch Changes
package/README.md CHANGED
@@ -32,11 +32,14 @@ rotation matrices, slerp — lives there.
32
32
  | `complexArgument` | Principal argument in `(−π, π]` |
33
33
  | `complexFromPolar`, `complexCis` | Polar construction and Euler's formula |
34
34
  | `complexExp`, `complexLog` | Exponential and principal logarithm |
35
- | `Quaternion`, `QUATERNION_IDENTITY` | `[x, y, z, w]` tuple and the unit |
36
- | `quaternionAdd`, `quaternionSub`, `quaternionNeg`, `quaternionMultiply` | Ring operations |
37
- | `quaternionConjugate`, `quaternionInverse` | Division-ring operations |
38
- | `quaternionLength`, `quaternionLengthSq`, `quaternionNormalize` | The ℍ norm and its unit form |
39
- | `quaternionDot`, `quaternionEquals`, `quaternionIsClose` | Inner product and comparison |
35
+ | `Quaternion`, `ReadonlyQuaternion` | `[x, y, z, w]` branded tuple, and its read-only view |
36
+ | `quaternionCreate`, `quaternionOf`, `quaternionClone`, `quaternionFromArray` | The only ways to make one; `FromArray` for untyped data |
37
+ | `quaternionSet`, `quaternionCopy`, `quaternionIdentity` | Write into an `out` |
38
+ | `quaternionAdd`, `quaternionSubtract`, `quaternionNegate`, `quaternionMultiplyScalar`, `quaternionMultiply` | Ring operations, `out` first |
39
+ | `quaternionConjugate`, `quaternionInvert`, `quaternionInvertScaled` | Division-ring operations |
40
+ | `quaternionLength`, `quaternionLengthSquared`, `quaternionNormalize` | The ℍ norm and its unit form |
41
+ | `quaternionLengthScaled`, `quaternionNormalizeScaled` | The same at any magnitude, beyond `1e±150` |
42
+ | `quaternionDot`, `quaternionEquals`, `quaternionIsClose`, `quaternionIsFinite` | Inner product, comparison and the finite check |
40
43
  | `ComplexNum`, `QuaternionNum` | Boxed field/ring values over ℂ and ℍ |
41
44
 
42
45
  `ComplexNum` and `QuaternionNum` box a value with its own field or ring API —
@@ -54,13 +57,78 @@ divisors even when the true quotient is perfectly representable. Smith's
54
57
  formulation divides by the larger component first, keeping every intermediate
55
58
  within range.
56
59
 
60
+ ## Quaternions
61
+
62
+ A quaternion is a plain array `[x, y, z, w]` — vector part first, scalar part
63
+ last, as glTF and the graphics APIs lay a rotation out — carrying a type-level
64
+ brand. The functions follow one standard:
65
+
66
+ - **Creators only.** `quaternionCreate()` (the identity), `quaternionOf(x, y, z,
67
+ w)`, `quaternionClone(q)` and `quaternionFromArray(out, source, offset?)` make a
68
+ quaternion. An array literal, a `number[]`, a `Float64Array` or any other
69
+ four-number value is rejected by the compiler, so `quaternionOf(0, 0, 0, 1)`
70
+ replaces `[0, 0, 0, 1]`. Constants such as the old `QUATERNION_IDENTITY` are
71
+ gone: a shared array could be written through; use `quaternionIdentity(out)`.
72
+ - **`out` first, alias-safe, no allocation.** Every operation writes into its
73
+ first argument and returns it, and that argument may be any of the inputs:
74
+ `quaternionMultiply(q, q, r)` is `q ← q · r`. Only the creators allocate; keep
75
+ them out of hot loops and reuse an `out`.
76
+ - **No throw.** Normalising the zero quaternion gives zero; inverting it gives
77
+ `NaN`; `NaN` propagates. Operations never check their arguments:
78
+ `quaternionIsFinite` is the check to run after parsing untrusted data, and
79
+ `quaternionFromArray` is the way in from JSON, messages or any array of unknown
80
+ origin — it stores `NaN` for an element that is not a number, never anything
81
+ else.
82
+ - **Plain arithmetic.** A product or a dot is rounded as written, not
83
+ compensated: within about four roundings of the exact value, relative to the
84
+ absolute values of its terms. The norm, the normalisation and the inverse
85
+ square the components, so they are right between about `1e-150` and `1e150`;
86
+ beyond that, `quaternionLengthScaled`, `quaternionNormalizeScaled` and
87
+ `quaternionInvertScaled` divide by the largest component first and cost about
88
+ three times as much.
89
+
90
+ Every creator copies a private array of non-integer doubles, so a quaternion is
91
+ a V8 `PACKED_DOUBLE_ELEMENTS` array even when its components are whole numbers.
92
+ That is what keeps the code that reads it fast, and it holds only while
93
+ nothing else is stored in one. For callers who bypass the types (JavaScript, a
94
+ cast, `any`):
95
+
96
+ - never store anything but a number in a quaternion, not even briefly;
97
+ - no holes, no `push`, no change of `length`;
98
+ - never pass a `Float64Array`, a hand-made array or any other array where a
99
+ quaternion is expected, even once, even in a test: the engine keeps type
100
+ feedback per function, so one such call slows every later call of that
101
+ function in the process (`quaternionFromArray`'s `source` is the one
102
+ parameter that takes any array);
103
+ - do not make one with `structuredClone` or `[...float64Array]` — use
104
+ `quaternionClone` or `quaternionFromArray`.
105
+
106
+ `JSON.parse`, `Response.json()` and `MessageEvent.data` are `any`, so the
107
+ compiler cannot stop them: pass them through `quaternionFromArray`. The
108
+ `~acKitMathType` property of the brand is reserved.
109
+
57
110
  ## Usage
58
111
 
59
112
  ```ts
60
- import { complexMul, complexModulus, COMPLEX_I } from "@ac-kit/math-complex";
113
+ import {
114
+ complexMul,
115
+ complexModulus,
116
+ COMPLEX_I,
117
+ quaternionCreate,
118
+ quaternionMultiply,
119
+ quaternionNormalize,
120
+ quaternionOf,
121
+ } from "@ac-kit/math-complex";
61
122
 
62
123
  complexMul(COMPLEX_I, COMPLEX_I); // [-1, 0]
63
124
  complexModulus([3, 4]); // 5
125
+
126
+ const i = quaternionOf(1, 0, 0, 0);
127
+ const j = quaternionOf(0, 1, 0, 0);
128
+ const out = quaternionCreate();
129
+ quaternionMultiply(out, i, j); // [0, 0, 1, 0]: ij = k
130
+ quaternionMultiply(out, j, i); // [0, 0, -1, 0]: ji = −k
131
+ quaternionNormalize(out, quaternionOf(0, 0, 0, 4)); // [0, 0, 0, 1]
64
132
  ```
65
133
 
66
134
  See the
@@ -0,0 +1,14 @@
1
+ /**
2
+ * The brand of every value type of the math packages: a property with a string
3
+ * key that is stable across versions, so two installed copies of a package (two
4
+ * dependents pinning different minors) stay assignable to each other, which a
5
+ * per-package `unique symbol` would not allow.
6
+ *
7
+ * Declared identically and internally in each package, never imported across
8
+ * packages: the structure is the identity. The key is reserved, and the brand
9
+ * costs nothing at run time.
10
+ */
11
+ export type Brand_<Name extends string> = {
12
+ readonly "~acKitMathType": Name;
13
+ };
14
+ //# sourceMappingURL=_brand.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_brand.d.ts","sourceRoot":"","sources":["../src/_brand.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,MAAM,MAAM,CAAC,IAAI,SAAS,MAAM,IAAI;IACzC,QAAQ,CAAC,gBAAgB,EAAE,IAAI,CAAC;CAChC,CAAC"}
package/dist/_brand.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=_brand.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_brand.js","sourceRoot":"","sources":["../src/_brand.ts"],"names":[],"mappings":""}
@@ -1,12 +1,15 @@
1
1
  import type { IRing } from "@ac-kit/math-algebra";
2
- import { Quaternion } from "./quaternion.js";
2
+ import { type Quaternion, type ReadonlyQuaternion } from "./quaternion.js";
3
3
  /**
4
4
  * A quaternion `a + bi + cj + dk`, boxed as a value with its own ring API.
5
5
  *
6
6
  * The contract shell over {@link Quaternion}. Every operation delegates to the
7
- * free functions in `quaternion.ts`; no arithmetic happens in this class. The
8
- * underlying tuple stores components as `[b, c, d, a]` — vector, then scalar;
9
- * {@link scalar} and {@link vector} present the `a + bi + cj + dk` reading.
7
+ * out-first functions in `quaternion.ts`; no arithmetic happens in this class,
8
+ * which allocates one tuple per operation, so it is for algebra written against
9
+ * `IRing`, not for loops. The underlying tuple stores components as `[b, c, d,
10
+ * a]` — vector, then scalar; {@link scalar} and {@link vector} present the `a +
11
+ * bi + cj + dk` reading. A value never changes: the tuples that go in and out
12
+ * are copies.
10
13
  */
11
14
  export declare class QuaternionNum implements IRing<QuaternionNum> {
12
15
  #private;
@@ -15,11 +18,11 @@ export declare class QuaternionNum implements IRing<QuaternionNum> {
15
18
  static readonly IDENTITY: QuaternionNum;
16
19
  /** Creates a quaternion from its scalar part and its `i, j, k` vector part. */
17
20
  static from(scalar: number, vector: readonly [number, number, number]): QuaternionNum;
18
- /** Wraps an already-computed {@link Quaternion} tuple `[b, c, d, a]`. */
19
- static fromTuple(value: Quaternion): QuaternionNum;
21
+ /** Wraps a copy of an already-computed {@link Quaternion} tuple `[b, c, d, a]`. */
22
+ static fromTuple(value: ReadonlyQuaternion): QuaternionNum;
20
23
  /**
21
- * The underlying `[b, c, d, a]` tuple, for callers working at the arithmetic
22
- * layer.
24
+ * A copy of the underlying `[b, c, d, a]` tuple, for callers working at the
25
+ * arithmetic layer.
23
26
  */
24
27
  toTuple(): Quaternion;
25
28
  /** Scalar (real) part: the `a` in `a + bi + cj + dk`. */
@@ -31,12 +34,17 @@ export declare class QuaternionNum implements IRing<QuaternionNum> {
31
34
  * part; leaves the scalar part unchanged.
32
35
  */
33
36
  conj(): QuaternionNum;
34
- /** Norm `‖q‖ = √(a² + b² + c² + d²)`. Always non-negative. */
37
+ /**
38
+ * Norm `‖q‖ = √(a² + b² + c² + d²)`. Always non-negative, and right at any
39
+ * magnitude, `1e-200` and `1e200` included.
40
+ */
35
41
  norm(): number;
36
42
  /**
37
- * Multiplicative inverse `q⁻¹ = conj(q) / ‖q‖²`.
43
+ * Multiplicative inverse `q⁻¹ = conj(q) / ‖q‖²`, at any magnitude where it
44
+ * exists: `1e-200` has the inverse `1e200`.
38
45
  *
39
- * @throws When called on the zero quaternion.
46
+ * @throws {RangeError} When called on the zero quaternion, the only one
47
+ * without an inverse.
40
48
  */
41
49
  inv(): QuaternionNum;
42
50
  add(other: QuaternionNum): QuaternionNum;
@@ -1 +1 @@
1
- {"version":3,"file":"quaternion-num.d.ts","sourceRoot":"","sources":["../../src/quaternion/quaternion-num.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAElD,OAAO,EAEN,UAAU,EAQV,MAAM,iBAAiB,CAAC;AAEzB;;;;;;;GAOG;AACH,qBAAa,aAAc,YAAW,KAAK,CAAC,aAAa,CAAC;;IAGzD,OAAO,eAEN;IAED,yCAAyC;IACzC,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAErC;IAEF,+EAA+E;IAC/E,MAAM,CAAC,IAAI,CACV,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,GACvC,aAAa,CAEf;IAED,yEAAyE;IACzE,MAAM,CAAC,SA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IAED,yDAAyD;IACzD,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED,+EAA+E;IAC/E,IAAI,MAAM,IAAI,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAE9C;IAED;;;OAGG;IACH,IAAI,IAAI,aAAa,CAIpB;IAED;;;OAGG;IACH,IAAI,IAAI,MAAM,CAEb;IAED;;;;;;OAMG;IACH,GAAG,IAAI,aAAa,CAOnB;IAED,GAAG,CAAC,KAAK,EAAE,aAAa,GAAG,aAAa,CAIvC;IAED,GAAG,CAAC,KAAK,EAAE,aAAa,GAAG,aAAa,CAIvC;IAED,GAAG,IAAI,aAAa,CAEnB;IAED,yDAAyD;IACzD,GAAG,CAAC,KAAK,EAAE,aAAa,GAAG,aAAa,CAIvC;CACD"}
@@ -1,11 +1,14 @@
1
- import { QUATERNION_IDENTITY, quaternionAdd, quaternionConjugate, quaternionInverse, quaternionLength, quaternionMultiply, quaternionNeg, quaternionSub, } from "./quaternion.js";
1
+ import { quaternionAdd, quaternionClone, quaternionConjugate, quaternionCreate, quaternionInvertScaled, quaternionLengthScaled, quaternionMultiply, quaternionNegate, quaternionOf, quaternionSubtract, } from "./quaternion.js";
2
2
  /**
3
3
  * A quaternion `a + bi + cj + dk`, boxed as a value with its own ring API.
4
4
  *
5
5
  * The contract shell over {@link Quaternion}. Every operation delegates to the
6
- * free functions in `quaternion.ts`; no arithmetic happens in this class. The
7
- * underlying tuple stores components as `[b, c, d, a]` — vector, then scalar;
8
- * {@link scalar} and {@link vector} present the `a + bi + cj + dk` reading.
6
+ * out-first functions in `quaternion.ts`; no arithmetic happens in this class,
7
+ * which allocates one tuple per operation, so it is for algebra written against
8
+ * `IRing`, not for loops. The underlying tuple stores components as `[b, c, d,
9
+ * a]` — vector, then scalar; {@link scalar} and {@link vector} present the `a +
10
+ * bi + cj + dk` reading. A value never changes: the tuples that go in and out
11
+ * are copies.
9
12
  */
10
13
  export class QuaternionNum {
11
14
  #value;
@@ -13,21 +16,21 @@ export class QuaternionNum {
13
16
  this.#value = value;
14
17
  }
15
18
  /** The quaternion `1 + 0i + 0j + 0k`. */
16
- static IDENTITY = new QuaternionNum(QUATERNION_IDENTITY);
19
+ static IDENTITY = new QuaternionNum(quaternionCreate());
17
20
  /** Creates a quaternion from its scalar part and its `i, j, k` vector part. */
18
21
  static from(scalar, vector) {
19
- return new QuaternionNum([vector[0], vector[1], vector[2], scalar]);
22
+ return new QuaternionNum(quaternionOf(vector[0], vector[1], vector[2], scalar));
20
23
  }
21
- /** Wraps an already-computed {@link Quaternion} tuple `[b, c, d, a]`. */
24
+ /** Wraps a copy of an already-computed {@link Quaternion} tuple `[b, c, d, a]`. */
22
25
  static fromTuple(value) {
23
- return new QuaternionNum(value);
26
+ return new QuaternionNum(quaternionClone(value));
24
27
  }
25
28
  /**
26
- * The underlying `[b, c, d, a]` tuple, for callers working at the arithmetic
27
- * layer.
29
+ * A copy of the underlying `[b, c, d, a]` tuple, for callers working at the
30
+ * arithmetic layer.
28
31
  */
29
32
  toTuple() {
30
- return this.#value;
33
+ return quaternionClone(this.#value);
31
34
  }
32
35
  /** Scalar (real) part: the `a` in `a + bi + cj + dk`. */
33
36
  get scalar() {
@@ -42,32 +45,40 @@ export class QuaternionNum {
42
45
  * part; leaves the scalar part unchanged.
43
46
  */
44
47
  conj() {
45
- return new QuaternionNum(quaternionConjugate(this.#value));
48
+ return new QuaternionNum(quaternionConjugate(quaternionCreate(), this.#value));
46
49
  }
47
- /** Norm `‖q‖ = √(a² + b² + c² + d²)`. Always non-negative. */
50
+ /**
51
+ * Norm `‖q‖ = √(a² + b² + c² + d²)`. Always non-negative, and right at any
52
+ * magnitude, `1e-200` and `1e200` included.
53
+ */
48
54
  norm() {
49
- return quaternionLength(this.#value);
55
+ return quaternionLengthScaled(this.#value);
50
56
  }
51
57
  /**
52
- * Multiplicative inverse `q⁻¹ = conj(q) / ‖q‖²`.
58
+ * Multiplicative inverse `q⁻¹ = conj(q) / ‖q‖²`, at any magnitude where it
59
+ * exists: `1e-200` has the inverse `1e200`.
53
60
  *
54
- * @throws When called on the zero quaternion.
61
+ * @throws {RangeError} When called on the zero quaternion, the only one
62
+ * without an inverse.
55
63
  */
56
64
  inv() {
57
- return new QuaternionNum(quaternionInverse(this.#value));
65
+ if (quaternionLengthScaled(this.#value) === 0) {
66
+ throw new RangeError("Cannot invert a zero-length quaternion.");
67
+ }
68
+ return new QuaternionNum(quaternionInvertScaled(quaternionCreate(), this.#value));
58
69
  }
59
70
  add(other) {
60
- return new QuaternionNum(quaternionAdd(this.#value, other.#value));
71
+ return new QuaternionNum(quaternionAdd(quaternionCreate(), this.#value, other.#value));
61
72
  }
62
73
  sub(other) {
63
- return new QuaternionNum(quaternionSub(this.#value, other.#value));
74
+ return new QuaternionNum(quaternionSubtract(quaternionCreate(), this.#value, other.#value));
64
75
  }
65
76
  neg() {
66
- return new QuaternionNum(quaternionNeg(this.#value));
77
+ return new QuaternionNum(quaternionNegate(quaternionCreate(), this.#value));
67
78
  }
68
79
  /** Hamilton product `this · other` — non-commutative. */
69
80
  mul(other) {
70
- return new QuaternionNum(quaternionMultiply(this.#value, other.#value));
81
+ return new QuaternionNum(quaternionMultiply(quaternionCreate(), this.#value, other.#value));
71
82
  }
72
83
  }
73
84
  //# sourceMappingURL=quaternion-num.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"quaternion-num.js","sourceRoot":"","sources":["../../src/quaternion/quaternion-num.ts"],"names":[],"mappings":"AAEA,OAAO,EACN,mBAAmB,EAEnB,aAAa,EACb,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,aAAa,EACb,aAAa,GACb,MAAM,iBAAiB,CAAC;AAEzB;;;;;;;GAOG;AACH,MAAM,OAAO,aAAa;IAChB,MAAM,CAAa;IAE5B,YAAoB,KAAiB;QACpC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACrB,CAAC;IAED,yCAAyC;IACzC,MAAM,CAAU,QAAQ,GAAkB,I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,OAAO,IAAI,aAAa,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;IACpE,CAAC;IAED,GAAG;QACF,OAAO,IAAI,aAAa,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IACtD,CAAC;IAED,yDAAyD;IACzD,GAAG,CAAC,KAAoB;QACvB,OAAO,IAAI,aAAa,CAAC,kBAAkB,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;IACzE,CAAC;CACD"}
1
+ {"version":3,"file":"quaternion-num.js","sourceRoot":"","sources":["../../src/quaternion/quaternion-num.ts"],"names":[],"mappings":"AAEA,OAAO,EAEN,aAAa,EACb,eAAe,EACf,mBAAmB,EACnB,gBAAgB,EAChB,sBAAsB,EACtB,sBAAsB,EACtB,kBAAkB,EAClB,gBAAgB,EAChB,YAAY,EACZ,kBAAkB,GAElB,MAAM,iBAAiB,CAAC;AAEzB;;;;;;;;;;GAUG;AACH,MAAM,OAAO,aAAa;IAChB,MAAM,CAAa;IAE5B,YAAoB,KAAiB;QACpC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACrB,CAAC;IAED,yCAAyC;IACzC,MAAM,CAAU,QAAQ,GAAkB,IAAI,aAAa,CAC1D,gBAAgB,EAAE,CAClB,CAAC;IAEF,+EAA+E;IAC/E,MAAM,CAAC,IAAI,CACV,MAAc,EACd,MAAyC;QAEzC,OAAO,IAAI,aAAa,CACvB,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CACrD,CAAC;IACH,CAAC;IAED,mFAAmF;IACnF,MAAM,CAAC,SAAS,CAAC,KAAyB;QACzC,OAAO,IAAI,aAAa,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC;IAClD,CAAC;IAED;;;OAGG;I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B,CAAC,gBAAgB,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IAC7E,CAAC;IAED,yDAAyD;IACzD,GAAG,CAAC,KAAoB;QACvB,OAAO,IAAI,aAAa,CACvB,kBAAkB,CAAC,gBAAgB,EAAE,EAAE,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CACjE,CAAC;IACH,CAAC;CACD"}
@@ -1,11 +1,152 @@
1
1
  import { type IsCloseToOptions } from "@ac-kit/core";
2
- export type Quaternion = [number, number, number, number];
3
- export declare const QUATERNION_IDENTITY: [0, 0, 0, 1];
4
- export declare function quaternionAdd(q1: Quaternion, q2: Quaternion): Quaternion;
5
- export declare function quaternionSub(q1: Quaternion, q2: Quaternion): Quaternion;
6
- export declare function quaternionNeg(q: Quaternion): Quaternion;
7
- export declare function quaternionConjugate(q: Quaternion): Quaternion;
8
- export declare function quaternionDot(q1: Quaternion, q2: Quaternion): number;
2
+ import type { Brand_ } from "../_brand.js";
3
+ /**
4
+ * A quaternion `x·i + y·j + z·k + w`, stored as `[x, y, z, w]`: the vector part
5
+ * first, the scalar part last, as glTF and every graphics API lay a rotation
6
+ * out. A plain array of four binary64 numbers carrying a type-level brand, so
7
+ * an array literal, a `number[]`, a `Float64Array` or a vector of four numbers
8
+ * is rejected where a quaternion is expected.
9
+ *
10
+ * Only {@link quaternionCreate}, {@link quaternionOf}, {@link quaternionClone},
11
+ * {@link quaternionFromArray} and the functions that write an `out` make one.
12
+ * They all start from an array of non-integer doubles, so every quaternion is
13
+ * `PACKED_DOUBLE_ELEMENTS` in V8 even when its components are whole numbers,
14
+ * and the hot loops that read it stay monomorphic. A literal such as `[0, 0, 0,
15
+ * 1]` is an array of small integers instead, and storing one into a shared
16
+ * `out` turns it into a generic array for good.
17
+ *
18
+ * Rules for callers who bypass the types (JavaScript, casts, `any`): never
19
+ * store anything but a number in a quaternion, not even briefly; no holes, no
20
+ * `push`, no change of `length`; and do not make one with `structuredClone` or
21
+ * `[...float64Array]` (use {@link quaternionClone},
22
+ * {@link quaternionFromArray}).
23
+ */
24
+ export type Quaternion = [x: number, y: number, z: number, w: number] & Brand_<"Quaternion">;
25
+ /** A {@link Quaternion} that is only read. */
26
+ export type ReadonlyQuaternion = readonly [
27
+ x: number,
28
+ y: number,
29
+ z: number,
30
+ w: number
31
+ ] & Brand_<"Quaternion">;
32
+ /**
33
+ * Creates the identity quaternion `[0, 0, 0, 1]`.
34
+ *
35
+ * Allocates; keep it out of hot loops.
36
+ */
37
+ export declare function quaternionCreate(): Quaternion;
38
+ /**
39
+ * Creates the quaternion `x·i + y·j + z·k + w`.
40
+ *
41
+ * Allocates; keep it out of hot loops.
42
+ */
43
+ export declare function quaternionOf(x: number, y: number, z: number, w: number): Quaternion;
44
+ /**
45
+ * Creates a copy of `q`. Like every creator it starts from a clean array, so a
46
+ * clone of an array of small integers is an array of doubles.
47
+ *
48
+ * Allocates; keep it out of hot loops.
49
+ */
50
+ export declare function quaternionClone(q: ReadonlyQuaternion): Quaternion;
51
+ /**
52
+ * The checked way in from untyped data (JSON, messages, arrays of unknown
53
+ * origin): `source[offset … offset + 4)` copied into `out`, each element that
54
+ * is not a number written as `NaN`, an index past the end of `source` too, so
55
+ * `out` never holds a non-number. Test the result with
56
+ * {@link quaternionIsFinite} when `NaN` must not get through. O(1) time, O(1)
57
+ * memory.
58
+ *
59
+ * `source` may be `out` itself: the four elements are read before the first
60
+ * write.
61
+ *
62
+ * @param out The quaternion to fill.
63
+ * @param source The array to read, of any length and any content.
64
+ * @param offset The index of the `x` component in `source`.
65
+ * @returns `out`.
66
+ */
67
+ export declare function quaternionFromArray(out: Quaternion, source: ArrayLike<number>, offset?: number): Quaternion;
68
+ /** Writes `x·i + y·j + z·k + w` into `out`. */
69
+ export declare function quaternionSet(out: Quaternion, x: number, y: number, z: number, w: number): Quaternion;
70
+ /** Writes a copy of `q` into `out`. */
71
+ export declare function quaternionCopy(out: Quaternion, q: ReadonlyQuaternion): Quaternion;
72
+ /** Writes the identity quaternion `[0, 0, 0, 1]` into `out`. */
73
+ export declare function quaternionIdentity(out: Quaternion): Quaternion;
74
+ /** Writes `a + b` into `out`. `out` may be `a` or `b`. */
75
+ export declare function quaternionAdd(out: Quaternion, a: ReadonlyQuaternion, b: ReadonlyQuaternion): Quaternion;
76
+ /** Writes `a − b` into `out`. `out` may be `a` or `b`. */
77
+ export declare function quaternionSubtract(out: Quaternion, a: ReadonlyQuaternion, b: ReadonlyQuaternion): Quaternion;
78
+ /** Writes `q · scalar` into `out`. `out` may be `q`. */
79
+ export declare function quaternionMultiplyScalar(out: Quaternion, q: ReadonlyQuaternion, scalar: number): Quaternion;
80
+ /** Writes `−q` into `out`, the same rotation as `q`. `out` may be `q`. */
81
+ export declare function quaternionNegate(out: Quaternion, q: ReadonlyQuaternion): Quaternion;
82
+ /**
83
+ * Writes the Hamilton product `a · b` into `out`: `b` is applied first when
84
+ * both are rotations. Not commutative. `out` may be `a` or `b`.
85
+ *
86
+ * Plain arithmetic: each component is within about four roundings (`4·2⁻⁵³`) of
87
+ * the exact value, relative to the sum of the absolute values of its four
88
+ * terms, so it can lose every digit where the terms cancel.
89
+ */
90
+ export declare function quaternionMultiply(out: Quaternion, a: ReadonlyQuaternion, b: ReadonlyQuaternion): Quaternion;
91
+ /**
92
+ * Writes the conjugate `−x·i − y·j − z·k + w` into `out`: the inverse of a unit
93
+ * quaternion, and its rotation reversed. `out` may be `q`.
94
+ */
95
+ export declare function quaternionConjugate(out: Quaternion, q: ReadonlyQuaternion): Quaternion;
96
+ /**
97
+ * Writes the inverse, the conjugate divided by `|q|²`, into `out`, so that `q ·
98
+ * q⁻¹` is the identity. The zero quaternion has no inverse: the components
99
+ * written are `NaN`. Where a component is beyond about `1e±150` the squared
100
+ * length overflows, underflows or loses its digits to the subnormal range, and
101
+ * the result is zeros, infinities or wrong: use {@link quaternionInvertScaled}.
102
+ * `out` may be `q`.
103
+ */
104
+ export declare function quaternionInvert(out: Quaternion, q: ReadonlyQuaternion): Quaternion;
105
+ /**
106
+ * Writes `q / |q|` into `out`: a unit quaternion, the same rotation. The zero
107
+ * quaternion stays zero, and `NaN` components make every component `NaN`. Where
108
+ * a component is beyond about `1e±150` the squared length overflows, underflows
109
+ * or loses its digits to the subnormal range, and the result is zeros or wrong
110
+ * (`1e-161` comes out as `1.006`): use {@link quaternionNormalizeScaled}. `out`
111
+ * may be `q`.
112
+ */
113
+ export declare function quaternionNormalize(out: Quaternion, q: ReadonlyQuaternion): Quaternion;
114
+ /**
115
+ * The inner product of the four components. For two unit quaternions it is the
116
+ * cosine of half the angle between the rotations (up to the sign of either).
117
+ * Plain arithmetic.
118
+ */
119
+ export declare function quaternionDot(a: ReadonlyQuaternion, b: ReadonlyQuaternion): number;
120
+ /**
121
+ * The norm `√(x² + y² + z² + w²)`. Outside about `1e±150` see
122
+ * {@link quaternionLengthScaled}.
123
+ */
124
+ export declare function quaternionLength(q: ReadonlyQuaternion): number;
125
+ /**
126
+ * The norm at any magnitude: every component is divided by the largest first,
127
+ * so the squares stay in range, where {@link quaternionLength} returns `0` or
128
+ * `Infinity` beyond about `1e±150`. Zero for the zero quaternion, `Infinity`
129
+ * for an infinite component, `NaN` for `NaN`. About three times the cost.
130
+ */
131
+ export declare function quaternionLengthScaled(q: ReadonlyQuaternion): number;
132
+ /**
133
+ * Writes `q / |q|` into `out` at any magnitude, subnormal and near the largest
134
+ * binary64 included: the components are divided by the largest first, so the
135
+ * squares stay in range (see {@link quaternionNormalize} for the plain form).
136
+ * The zero quaternion stays zero; `NaN` and infinite components make every
137
+ * component `NaN`. About three times the cost. `out` may be `q`.
138
+ */
139
+ export declare function quaternionNormalizeScaled(out: Quaternion, q: ReadonlyQuaternion): Quaternion;
140
+ /**
141
+ * Writes the inverse into `out` at any magnitude where it exists: the
142
+ * components are divided by the largest first, so a quaternion of `1e-200` has
143
+ * the inverse `1e200` where {@link quaternionInvert} has no digit left. The zero
144
+ * quaternion, `NaN` and infinite components give `NaN`; an inverse beyond the
145
+ * binary64 range is `Infinity`. About three times the cost. `out` may be `q`.
146
+ */
147
+ export declare function quaternionInvertScaled(out: Quaternion, q: ReadonlyQuaternion): Quaternion;
148
+ /** The squared norm `x² + y² + z² + w²`, without the square root. */
149
+ export declare function quaternionLengthSquared(q: ReadonlyQuaternion): number;
9
150
  /**
10
151
  * Exact component-wise equality. See {@link quaternionIsClose} for a tolerant
11
152
  * test.
@@ -13,20 +154,20 @@ export declare function quaternionDot(q1: Quaternion, q2: Quaternion): number;
13
154
  * Compares the four components, so `q` and `-q` are not equal even though they
14
155
  * denote the same rotation.
15
156
  */
16
- export declare function quaternionEquals(q1: Quaternion, q2: Quaternion): boolean;
157
+ export declare function quaternionEquals(a: ReadonlyQuaternion, b: ReadonlyQuaternion): boolean;
17
158
  /**
18
159
  * Component-wise approximate equality.
19
160
  *
20
161
  * Not transitive, so it is not an equality in the sense a `Set` or `Map` needs,
21
162
  * and never a basis for ordering — use {@link quaternionEquals} there. Like the
22
163
  * exact form it compares components, so `q` and `-q` are not close even though
23
- * they denote the same rotation; compare `|quaternionDot(q1, q2)|` against `1`
24
- * to test the rotations instead.
25
- */
26
- export declare function quaternionIsClose(q1: Quaternion, q2: Quaternion, tolerance: IsCloseToOptions): boolean;
27
- export declare function quaternionInverse(q: Quaternion): Quaternion;
28
- export declare function quaternionLength(q: Quaternion): number;
29
- export declare function quaternionLengthSq(q: Quaternion): number;
30
- export declare function quaternionMultiply(q1: Quaternion, q2: Quaternion): Quaternion;
31
- export declare function quaternionNormalize(q: Quaternion): Quaternion;
164
+ * they denote the same rotation; compare `|quaternionDot(a, b)|` against `1` to
165
+ * test the rotations instead.
166
+ */
167
+ export declare function quaternionIsClose(a: ReadonlyQuaternion, b: ReadonlyQuaternion, options: IsCloseToOptions): boolean;
168
+ /**
169
+ * Whether all four components are finite numbers: the check to run after
170
+ * parsing untrusted data or before an upload, as operations never check.
171
+ */
172
+ export declare function quaternionIsFinite(q: ReadonlyQuaternion): boolean;
32
173
  //# sourceM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nB,MAAM,CAER;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,kBAAkB,GAAG,MAAM,CAE9D;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,EAAE,kBAAkB,GAAG,MAAM,CAUpE;AAED;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CACxC,GAAG,EAAE,UAAU,EACf,CAAC,EAAE,kBAAkB,GACnB,UAAU,CAeZ;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACrC,GAAG,EAAE,UAAU,EACf,CAAC,EAAE,kBAAkB,GACnB,UAAU,CAYZ;AAED,qEAAqE;AACrE,wBAAgB,uBAAuB,CAAC,CAAC,EAAE,kBAAkB,GAAG,MAAM,CAErE;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC/B,CAAC,EAAE,kBAAkB,EACrB,CAAC,EAAE,kBAAkB,GACnB,OAAO,CAET;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAChC,CAAC,EAAE,kBAAkB,EACrB,CAAC,EAAE,kBAAkB,EACrB,OAAO,EAAE,gBAAgB,GACvB,OAAO,CAOT;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAOjE"}
@@ -1,20 +1,302 @@
1
- import { isCloseTo } from "@ac-kit/core";
2
- import { diffOfProducts, dotPrecise, sumOfProducts } from "@ac-kit/math-scalar";
3
- export const QUATERNION_IDENTITY = [0, 0, 0, 1];
4
- export function quaternionAdd(q1, q2) {
5
- return [q1[0] + q2[0], q1[1] + q2[1], q1[2] + q2[2], q1[3] + q2[3]];
1
+ import { isCloseTo, numberOrNaN } 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
+ * `source[index]` if the index is inside `source` and holds a number; else
9
+ * `NaN`.
10
+ */
11
+ function numberAt_(source, index) {
12
+ return index >= 0 && index < source.length
13
+ ? numberOrNaN(source[index])
14
+ : Number.NaN;
15
+ }
16
+ /** The largest absolute component; `NaN` if one is `NaN`. */
17
+ function largestMagnitude_(q) {
18
+ return Math.max(Math.abs(q[0]), Math.abs(q[1]), Math.abs(q[2]), Math.abs(q[3]));
19
+ }
20
+ /**
21
+ * Creates the identity quaternion `[0, 0, 0, 1]`.
22
+ *
23
+ * Allocates; keep it out of hot loops.
24
+ */
25
+ export function quaternionCreate() {
26
+ const out = TEMPLATE_.slice();
27
+ out[0] = 0;
28
+ out[1] = 0;
29
+ out[2] = 0;
30
+ out[3] = 1;
31
+ return out;
32
+ }
33
+ /**
34
+ * Creates the quaternion `x·i + y·j + z·k + w`.
35
+ *
36
+ * Allocates; keep it out of hot loops.
37
+ */
38
+ export function quaternionOf(x, y, z, w) {
39
+ const out = TEMPLATE_.slice();
40
+ out[0] = x;
41
+ out[1] = y;
42
+ out[2] = z;
43
+ out[3] = w;
44
+ return out;
45
+ }
46
+ /**
47
+ * Creates a copy of `q`. Like every creator it starts from a clean array, so a
48
+ * clone of an array of small integers is an array of doubles.
49
+ *
50
+ * Allocates; keep it out of hot loops.
51
+ */
52
+ export function quaternionClone(q) {
53
+ const out = TEMPLATE_.slice();
54
+ out[0] = q[0];
55
+ out[1] = q[1];
56
+ out[2] = q[2];
57
+ out[3] = q[3];
58
+ return out;
6
59
  }
7
- export function quaternionSub(q1, q2) {
8
- return [q1[0] - q2[0], q1[1] - q2[1], q1[2] - q2[2], q1[3] - q2[3]];
60
+ /**
61
+ * The checked way in from untyped data (JSON, messages, arrays of unknown
62
+ * origin): `source[offset … offset + 4)` copied into `out`, each element that
63
+ * is not a number written as `NaN`, an index past the end of `source` too, so
64
+ * `out` never holds a non-number. Test the result with
65
+ * {@link quaternionIsFinite} when `NaN` must not get through. O(1) time, O(1)
66
+ * memory.
67
+ *
68
+ * `source` may be `out` itself: the four elements are read before the first
69
+ * write.
70
+ *
71
+ * @param out The quaternion to fill.
72
+ * @param source The array to read, of any length and any content.
73
+ * @param offset The index of the `x` component in `source`.
74
+ * @returns `out`.
75
+ */
76
+ export function quaternionFromArray(out, source, offset = 0) {
77
+ const x = numberAt_(source, offset);
78
+ const y = numberAt_(source, offset + 1);
79
+ const z = numberAt_(source, offset + 2);
80
+ const w = numberAt_(source, offset + 3);
81
+ out[0] = x;
82
+ out[1] = y;
83
+ out[2] = z;
84
+ out[3] = w;
85
+ return out;
86
+ }
87
+ /** Writes `x·i + y·j + z·k + w` into `out`. */
88
+ export function quaternionSet(out, x, y, z, w) {
89
+ out[0] = x;
90
+ out[1] = y;
91
+ out[2] = z;
92
+ out[3] = w;
93
+ return out;
9
94
  }
10
- export function quaternionNeg(q) {
11
- return [-q[0], -q[1], -q[2], -q[3]];
95
+ /** Writes a copy of `q` into `out`. */
96
+ export function quaternionCopy(out, q) {
97
+ const x = q[0];
98
+ const y = q[1];
99
+ const z = q[2];
100
+ const w = q[3];
101
+ out[0] = x;
102
+ out[1] = y;
103
+ out[2] = z;
104
+ out[3] = w;
105
+ return out;
12
106
  }
13
- export function quaternionConjugate(q) {
14
- return [-q[0], -q[1], -q[2], q[3]];
107
+ /** Writes the identity quaternion `[0, 0, 0, 1]` into `out`. */
108
+ export function quaternionIdentity(out) {
109
+ out[0] = 0;
110
+ out[1] = 0;
111
+ out[2] = 0;
112
+ out[3] = 1;
113
+ return out;
15
114
  }
16
- export function quaternionDot(q1, q2) {
17
- return dotPrecise(q1, q2);
115
+ /** Writes `a + b` into `out`. `out` may be `a` or `b`. */
116
+ export function quaternionAdd(out, a, b) {
117
+ out[0] = a[0] + b[0];
118
+ out[1] = a[1] + b[1];
119
+ out[2] = a[2] + b[2];
120
+ out[3] = a[3] + b[3];
121
+ return out;
122
+ }
123
+ /** Writes `a − b` into `out`. `out` may be `a` or `b`. */
124
+ export function quaternionSubtract(out, a, b) {
125
+ out[0] = a[0] - b[0];
126
+ out[1] = a[1] - b[1];
127
+ out[2] = a[2] - b[2];
128
+ out[3] = a[3] - b[3];
129
+ return out;
130
+ }
131
+ /** Writes `q · scalar` into `out`. `out` may be `q`. */
132
+ export function quaternionMultiplyScalar(out, q, scalar) {
133
+ out[0] = q[0] * scalar;
134
+ out[1] = q[1] * scalar;
135
+ out[2] = q[2] * scalar;
136
+ out[3] = q[3] * scalar;
137
+ return out;
138
+ }
139
+ /** Writes `−q` into `out`, the same rotation as `q`. `out` may be `q`. */
140
+ export function quaternionNegate(out, q) {
141
+ out[0] = -q[0];
142
+ out[1] = -q[1];
143
+ out[2] = -q[2];
144
+ out[3] = -q[3];
145
+ return out;
146
+ }
147
+ /**
148
+ * Writes the Hamilton product `a · b` into `out`: `b` is applied first when
149
+ * both are rotations. Not commutative. `out` may be `a` or `b`.
150
+ *
151
+ * Plain arithmetic: each component is within about four roundings (`4·2⁻⁵³`) of
152
+ * the exact value, relative to the sum of the absolute values of its four
153
+ * terms, so it can lose every digit where the terms cancel.
154
+ */
155
+ export function quaternionMultiply(out, a, b) {
156
+ const ax = a[0];
157
+ const ay = a[1];
158
+ const az = a[2];
159
+ const aw = a[3];
160
+ const bx = b[0];
161
+ const by = b[1];
162
+ const bz = b[2];
163
+ const bw = b[3];
164
+ out[0] = aw * bx + ax * bw + ay * bz - az * by;
165
+ out[1] = aw * by - ax * bz + ay * bw + az * bx;
166
+ out[2] = aw * bz + ax * by - ay * bx + az * bw;
167
+ out[3] = aw * bw - ax * bx - ay * by - az * bz;
168
+ return out;
169
+ }
170
+ /**
171
+ * Writes the conjugate `−x·i − y·j − z·k + w` into `out`: the inverse of a unit
172
+ * quaternion, and its rotation reversed. `out` may be `q`.
173
+ */
174
+ export function quaternionConjugate(out, q) {
175
+ out[0] = -q[0];
176
+ out[1] = -q[1];
177
+ out[2] = -q[2];
178
+ out[3] = q[3];
179
+ return out;
180
+ }
181
+ /**
182
+ * Writes the inverse, the conjugate divided by `|q|²`, into `out`, so that `q ·
183
+ * q⁻¹` is the identity. The zero quaternion has no inverse: the components
184
+ * written are `NaN`. Where a component is beyond about `1e±150` the squared
185
+ * length overflows, underflows or loses its digits to the subnormal range, and
186
+ * the result is zeros, infinities or wrong: use {@link quaternionInvertScaled}.
187
+ * `out` may be `q`.
188
+ */
189
+ export function quaternionInvert(out, q) {
190
+ const x = q[0];
191
+ const y = q[1];
192
+ const z = q[2];
193
+ const w = q[3];
194
+ const lengthSquared = x * x + y * y + z * z + w * w;
195
+ out[0] = -x / lengthSquared;
196
+ out[1] = -y / lengthSquared;
197
+ out[2] = -z / lengthSquared;
198
+ out[3] = w / lengthSquared;
199
+ return out;
200
+ }
201
+ /**
202
+ * Writes `q / |q|` into `out`: a unit quaternion, the same rotation. The zero
203
+ * quaternion stays zero, and `NaN` components make every component `NaN`. Where
204
+ * a component is beyond about `1e±150` the squared length overflows, underflows
205
+ * or loses its digits to the subnormal range, and the result is zeros or wrong
206
+ * (`1e-161` comes out as `1.006`): use {@link quaternionNormalizeScaled}. `out`
207
+ * may be `q`.
208
+ */
209
+ export function quaternionNormalize(out, q) {
210
+ const x = q[0];
211
+ const y = q[1];
212
+ const z = q[2];
213
+ const w = q[3];
214
+ const lengthSquared = x * x + y * y + z * z + w * w;
215
+ const scale = lengthSquared === 0 ? 0 : 1 / Math.sqrt(lengthSquared);
216
+ out[0] = x * scale;
217
+ out[1] = y * scale;
218
+ out[2] = z * scale;
219
+ out[3] = w * scale;
220
+ return out;
221
+ }
222
+ /**
223
+ * The inner product of the four components. For two unit quaternions it is the
224
+ * cosine of half the angle between the rotations (up to the sign of either).
225
+ * Plain arithmetic.
226
+ */
227
+ export function quaternionDot(a, b) {
228
+ return a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3];
229
+ }
230
+ /**
231
+ * The norm `√(x² + y² + z² + w²)`. Outside about `1e±150` see
232
+ * {@link quaternionLengthScaled}.
233
+ */
234
+ export function quaternionLength(q) {
235
+ return Math.sqrt(q[0] * q[0] + q[1] * q[1] + q[2] * q[2] + q[3] * q[3]);
236
+ }
237
+ /**
238
+ * The norm at any magnitude: every component is divided by the largest first,
239
+ * so the squares stay in range, where {@link quaternionLength} returns `0` or
240
+ * `Infinity` beyond about `1e±150`. Zero for the zero quaternion, `Infinity`
241
+ * for an infinite component, `NaN` for `NaN`. About three times the cost.
242
+ */
243
+ export function quaternionLengthScaled(q) {
244
+ const largest = largestMagnitude_(q);
245
+ if (largest === 0 || largest === Infinity) {
246
+ return largest;
247
+ }
248
+ const x = q[0] / largest;
249
+ const y = q[1] / largest;
250
+ const z = q[2] / largest;
251
+ const w = q[3] / largest;
252
+ return largest * Math.sqrt(x * x + y * y + z * z + w * w);
253
+ }
254
+ /**
255
+ * Writes `q / |q|` into `out` at any magnitude, subnormal and near the largest
256
+ * binary64 included: the components are divided by the largest first, so the
257
+ * squares stay in range (see {@link quaternionNormalize} for the plain form).
258
+ * The zero quaternion stays zero; `NaN` and infinite components make every
259
+ * component `NaN`. About three times the cost. `out` may be `q`.
260
+ */
261
+ export function quaternionNormalizeScaled(out, q) {
262
+ const largest = largestMagnitude_(q);
263
+ if (largest === 0) {
264
+ return quaternionSet(out, 0, 0, 0, 0);
265
+ }
266
+ const x = q[0] / largest;
267
+ const y = q[1] / largest;
268
+ const z = q[2] / largest;
269
+ const w = q[3] / largest;
270
+ const scale = 1 / Math.sqrt(x * x + y * y + z * z + w * w);
271
+ out[0] = x * scale;
272
+ out[1] = y * scale;
273
+ out[2] = z * scale;
274
+ out[3] = w * scale;
275
+ return out;
276
+ }
277
+ /**
278
+ * Writes the inverse into `out` at any magnitude where it exists: the
279
+ * components are divided by the largest first, so a quaternion of `1e-200` has
280
+ * the inverse `1e200` where {@link quaternionInvert} has no digit left. The zero
281
+ * quaternion, `NaN` and infinite components give `NaN`; an inverse beyond the
282
+ * binary64 range is `Infinity`. About three times the cost. `out` may be `q`.
283
+ */
284
+ export function quaternionInvertScaled(out, q) {
285
+ const largest = largestMagnitude_(q);
286
+ const x = q[0] / largest;
287
+ const y = q[1] / largest;
288
+ const z = q[2] / largest;
289
+ const w = q[3] / largest;
290
+ const lengthSquared = x * x + y * y + z * z + w * w;
291
+ out[0] = -x / lengthSquared / largest;
292
+ out[1] = -y / lengthSquared / largest;
293
+ out[2] = -z / lengthSquared / largest;
294
+ out[3] = w / lengthSquared / largest;
295
+ return out;
296
+ }
297
+ /** The squared norm `x² + y² + z² + w²`, without the square root. */
298
+ export function quaternionLengthSquared(q) {
299
+ return q[0] * q[0] + q[1] * q[1] + q[2] * q[2] + q[3] * q[3];
18
300
  }
19
301
  /**
20
302
  * Exact component-wise equality. See {@link quaternionIsClose} for a tolerant
@@ -23,8 +305,8 @@ export function quaternionDot(q1, q2) {
23
305
  * Compares the four components, so `q` and `-q` are not equal even though they
24
306
  * denote the same rotation.
25
307
  */
26
- export function quaternionEquals(q1, q2) {
27
- return (q1[0] === q2[0] && q1[1] === q2[1] && q1[2] === q2[2] && q1[3] === q2[3]);
308
+ export function quaternionEquals(a, b) {
309
+ return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3];
28
310
  }
29
311
  /**
30
312
  * Component-wise approximate equality.
@@ -32,49 +314,23 @@ export function quaternionEquals(q1, q2) {
32
314
  * Not transitive, so it is not an equality in the sense a `Set` or `Map` needs,
33
315
  * and never a basis for ordering — use {@link quaternionEquals} there. Like the
34
316
  * exact form it compares components, so `q` and `-q` are not close even though
35
- * they denote the same rotation; compare `|quaternionDot(q1, q2)|` against `1`
36
- * to test the rotations instead.
37
- */
38
- export function quaternionIsClose(q1, q2, tolerance) {
39
- return (isCloseTo(q1[0], q2[0], tolerance) &&
40
- isCloseTo(q1[1], q2[1], tolerance) &&
41
- isCloseTo(q1[2], q2[2], tolerance) &&
42
- isCloseTo(q1[3], q2[3], tolerance));
43
- }
44
- export function quaternionInverse(q) {
45
- const conjugate = quaternionConjugate(q);
46
- const normSq = q[0] * q[0] + q[1] * q[1] + q[2] * q[2] + q[3] * q[3];
47
- if (normSq === 0) {
48
- throw new Error("Cannot invert a zero-length quaternion.");
49
- }
50
- return [
51
- conjugate[0] / normSq,
52
- conjugate[1] / normSq,
53
- conjugate[2] / normSq,
54
- conjugate[3] / normSq,
55
- ];
56
- }
57
- export function quaternionLength(q) {
58
- return Math.sqrt(quaternionLengthSq(q));
59
- }
60
- export function quaternionLengthSq(q) {
61
- return q[0] * q[0] + q[1] * q[1] + q[2] * q[2] + q[3] * q[3];
317
+ * they denote the same rotation; compare `|quaternionDot(a, b)|` against `1` to
318
+ * test the rotations instead.
319
+ */
320
+ export function quaternionIsClose(a, b, options) {
321
+ return (isCloseTo(a[0], b[0], options) &&
322
+ isCloseTo(a[1], b[1], options) &&
323
+ isCloseTo(a[2], b[2], options) &&
324
+ isCloseTo(a[3], b[3], options));
62
325
  }
63
- export function quaternionMultiply(q1, q2) {
64
- const x1 = q1[0], y1 = q1[1], z1 = q1[2], w1 = q1[3];
65
- const x2 = q2[0], y2 = q2[1], z2 = q2[2], w2 = q2[3];
66
- return [
67
- sumOfProducts(w1, x2, x1, w2) + diffOfProducts(y1, z2, z1, y2),
68
- diffOfProducts(w1, y2, x1, z2) + sumOfProducts(y1, w2, z1, x2),
69
- sumOfProducts(w1, z2, x1, y2) + diffOfProducts(z1, w2, y1, x2),
70
- diffOfProducts(w1, w2, x1, x2) - sumOfProducts(y1, y2, z1, z2),
71
- ];
72
- }
73
- export function quaternionNormalize(q) {
74
- const length = Math.sqrt(q[0] * q[0] + q[1] * q[1] + q[2] * q[2] + q[3] * q[3]);
75
- if (length === 0) {
76
- throw new Error("Cannot normalize a zero-length quaternion.");
77
- }
78
- return [q[0] / length, q[1] / length, q[2] / length, q[3] / length];
326
+ /**
327
+ * Whether all four components are finite numbers: the check to run after
328
+ * parsing untrusted data or before an upload, as operations never check.
329
+ */
330
+ export function quaternionIsFinite(q) {
331
+ return (Number.isFinite(q[0]) &&
332
+ Number.isFinite(q[1]) &&
333
+ Number.isFinite(q[2]) &&
334
+ Number.isFinite(q[3]));
79
335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CAAC,CAAC;AACzE,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,iBAAiB,CAChC,CAAqB,EACrB,CAAqB,EACrB,OAAyB;IAEzB,OAAO,CACN,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC;QAC9B,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC;QAC9B,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC;QAC9B,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAC9B,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,CAAqB;IACvD,OAAO,CACN,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACrB,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACrB,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACrB,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CACrB,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ac-kit/math-complex",
3
- "version": "0.1.9",
3
+ "version": "0.2.0",
4
4
  "description": "Complex numbers and their extensions: the finite-dimensional algebras over the reals.",
5
5
  "keywords": [
6
6
  "algebra",
@@ -44,21 +44,23 @@
44
44
  "prepack": "yarn build"
45
45
  },
46
46
  "dependencies": {
47
- "@ac-kit/core": "^0.10.0",
48
- "@ac-kit/math-algebra": "^0.1.9",
49
- "@ac-kit/math-scalar": "^0.2.2",
47
+ "@ac-kit/core": "^0.12.0",
48
+ "@ac-kit/math-algebra": "^0.1.11",
49
+ "@ac-kit/math-scalar": "^0.3.0",
50
50
  "@types/web": "^0.0.367"
51
51
  },
52
52
  "devDependencies": {
53
+ "@ac-kit/math-random": "0.4.0",
54
+ "@ac-kit/test-util": "0.4.0",
53
55
  "@ac-kit/tsconfig": "0.1.0",
54
56
  "@ac-kit/typedoc-config": "0.1.0",
55
- "@ac-kit/vitest-config": "0.1.1",
57
+ "@ac-kit/vitest-config": "0.2.0",
56
58
  "@typescript/native": "typescript@7.0.2",
57
59
  "rimraf": "6.1.4",
58
60
  "typedoc": "0.28.20",
59
61
  "typescript": "@typescript/typescript6@6.0.2",
60
- "vite": "8.3.8",
61
- "vitest": "5.1.1"
62
+ "vite": "8.4.0",
63
+ "vitest": "5.1.2"
62
64
  },
63
65
  "engines": {
64
66
  "node": ">=24"