@ac-kit/math-complex 0.1.10 → 0.2.1
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 +107 -0
- package/README.md +74 -6
- 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/complex/complex-num.d.ts +1 -1
- package/dist/complex/complex-num.d.ts.map +1 -1
- package/dist/complex/complex-num.js +14 -14
- package/dist/complex/complex-num.js.map +1 -1
- package/dist/quaternion/quaternion-num.d.ts +20 -12
- package/dist/quaternion/quaternion-num.d.ts.map +1 -1
- package/dist/quaternion/quaternion-num.js +36 -25
- package/dist/quaternion/quaternion-num.js.map +1 -1
- package/dist/quaternion/quaternion.d.ts +158 -17
- package/dist/quaternion/quaternion.d.ts.map +1 -1
- package/dist/quaternion/quaternion.js +314 -58
- package/dist/quaternion/quaternion.js.map +1 -1
- package/package.json +9 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,112 @@
|
|
|
1
1
|
# @ac-kit/math-complex
|
|
2
2
|
|
|
3
|
+
## 0.2.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 0b4fe43: Instance state that was held in `#` private fields is now held in
|
|
8
|
+
TypeScript-private properties (named with a trailing `_`). They are no longer
|
|
9
|
+
hidden at runtime: they appear as own properties (`Object.keys`,
|
|
10
|
+
`JSON.stringify`, `structuredClone`, deep equality), and the declarations list
|
|
11
|
+
them as `private`. Public members are unchanged.
|
|
12
|
+
- Updated dependencies [0b4fe43]
|
|
13
|
+
- Updated dependencies [0b4fe43]
|
|
14
|
+
- Updated dependencies [0b4fe43]
|
|
15
|
+
- Updated dependencies [0b4fe43]
|
|
16
|
+
- Updated dependencies [0b4fe43]
|
|
17
|
+
- Updated dependencies [0b4fe43]
|
|
18
|
+
- Updated dependencies [0b4fe43]
|
|
19
|
+
- Updated dependencies [0b4fe43]
|
|
20
|
+
- Updated dependencies [0b4fe43]
|
|
21
|
+
- Updated dependencies [0b4fe43]
|
|
22
|
+
- Updated dependencies [0b4fe43]
|
|
23
|
+
- Updated dependencies [0b4fe43]
|
|
24
|
+
- Updated dependencies [0b4fe43]
|
|
25
|
+
- Updated dependencies [0b4fe43]
|
|
26
|
+
- Updated dependencies [0b4fe43]
|
|
27
|
+
- Updated dependencies [0b4fe43]
|
|
28
|
+
- Updated dependencies [0b4fe43]
|
|
29
|
+
- Updated dependencies [0b4fe43]
|
|
30
|
+
- Updated dependencies [0b4fe43]
|
|
31
|
+
- Updated dependencies [0b4fe43]
|
|
32
|
+
- Updated dependencies [0b4fe43]
|
|
33
|
+
- Updated dependencies [0b4fe43]
|
|
34
|
+
- Updated dependencies [0b4fe43]
|
|
35
|
+
- Updated dependencies [0b4fe43]
|
|
36
|
+
- Updated dependencies [0b4fe43]
|
|
37
|
+
- Updated dependencies [0b4fe43]
|
|
38
|
+
- Updated dependencies [0b4fe43]
|
|
39
|
+
- Updated dependencies [0b4fe43]
|
|
40
|
+
- @ac-kit/core@0.13.0
|
|
41
|
+
- @ac-kit/math-scalar@0.4.0
|
|
42
|
+
- @ac-kit/math-algebra@0.1.12
|
|
43
|
+
|
|
44
|
+
## 0.2.0
|
|
45
|
+
|
|
46
|
+
### Minor Changes
|
|
47
|
+
|
|
48
|
+
- 34e8cfa: Quaternions follow the out-first standard. `Quaternion` is a branded
|
|
49
|
+
`[x, y, z, w]` tuple made only by `quaternionCreate` (the identity),
|
|
50
|
+
`quaternionOf`, `quaternionClone` and `quaternionFromArray`, so an array
|
|
51
|
+
literal, a `number[]` or a `Float64Array` no longer type-checks and every
|
|
52
|
+
quaternion is a clean array of doubles for V8. `quaternionFromArray` is the
|
|
53
|
+
checked way in from JSON or messages: an element that is not a number, or lies
|
|
54
|
+
past `source.length`, is stored as `NaN`, never as anything else. `quaternionIsFinite` checks a value after
|
|
55
|
+
parsing. Every operation takes `out` first, writes it, returns it, allocates
|
|
56
|
+
nothing, and accepts any of its inputs as `out`.
|
|
57
|
+
|
|
58
|
+
Operations never throw: `quaternionNormalize` of the zero quaternion is zero and
|
|
59
|
+
`quaternionInvert` of it is `NaN`. Arithmetic is plain: `quaternionMultiply` and
|
|
60
|
+
`quaternionDot` no longer use compensated sums, so results can differ in the
|
|
61
|
+
last bits, and the norm, the normalisation and the inverse are right between
|
|
62
|
+
about `1e-150` and `1e150`. Beyond that, `quaternionLengthScaled`,
|
|
63
|
+
`quaternionNormalizeScaled` and `quaternionInvertScaled` divide by the largest
|
|
64
|
+
component first. `QuaternionNum` keeps its API, built on the scaled forms: the
|
|
65
|
+
tuples it takes and returns are copies, `norm()` is right at any magnitude, and
|
|
66
|
+
`inv()` throws only on the zero quaternion (it threw for `1e-200`, whose inverse
|
|
67
|
+
exists).
|
|
68
|
+
|
|
69
|
+
Migration: `quaternionSub`, `quaternionNeg`, `quaternionInverse` and
|
|
70
|
+
`quaternionLengthSq` become `quaternionSubtract`, `quaternionNegate`,
|
|
71
|
+
`quaternionInvert` and `quaternionLengthSquared`, and every function that
|
|
72
|
+
returns a quaternion takes the destination first (`quaternionMultiply(a, b)` is
|
|
73
|
+
now `quaternionMultiply(quaternionCreate(), a, b)`). `QUATERNION_IDENTITY` is
|
|
74
|
+
gone: use `quaternionCreate()` or `quaternionIdentity(out)`. Literals such as
|
|
75
|
+
`[0, 0, 0, 1]` become `quaternionOf(0, 0, 0, 1)`. Code that caught the error on
|
|
76
|
+
a zero quaternion tests the result instead.
|
|
77
|
+
|
|
78
|
+
### Patch Changes
|
|
79
|
+
|
|
80
|
+
- Updated dependencies [34e8cfa]
|
|
81
|
+
- Updated dependencies [34e8cfa]
|
|
82
|
+
- Updated dependencies [34e8cfa]
|
|
83
|
+
- Updated dependencies [34e8cfa]
|
|
84
|
+
- Updated dependencies [34e8cfa]
|
|
85
|
+
- Updated dependencies [34e8cfa]
|
|
86
|
+
- Updated dependencies [34e8cfa]
|
|
87
|
+
- Updated dependencies [34e8cfa]
|
|
88
|
+
- Updated dependencies [34e8cfa]
|
|
89
|
+
- Updated dependencies [34e8cfa]
|
|
90
|
+
- Updated dependencies [34e8cfa]
|
|
91
|
+
- Updated dependencies [34e8cfa]
|
|
92
|
+
- Updated dependencies [34e8cfa]
|
|
93
|
+
- Updated dependencies [34e8cfa]
|
|
94
|
+
- Updated dependencies [34e8cfa]
|
|
95
|
+
- Updated dependencies [34e8cfa]
|
|
96
|
+
- Updated dependencies [34e8cfa]
|
|
97
|
+
- Updated dependencies [34e8cfa]
|
|
98
|
+
- Updated dependencies [34e8cfa]
|
|
99
|
+
- Updated dependencies [34e8cfa]
|
|
100
|
+
- Updated dependencies [34e8cfa]
|
|
101
|
+
- Updated dependencies [34e8cfa]
|
|
102
|
+
- Updated dependencies [34e8cfa]
|
|
103
|
+
- Updated dependencies [34e8cfa]
|
|
104
|
+
- Updated dependencies [34e8cfa]
|
|
105
|
+
- Updated dependencies [34e8cfa]
|
|
106
|
+
- @ac-kit/core@0.12.0
|
|
107
|
+
- @ac-kit/math-scalar@0.3.0
|
|
108
|
+
- @ac-kit/math-algebra@0.1.11
|
|
109
|
+
|
|
3
110
|
## 0.1.10
|
|
4
111
|
|
|
5
112
|
### 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`, `
|
|
36
|
-
| `
|
|
37
|
-
| `
|
|
38
|
-
| `
|
|
39
|
-
| `
|
|
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 {
|
|
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
|
package/dist/_brand.d.ts
ADDED
|
@@ -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 @@
|
|
|
1
|
+
{"version":3,"file":"_brand.js","sourceRoot":"","sources":["../src/_brand.ts"],"names":[],"mappings":""}
|
|
@@ -13,7 +13,7 @@ import { Complex } from "./complex.js";
|
|
|
13
13
|
* ```
|
|
14
14
|
*/
|
|
15
15
|
export declare class ComplexNum implements IField<ComplexNum> {
|
|
16
|
-
|
|
16
|
+
private readonly value_;
|
|
17
17
|
private constructor();
|
|
18
18
|
/** The complex number `0 + 0i`. */
|
|
19
19
|
static readonly ZERO: ComplexNum;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"complex-num.d.ts","sourceRoot":"","sources":["../../src/complex/complex-num.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAEnD,OAAO,EAIN,OAAO,EAUP,MAAM,cAAc,CAAC;AAEtB;;;;;;;;;;;GAWG;AACH,qBAAa,UAAW,YAAW,MAAM,CAAC,UAAU,CAAC
|
|
1
|
+
{"version":3,"file":"complex-num.d.ts","sourceRoot":"","sources":["../../src/complex/complex-num.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAEnD,OAAO,EAIN,OAAO,EAUP,MAAM,cAAc,CAAC;AAEtB;;;;;;;;;;;GAWG;AACH,qBAAa,UAAW,YAAW,MAAM,CAAC,UAAU,CAAC;IACpD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAU;IAEjC,OAAO,eAEN;IAED,mCAAmC;IACnC,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAgC;IAEhE,mCAAmC;IACnC,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,UAAU,CAA+B;IAE9D,oDAAoD;IACpD,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,UAAU,CAA6B;IAE1D,kEAAkE;IAClE,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,SAAI,GAAG,UAAU,CAE1C;IAED,uDAAuD;IACvD,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,UAAU,CAE3C;IAED,yEAAyE;IACzE,OAAO,IAAI,OAAO,CAEjB;IAED,iCAAiC;IACjC,IAAI,EAAE,IAAI,MAAM,CAEf;IAED,sCAAsC;IACtC,IAAI,EAAE,IAAI,MAAM,CAEf;IAED,yDAAyD;IACzD,GAAG,IAAI,MAAM,CAEZ;IAED,mDAAmD;IACnD,GAAG,IAAI,MAAM,CAEZ;IAED,+BAA+B;IAC/B,IAAI,IAAI,UAAU,CAEjB;IAED,GAAG,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,CAEjC;IAED,GAAG,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,CAEjC;IAED,GAAG,IAAI,UAAU,CAEhB;IAED,GAAG,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,CAEjC;IAED,mCAAmC;IACnC,GAAG,IAAI,UAAU,CAEhB;IAED,oCAAoC;IACpC,GAAG,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,CAEjC;CACD"}
|
|
@@ -12,9 +12,9 @@ import { COMPLEX_I, COMPLEX_ONE, COMPLEX_ZERO, complexAdd, complexArgument, comp
|
|
|
12
12
|
* ```
|
|
13
13
|
*/
|
|
14
14
|
export class ComplexNum {
|
|
15
|
-
|
|
15
|
+
value_;
|
|
16
16
|
constructor(value) {
|
|
17
|
-
this
|
|
17
|
+
this.value_ = value;
|
|
18
18
|
}
|
|
19
19
|
/** The complex number `0 + 0i`. */
|
|
20
20
|
static ZERO = new ComplexNum(COMPLEX_ZERO);
|
|
@@ -32,47 +32,47 @@ export class ComplexNum {
|
|
|
32
32
|
}
|
|
33
33
|
/** The underlying tuple, for callers working at the arithmetic layer. */
|
|
34
34
|
toTuple() {
|
|
35
|
-
return this
|
|
35
|
+
return this.value_;
|
|
36
36
|
}
|
|
37
37
|
/** Real part `a` of `a + bi`. */
|
|
38
38
|
get re() {
|
|
39
|
-
return this
|
|
39
|
+
return this.value_[0];
|
|
40
40
|
}
|
|
41
41
|
/** Imaginary part `b` of `a + bi`. */
|
|
42
42
|
get im() {
|
|
43
|
-
return this
|
|
43
|
+
return this.value_[1];
|
|
44
44
|
}
|
|
45
45
|
/** Modulus `|z| = √(re² + im²)`. Always non-negative. */
|
|
46
46
|
abs() {
|
|
47
|
-
return complexModulus(this
|
|
47
|
+
return complexModulus(this.value_);
|
|
48
48
|
}
|
|
49
49
|
/** Argument `arg(z) = atan2(im, re) ∈ (−π, π]`. */
|
|
50
50
|
arg() {
|
|
51
|
-
return complexArgument(this
|
|
51
|
+
return complexArgument(this.value_);
|
|
52
52
|
}
|
|
53
53
|
/** `conj(a + bi) = a − bi`. */
|
|
54
54
|
conj() {
|
|
55
|
-
return new ComplexNum(complexConjugate(this
|
|
55
|
+
return new ComplexNum(complexConjugate(this.value_));
|
|
56
56
|
}
|
|
57
57
|
add(other) {
|
|
58
|
-
return new ComplexNum(complexAdd(this
|
|
58
|
+
return new ComplexNum(complexAdd(this.value_, other.value_));
|
|
59
59
|
}
|
|
60
60
|
sub(other) {
|
|
61
|
-
return new ComplexNum(complexSub(this
|
|
61
|
+
return new ComplexNum(complexSub(this.value_, other.value_));
|
|
62
62
|
}
|
|
63
63
|
neg() {
|
|
64
|
-
return new ComplexNum(complexNeg(this
|
|
64
|
+
return new ComplexNum(complexNeg(this.value_));
|
|
65
65
|
}
|
|
66
66
|
mul(other) {
|
|
67
|
-
return new ComplexNum(complexMul(this
|
|
67
|
+
return new ComplexNum(complexMul(this.value_, other.value_));
|
|
68
68
|
}
|
|
69
69
|
/** @throws When called on zero. */
|
|
70
70
|
inv() {
|
|
71
|
-
return new ComplexNum(complexInverse(this
|
|
71
|
+
return new ComplexNum(complexInverse(this.value_));
|
|
72
72
|
}
|
|
73
73
|
/** @throws When `other` is zero. */
|
|
74
74
|
div(other) {
|
|
75
|
-
return new ComplexNum(complexDiv(this
|
|
75
|
+
return new ComplexNum(complexDiv(this.value_, other.value_));
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
//# sourceMappingURL=complex-num.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"complex-num.js","sourceRoot":"","sources":["../../src/complex/complex-num.ts"],"names":[],"mappings":"AAEA,OAAO,EACN,SAAS,EACT,WAAW,EACX,YAAY,EAEZ,UAAU,EACV,eAAe,EACf,gBAAgB,EAChB,UAAU,EACV,cAAc,EACd,cAAc,EACd,UAAU,EACV,UAAU,EACV,UAAU,GACV,MAAM,cAAc,CAAC;AAEtB;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,UAAU;
|
|
1
|
+
{"version":3,"file":"complex-num.js","sourceRoot":"","sources":["../../src/complex/complex-num.ts"],"names":[],"mappings":"AAEA,OAAO,EACN,SAAS,EACT,WAAW,EACX,YAAY,EAEZ,UAAU,EACV,eAAe,EACf,gBAAgB,EAChB,UAAU,EACV,cAAc,EACd,cAAc,EACd,UAAU,EACV,UAAU,EACV,UAAU,GACV,MAAM,cAAc,CAAC;AAEtB;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,UAAU;IACL,MAAM,CAAU;IAEjC,YAAoB,KAAc;QACjC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACrB,CAAC;IAED,mCAAmC;IACnC,MAAM,CAAU,IAAI,GAAe,IAAI,UAAU,CAAC,YAAY,CAAC,CAAC;IAEhE,mCAAmC;IACnC,MAAM,CAAU,GAAG,GAAe,I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IAED,GAAG;QACF,OAAO,IAAI,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IAChD,CAAC;IAED,GAAG,CAAC,KAAiB;QACpB,OAAO,IAAI,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;IAC9D,CAAC;IAED,mCAAmC;IACnC,GAAG;QACF,OAAO,IAAI,UAAU,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IACpD,CAAC;IAED,oCAAoC;IACpC,GAAG,CAAC,KAAiB;QACpB,OAAO,IAAI,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;IAC9D,CAAC;CACD"}
|
|
@@ -1,25 +1,28 @@
|
|
|
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
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
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 readonly value_;
|
|
13
16
|
private constructor();
|
|
14
17
|
/** The quaternion `1 + 0i + 0j + 0k`. */
|
|
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:
|
|
21
|
+
/** Wraps a copy of an already-computed {@link Quaternion} tuple `[b, c, d, a]`. */
|
|
22
|
+
static fromTuple(value: ReadonlyQuaternion): QuaternionNum;
|
|
20
23
|
/**
|
|
21
|
-
*
|
|
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
|
-
/**
|
|
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,
|
|
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,EACN,KAAK,UAAU,EAWf,KAAK,kBAAkB,EACvB,MAAM,iBAAiB,CAAC;AAEzB;;;;;;;;;;GAUG;AACH,qBAAa,aAAc,YAAW,KAAK,CAAC,aAAa,CAAC;IACzD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAa;IAEpC,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,CAIf;IAED,mFAAmF;IACnF,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,kBAAkB,GAAG,aAAa,CAEzD;IAED;;;OAGG;IACH,OAAO,IAAI,UAAU,CAEpB;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,73 +1,84 @@
|
|
|
1
|
-
import {
|
|
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
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
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_;
|
|
12
15
|
constructor(value) {
|
|
13
|
-
this
|
|
16
|
+
this.value_ = value;
|
|
14
17
|
}
|
|
15
18
|
/** The quaternion `1 + 0i + 0j + 0k`. */
|
|
16
|
-
static IDENTITY = new QuaternionNum(
|
|
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(
|
|
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
|
-
*
|
|
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
|
|
33
|
+
return quaternionClone(this.value_);
|
|
31
34
|
}
|
|
32
35
|
/** Scalar (real) part: the `a` in `a + bi + cj + dk`. */
|
|
33
36
|
get scalar() {
|
|
34
|
-
return this
|
|
37
|
+
return this.value_[3];
|
|
35
38
|
}
|
|
36
39
|
/** Vector (pure-quaternion) part: `[b, c, d]` for `i`, `j`, `k` components. */
|
|
37
40
|
get vector() {
|
|
38
|
-
return [this
|
|
41
|
+
return [this.value_[0], this.value_[1], this.value_[2]];
|
|
39
42
|
}
|
|
40
43
|
/**
|
|
41
44
|
* Conjugate `conj(a + bi + cj + dk) = a − bi − cj − dk`. Negates the vector
|
|
42
45
|
* part; leaves the scalar part unchanged.
|
|
43
46
|
*/
|
|
44
47
|
conj() {
|
|
45
|
-
return new QuaternionNum(quaternionConjugate(this
|
|
48
|
+
return new QuaternionNum(quaternionConjugate(quaternionCreate(), this.value_));
|
|
46
49
|
}
|
|
47
|
-
/**
|
|
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
|
|
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
|
-
|
|
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
|
|
71
|
+
return new QuaternionNum(quaternionAdd(quaternionCreate(), this.value_, other.value_));
|
|
61
72
|
}
|
|
62
73
|
sub(other) {
|
|
63
|
-
return new QuaternionNum(
|
|
74
|
+
return new QuaternionNum(quaternionSubtract(quaternionCreate(), this.value_, other.value_));
|
|
64
75
|
}
|
|
65
76
|
neg() {
|
|
66
|
-
return new QuaternionNum(
|
|
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
|
|
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,
|
|
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,sB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ACH,OAAO,sBAAsB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC5C,CAAC;IAED;;;;;;OAMG;IACH,GAAG;QACF,IAAI,sBAAsB,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;YAC/C,MAAM,IAAI,UAAU,CAAC,yCAAyC,CAAC,CAAC;QACjE,CAAC;QACD,OAAO,IAAI,aAAa,CACvB,sBAAsB,CAAC,gBAAgB,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC,CACvD,CAAC;IACH,CAAC;IAED,GAAG,CAAC,KAAoB;QACvB,OAAO,IAAI,aAAa,CACvB,aAAa,CAAC,gBAAgB,EAAE,EAAE,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CAC5D,CAAC;IACH,CAAC;IAED,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;IAED,GAAG;QACF,OAAO,IAAI,aAAa,CAAC,gBAAgB,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
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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(
|
|
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(
|
|
24
|
-
*
|
|
25
|
-
*/
|
|
26
|
-
export declare function quaternionIsClose(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
export declare function
|
|
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
|
//# sourceMappingURL=quaternion.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quaternion.d.ts","sourceRoot":"","sources":["../../src/quaternion/quaternion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,gBAAgB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"quaternion.d.ts","sourceRoot":"","sources":["../../src/quaternion/quaternion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,gBAAgB,EAAe,MAAM,cAAc,CAAC;AAE7E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,CAAC,GACpE,MAAM,CAAC,YAAY,CAAC,CAAC;AAEtB,8CAA8C;AAC9C,MAAM,MAAM,kBAAkB,GAAG,SAAS;IACzC,CAAC,EAAE,MAAM;IACT,CAAC,EAAE,MAAM;IACT,CAAC,EAAE,MAAM;IACT,CAAC,EAAE,MAAM;CACT,GACA,MAAM,CAAC,YAAY,CAAC,CAAC;AA4BtB;;;;GAIG;AACH,wBAAgB,gBAAgB,IAAI,UAAU,CAO7C;AAED;;;;GAIG;AACH,wBAAgB,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OT;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAOjE"}
|
|
@@ -1,20 +1,302 @@
|
|
|
1
|
-
import { isCloseTo } from "@ac-kit/core";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
|
|
8
|
-
|
|
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
|
-
|
|
11
|
-
|
|
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
|
-
|
|
14
|
-
|
|
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
|
-
|
|
17
|
-
|
|
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(
|
|
27
|
-
return
|
|
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(
|
|
36
|
-
*
|
|
37
|
-
*/
|
|
38
|
-
export function quaternionIsClose(
|
|
39
|
-
return (isCloseTo(
|
|
40
|
-
isCloseTo(
|
|
41
|
-
isCloseTo(
|
|
42
|
-
isCloseTo(
|
|
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
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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
|
}
|
|
80
336
|
//# sourceMappingURL=quaternion.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quaternion.js","sourceRoot":"","sources":["../../src/quaternion/quaternion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAyB,MAAM,cAAc,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAIhF,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAA+B,CAAC;AAE9E,MAAM,UAAU,aAAa,CAAC,EAAc,EAAE,EAAc;IAC3D,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AACrE,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,EAAc,EAAE,EAAc;IAC3D,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AACrE,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,CAAa;IAC1C,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CA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,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,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
|
|
3
|
+
"version": "0.2.1",
|
|
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.
|
|
48
|
-
"@ac-kit/math-algebra": "^0.1.
|
|
49
|
-
"@ac-kit/math-scalar": "^0.
|
|
47
|
+
"@ac-kit/core": "^0.13.0",
|
|
48
|
+
"@ac-kit/math-algebra": "^0.1.12",
|
|
49
|
+
"@ac-kit/math-scalar": "^0.4.0",
|
|
50
50
|
"@types/web": "^0.0.367"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
+
"@ac-kit/math-random": "0.4.1",
|
|
54
|
+
"@ac-kit/test-util": "0.5.0",
|
|
53
55
|
"@ac-kit/tsconfig": "0.1.0",
|
|
54
56
|
"@ac-kit/typedoc-config": "0.1.0",
|
|
55
|
-
"@ac-kit/vitest-config": "0.
|
|
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.
|
|
61
|
-
"vitest": "5.1.
|
|
62
|
+
"vite": "8.4.0",
|
|
63
|
+
"vitest": "5.1.2"
|
|
62
64
|
},
|
|
63
65
|
"engines": {
|
|
64
66
|
"node": ">=24"
|