symcrys 0.10.1 → 0.12.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/README.md +6 -6
- package/dist/cell.d.ts +19 -16
- package/dist/cell.d.ts.map +1 -1
- package/dist/cell.js +63 -35
- package/dist/cell.js.map +1 -1
- package/dist/checks.d.ts +29 -0
- package/dist/checks.d.ts.map +1 -0
- package/dist/checks.js +79 -0
- package/dist/checks.js.map +1 -0
- package/dist/closure.d.ts +43 -0
- package/dist/closure.d.ts.map +1 -0
- package/dist/closure.js +201 -0
- package/dist/closure.js.map +1 -0
- package/dist/coordinates.d.ts +143 -0
- package/dist/coordinates.d.ts.map +1 -0
- package/dist/coordinates.js +198 -0
- package/dist/coordinates.js.map +1 -0
- package/dist/crystalClasses.d.ts +170 -117
- package/dist/crystalClasses.d.ts.map +1 -1
- package/dist/crystalClasses.js +190 -121
- package/dist/crystalClasses.js.map +1 -1
- package/dist/freeze.d.ts +7 -0
- package/dist/freeze.d.ts.map +1 -0
- package/dist/freeze.js +15 -0
- package/dist/freeze.js.map +1 -0
- package/dist/index.d.ts +13 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -3
- package/dist/index.js.map +1 -1
- package/dist/indices.d.ts +30 -20
- package/dist/indices.d.ts.map +1 -1
- package/dist/indices.js +101 -31
- package/dist/indices.js.map +1 -1
- package/dist/lattice.d.ts +15 -1
- package/dist/lattice.d.ts.map +1 -1
- package/dist/lattice.js +30 -1
- package/dist/lattice.js.map +1 -1
- package/dist/linalg.d.ts +2 -2
- package/dist/linalg.d.ts.map +1 -1
- package/dist/linalg.js +3 -3
- package/dist/linalg.js.map +1 -1
- package/dist/magnetic.d.ts +14 -10
- package/dist/magnetic.d.ts.map +1 -1
- package/dist/magnetic.js +10 -6
- package/dist/magnetic.js.map +1 -1
- package/dist/notation.d.ts +16 -0
- package/dist/notation.d.ts.map +1 -0
- package/dist/notation.js +66 -0
- package/dist/notation.js.map +1 -0
- package/dist/operations.d.ts +40 -26
- package/dist/operations.d.ts.map +1 -1
- package/dist/operations.js +48 -60
- package/dist/operations.js.map +1 -1
- package/dist/plane.d.ts +297 -80
- package/dist/plane.d.ts.map +1 -1
- package/dist/plane.js +289 -94
- package/dist/plane.js.map +1 -1
- package/dist/pointGroups/crystalForms.d.ts +6 -21
- package/dist/pointGroups/crystalForms.d.ts.map +1 -1
- package/dist/pointGroups/crystalForms.js +9 -16
- package/dist/pointGroups/crystalForms.js.map +1 -1
- package/dist/pointGroups/crystalFormsData.d.ts +4 -1
- package/dist/pointGroups/crystalFormsData.d.ts.map +1 -1
- package/dist/pointGroups/crystalFormsData.js +64 -1
- package/dist/pointGroups/crystalFormsData.js.map +1 -1
- package/dist/pointGroups/elements.d.ts +19 -17
- package/dist/pointGroups/elements.d.ts.map +1 -1
- package/dist/pointGroups/elements.js +65 -83
- package/dist/pointGroups/elements.js.map +1 -1
- package/dist/pointGroups/identify.d.ts +10 -18
- package/dist/pointGroups/identify.d.ts.map +1 -1
- package/dist/pointGroups/identify.js +27 -79
- package/dist/pointGroups/identify.js.map +1 -1
- package/dist/pointGroups/itaOrder.d.ts +15 -14
- package/dist/pointGroups/itaOrder.d.ts.map +1 -1
- package/dist/pointGroups/itaOrder.js +116 -94
- package/dist/pointGroups/itaOrder.js.map +1 -1
- package/dist/pointGroups/itcData.d.ts +96 -0
- package/dist/pointGroups/itcData.d.ts.map +1 -0
- package/dist/pointGroups/itcData.js +336 -0
- package/dist/pointGroups/itcData.js.map +1 -0
- package/dist/pointGroups/itcMagneticData.d.ts +55 -0
- package/dist/pointGroups/itcMagneticData.d.ts.map +1 -0
- package/dist/pointGroups/itcMagneticData.js +172 -0
- package/dist/pointGroups/itcMagneticData.js.map +1 -0
- package/dist/pointGroups/keys.d.ts +32 -0
- package/dist/pointGroups/keys.d.ts.map +1 -0
- package/dist/pointGroups/keys.js +120 -0
- package/dist/pointGroups/keys.js.map +1 -0
- package/dist/pointGroups/magneticSymbols.d.ts +6 -5
- package/dist/pointGroups/magneticSymbols.d.ts.map +1 -1
- package/dist/pointGroups/magneticSymbols.js +15 -12
- package/dist/pointGroups/magneticSymbols.js.map +1 -1
- package/dist/pointGroups/orbits.d.ts +23 -42
- package/dist/pointGroups/orbits.d.ts.map +1 -1
- package/dist/pointGroups/orbits.js +20 -62
- package/dist/pointGroups/orbits.js.map +1 -1
- package/dist/pointGroups/pointGroups.d.ts +145 -68
- package/dist/pointGroups/pointGroups.d.ts.map +1 -1
- package/dist/pointGroups/pointGroups.js +455 -243
- package/dist/pointGroups/pointGroups.js.map +1 -1
- package/dist/pointGroups/properties.d.ts +21 -22
- package/dist/pointGroups/properties.d.ts.map +1 -1
- package/dist/pointGroups/properties.js +40 -37
- package/dist/pointGroups/properties.js.map +1 -1
- package/dist/pointGroups/seitzData.d.ts +26 -0
- package/dist/pointGroups/seitzData.d.ts.map +1 -0
- package/dist/pointGroups/seitzData.js +130 -0
- package/dist/pointGroups/seitzData.js.map +1 -0
- package/dist/pointGroups/shubnikovData.d.ts +11 -0
- package/dist/pointGroups/shubnikovData.d.ts.map +1 -0
- package/dist/pointGroups/shubnikovData.js +101 -0
- package/dist/pointGroups/shubnikovData.js.map +1 -0
- package/dist/pointGroups/wyckoff.d.ts +70 -40
- package/dist/pointGroups/wyckoff.d.ts.map +1 -1
- package/dist/pointGroups/wyckoff.js +98 -91
- package/dist/pointGroups/wyckoff.js.map +1 -1
- package/dist/pointGroups/wyckoffData.d.ts +7 -4
- package/dist/pointGroups/wyckoffData.d.ts.map +1 -1
- package/dist/pointGroups/wyckoffData.js +789 -168
- package/dist/pointGroups/wyckoffData.js.map +1 -1
- package/dist/siteSymmetry.d.ts +8 -16
- package/dist/siteSymmetry.d.ts.map +1 -1
- package/dist/siteSymmetry.js +34 -24
- package/dist/siteSymmetry.js.map +1 -1
- package/dist/spaceGroups/affine.d.ts.map +1 -1
- package/dist/spaceGroups/affine.js +3 -2
- package/dist/spaceGroups/affine.js.map +1 -1
- package/dist/spaceGroups/cell.d.ts +43 -31
- package/dist/spaceGroups/cell.d.ts.map +1 -1
- package/dist/spaceGroups/cell.js +173 -85
- package/dist/spaceGroups/cell.js.map +1 -1
- package/dist/spaceGroups/describe.d.ts +13 -10
- package/dist/spaceGroups/describe.d.ts.map +1 -1
- package/dist/spaceGroups/describe.js +11 -10
- package/dist/spaceGroups/describe.js.map +1 -1
- package/dist/spaceGroups/planeGroupData.d.ts +3 -1
- package/dist/spaceGroups/planeGroupData.d.ts.map +1 -1
- package/dist/spaceGroups/planeGroupData.js +25 -8
- package/dist/spaceGroups/planeGroupData.js.map +1 -1
- package/dist/spaceGroups/planeGroups.d.ts.map +1 -1
- package/dist/spaceGroups/planeGroups.js +2 -1
- package/dist/spaceGroups/planeGroups.js.map +1 -1
- package/dist/spaceGroups/planeLattice.d.ts +78 -0
- package/dist/spaceGroups/planeLattice.d.ts.map +1 -0
- package/dist/spaceGroups/planeLattice.js +143 -0
- package/dist/spaceGroups/planeLattice.js.map +1 -0
- package/dist/spaceGroups/planePointGroups.d.ts +6 -2
- package/dist/spaceGroups/planePointGroups.d.ts.map +1 -1
- package/dist/spaceGroups/planePointGroups.js +14 -2
- package/dist/spaceGroups/planePointGroups.js.map +1 -1
- package/dist/spaceGroups/positions.d.ts +48 -19
- package/dist/spaceGroups/positions.d.ts.map +1 -1
- package/dist/spaceGroups/positions.js +166 -67
- package/dist/spaceGroups/positions.js.map +1 -1
- package/dist/spaceGroups/rational.d.ts +18 -0
- package/dist/spaceGroups/rational.d.ts.map +1 -1
- package/dist/spaceGroups/rational.js +58 -0
- package/dist/spaceGroups/rational.js.map +1 -1
- package/dist/tensors/propertyTable.d.ts +3 -1
- package/dist/tensors/propertyTable.d.ts.map +1 -1
- package/dist/tensors/propertyTable.js +17 -10
- package/dist/tensors/propertyTable.js.map +1 -1
- package/dist/tensors/rowEchelon.d.ts +3 -3
- package/dist/tensors/rowEchelon.d.ts.map +1 -1
- package/dist/tensors/rowEchelon.js +4 -4
- package/dist/tensors/rowEchelon.js.map +1 -1
- package/dist/tensors/tensorForm.d.ts +75 -34
- package/dist/tensors/tensorForm.d.ts.map +1 -1
- package/dist/tensors/tensorForm.js +171 -67
- package/dist/tensors/tensorForm.js.map +1 -1
- package/dist/tensors/tensorProperties.d.ts +10 -9
- package/dist/tensors/tensorProperties.d.ts.map +1 -1
- package/dist/tensors/tensorProperties.js +22 -12
- package/dist/tensors/tensorProperties.js.map +1 -1
- package/dist/tensors/voigt.d.ts +56 -0
- package/dist/tensors/voigt.d.ts.map +1 -0
- package/dist/tensors/voigt.js +188 -0
- package/dist/tensors/voigt.js.map +1 -0
- package/dist/tolerances.d.ts +56 -1
- package/dist/tolerances.d.ts.map +1 -1
- package/dist/tolerances.js +51 -1
- package/dist/tolerances.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/src/cell.ts +78 -51
- package/src/checks.ts +84 -0
- package/src/closure.ts +214 -0
- package/src/coordinates.ts +370 -0
- package/src/crystalClasses.ts +271 -157
- package/src/freeze.ts +14 -0
- package/src/index.ts +33 -12
- package/src/indices.ts +102 -42
- package/src/lattice.ts +41 -1
- package/src/linalg.ts +3 -3
- package/src/magnetic.ts +24 -11
- package/src/notation.ts +73 -0
- package/src/operations.ts +78 -71
- package/src/plane.ts +531 -151
- package/src/pointGroups/crystalForms.ts +11 -44
- package/src/pointGroups/crystalFormsData.ts +66 -1
- package/src/pointGroups/elements.ts +82 -92
- package/src/pointGroups/identify.ts +38 -97
- package/src/pointGroups/itaOrder.ts +117 -101
- package/src/pointGroups/itcData.ts +404 -0
- package/src/pointGroups/itcMagneticData.ts +206 -0
- package/src/pointGroups/keys.ts +144 -0
- package/src/pointGroups/magneticSymbols.ts +18 -17
- package/src/pointGroups/orbits.ts +41 -89
- package/src/pointGroups/pointGroups.ts +593 -298
- package/src/pointGroups/properties.ts +44 -40
- package/src/pointGroups/seitzData.ts +147 -0
- package/src/pointGroups/shubnikovData.ts +103 -0
- package/src/pointGroups/wyckoff.ts +137 -112
- package/src/pointGroups/wyckoffData.ts +793 -170
- package/src/siteSymmetry.ts +43 -40
- package/src/spaceGroups/affine.ts +3 -2
- package/src/spaceGroups/cell.ts +227 -116
- package/src/spaceGroups/describe.ts +23 -19
- package/src/spaceGroups/planeGroupData.ts +28 -9
- package/src/spaceGroups/planeGroups.ts +2 -1
- package/src/spaceGroups/planeLattice.ts +208 -0
- package/src/spaceGroups/planePointGroups.ts +23 -3
- package/src/spaceGroups/positions.ts +202 -78
- package/src/spaceGroups/rational.ts +59 -0
- package/src/tensors/propertyTable.ts +26 -14
- package/src/tensors/rowEchelon.ts +4 -3
- package/src/tensors/tensorForm.ts +258 -88
- package/src/tensors/tensorProperties.ts +34 -14
- package/src/tensors/voigt.ts +268 -0
- package/src/tolerances.ts +66 -1
- package/src/version.ts +1 -1
- package/dist/pointGroups/data.d.ts +0 -75
- package/dist/pointGroups/data.d.ts.map +0 -1
- package/dist/pointGroups/data.js +0 -212
- package/dist/pointGroups/data.js.map +0 -1
- package/dist/pointGroups/magneticData.d.ts +0 -66
- package/dist/pointGroups/magneticData.d.ts.map +0 -1
- package/dist/pointGroups/magneticData.js +0 -184
- package/dist/pointGroups/magneticData.js.map +0 -1
- package/dist/spaceGroups/snap.d.ts +0 -20
- package/dist/spaceGroups/snap.d.ts.map +0 -1
- package/dist/spaceGroups/snap.js +0 -103
- package/dist/spaceGroups/snap.js.map +0 -1
- package/src/pointGroups/data.ts +0 -305
- package/src/pointGroups/magneticData.ts +0 -328
- package/src/spaceGroups/snap.ts +0 -121
package/dist/closure.js
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The group generated by operations a caller passes in, within a tolerance, and that group made
|
|
3
|
+
* exact (docs/conventions.md, "Tolerances"). Operations read from a file or computed elsewhere carry
|
|
4
|
+
* rounding errors (√3/2 written as 0.866025); compared within the tolerance they still generate the
|
|
5
|
+
* right group, but its matrices are not exactly a group, and a tensor form computed from them has
|
|
6
|
+
* the wrong number of free parameters (#89). `idealGroup` therefore replaces them by the exact group
|
|
7
|
+
* nearest to them before anything is computed from them.
|
|
8
|
+
*/
|
|
9
|
+
import { det, inverse, multiply, snap, trace, transpose } from './linalg.js';
|
|
10
|
+
import { IDEAL_PASSES, IDEAL_SETTLED, IDEAL_SNAP, IDEAL_UNSETTLED, PRODUCT_MATCH } from './tolerances.js';
|
|
11
|
+
const IDENTITY = {
|
|
12
|
+
cartesian: [
|
|
13
|
+
[1, 0, 0],
|
|
14
|
+
[0, 1, 0],
|
|
15
|
+
[0, 0, 1],
|
|
16
|
+
],
|
|
17
|
+
timeReversal: false,
|
|
18
|
+
};
|
|
19
|
+
/** No finite group of Cartesian operations that symcrys computes with has more elements (m-3m1' has 96). */
|
|
20
|
+
export const MAX_GROUP_ORDER = 200;
|
|
21
|
+
/** True if the two operations agree in time reversal and in every matrix entry within `tolerance`. */
|
|
22
|
+
export function sameWithin(a, b, tolerance) {
|
|
23
|
+
return (a.timeReversal === b.timeReversal &&
|
|
24
|
+
a.cartesian.every((row, i) => row.every((v, j) => Math.abs(v - b.cartesian[i][j]) < tolerance)));
|
|
25
|
+
}
|
|
26
|
+
/** The kind of an operation (rounded trace, sign of the determinant, time reversal): equal operations have the same. */
|
|
27
|
+
const kindOf = (op) => `${Math.round(trace(op.cartesian))}${det(op.cartesian) > 0 ? '+' : '-'}${op.timeReversal ? "'" : ''}`;
|
|
28
|
+
/**
|
|
29
|
+
* The group the operations generate within `tolerance` (two operations equal when they agree in
|
|
30
|
+
* time reversal and in every matrix entry within it), the identity first, then the operations of
|
|
31
|
+
* the list that are new, then products in the order they are found; or undefined if it has more
|
|
32
|
+
* than `maxOrder` elements. A new operation is compared only with the operations of its kind.
|
|
33
|
+
*/
|
|
34
|
+
export function closeWithin(operations, tolerance, maxOrder = MAX_GROUP_ORDER) {
|
|
35
|
+
const group = [];
|
|
36
|
+
const byKind = new Map();
|
|
37
|
+
const has = (op) => (byKind.get(kindOf(op)) ?? []).some((g) => sameWithin(g, op, tolerance));
|
|
38
|
+
const push = (op) => {
|
|
39
|
+
group.push(op);
|
|
40
|
+
const k = kindOf(op);
|
|
41
|
+
const list = byKind.get(k);
|
|
42
|
+
if (list)
|
|
43
|
+
list.push(op);
|
|
44
|
+
else
|
|
45
|
+
byKind.set(k, [op]);
|
|
46
|
+
};
|
|
47
|
+
push(IDENTITY);
|
|
48
|
+
const generators = [];
|
|
49
|
+
for (const s of operations) {
|
|
50
|
+
const op = { cartesian: s.cartesian, timeReversal: s.timeReversal };
|
|
51
|
+
if (has(op))
|
|
52
|
+
continue;
|
|
53
|
+
generators.push(op);
|
|
54
|
+
for (let i = 0; i < group.length; i++) {
|
|
55
|
+
for (const t of generators) {
|
|
56
|
+
const product = {
|
|
57
|
+
cartesian: multiply(group[i].cartesian, t.cartesian),
|
|
58
|
+
timeReversal: group[i].timeReversal !== t.timeReversal,
|
|
59
|
+
};
|
|
60
|
+
if (has(product))
|
|
61
|
+
continue;
|
|
62
|
+
if (group.length >= maxOrder)
|
|
63
|
+
return undefined;
|
|
64
|
+
push(product);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return group;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* The group the operations generate within `tolerance` (`closeWithin`); throws a RangeError if it
|
|
72
|
+
* has more than `MAX_GROUP_ORDER` elements.
|
|
73
|
+
*/
|
|
74
|
+
export function closedGroup(operations, tolerance) {
|
|
75
|
+
const group = closeWithin(operations, tolerance);
|
|
76
|
+
if (!group) {
|
|
77
|
+
throw new RangeError(`The operations generate no finite point group within the tolerance ${tolerance} (more than ${MAX_GROUP_ORDER} elements): matrices with errors too large for the tolerance (pass a larger one, about ten times their rounding), or a rotation by an angle that is not 360°/n`);
|
|
78
|
+
}
|
|
79
|
+
return group;
|
|
80
|
+
}
|
|
81
|
+
/** The largest difference of two matrix entries. */
|
|
82
|
+
function distance(a, b) {
|
|
83
|
+
let d = 0;
|
|
84
|
+
for (let i = 0; i < 3; i++)
|
|
85
|
+
for (let j = 0; j < 3; j++)
|
|
86
|
+
d = Math.max(d, Math.abs(a[i][j] - b[i][j]));
|
|
87
|
+
return d;
|
|
88
|
+
}
|
|
89
|
+
const add = (a, b) => a.map((row, i) => row.map((v, j) => v + b[i][j]));
|
|
90
|
+
const scale = (a, s) => a.map((row) => row.map((v) => v * s));
|
|
91
|
+
/**
|
|
92
|
+
* The square root of a symmetric positive definite matrix and its inverse, by the iteration of
|
|
93
|
+
* Denman and Beavers (Y ← (Y + Z⁻¹)/2, Z ← (Z + Y⁻¹)/2 from Y = M, Z = 1), which converges
|
|
94
|
+
* quadratically; here M lies near the identity.
|
|
95
|
+
*/
|
|
96
|
+
function squareRoots(m) {
|
|
97
|
+
let y = m;
|
|
98
|
+
let z = IDENTITY.cartesian;
|
|
99
|
+
for (let pass = 0; pass < IDEAL_PASSES; pass++) {
|
|
100
|
+
const nextY = scale(add(y, inverse(z)), 0.5);
|
|
101
|
+
const nextZ = scale(add(z, inverse(y)), 0.5);
|
|
102
|
+
const change = distance(nextY, y);
|
|
103
|
+
y = nextY;
|
|
104
|
+
z = nextZ;
|
|
105
|
+
if (change < IDEAL_SETTLED)
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
return [y, z];
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* The group generated by `operations` within `tolerance` (`closeWithin`, at most `MAX_GROUP_ORDER`
|
|
112
|
+
* elements), made exact: each matrix f(x) is replaced by the mean of f(xy)·f(y)⁻¹ over the group,
|
|
113
|
+
* repeated until nothing changes. For an exact group this is f(x) itself; for matrices that are a
|
|
114
|
+
* group only within a small error the passes settle on an exact representation nearby (tested in
|
|
115
|
+
* closure.test.ts and tensors/tolerance.test.ts), and the invariant metric of the result makes it
|
|
116
|
+
* orthogonal. Entries within 10⁻¹² of 0, ±1/2, ±√2/2, ±√3/2, ±1 are then set to them, so that exact
|
|
117
|
+
* input stays exact. Throws a RangeError if the operations generate more than `MAX_GROUP_ORDER`
|
|
118
|
+
* elements or do not settle into a group (a tolerance too large or too small for their errors).
|
|
119
|
+
*/
|
|
120
|
+
export function idealGroup(operations, tolerance) {
|
|
121
|
+
const group = closedGroup(operations, tolerance);
|
|
122
|
+
const n = group.length;
|
|
123
|
+
// The product table: the element nearest to each product, of the same time reversal, sought
|
|
124
|
+
// among the elements of its kind first and among all if none of them is near enough.
|
|
125
|
+
const byKind = new Map();
|
|
126
|
+
group.forEach((g, k) => {
|
|
127
|
+
const list = byKind.get(kindOf(g));
|
|
128
|
+
if (list)
|
|
129
|
+
list.push(k);
|
|
130
|
+
else
|
|
131
|
+
byKind.set(kindOf(g), [k]);
|
|
132
|
+
});
|
|
133
|
+
const all = group.map((_, k) => k);
|
|
134
|
+
const nearest = (product, candidates) => {
|
|
135
|
+
let best = -1;
|
|
136
|
+
let bestDistance = Infinity;
|
|
137
|
+
for (const k of candidates) {
|
|
138
|
+
if (group[k].timeReversal !== product.timeReversal)
|
|
139
|
+
continue;
|
|
140
|
+
const d = distance(group[k].cartesian, product.cartesian);
|
|
141
|
+
if (d < bestDistance) {
|
|
142
|
+
best = k;
|
|
143
|
+
bestDistance = d;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return bestDistance < PRODUCT_MATCH ? best : -1;
|
|
147
|
+
};
|
|
148
|
+
const table = group.map((a) => group.map((b) => {
|
|
149
|
+
const product = {
|
|
150
|
+
cartesian: multiply(a.cartesian, b.cartesian),
|
|
151
|
+
timeReversal: a.timeReversal !== b.timeReversal,
|
|
152
|
+
};
|
|
153
|
+
let k = nearest(product, byKind.get(kindOf(product)) ?? []);
|
|
154
|
+
if (k < 0)
|
|
155
|
+
k = nearest(product, all);
|
|
156
|
+
if (k < 0)
|
|
157
|
+
throw new RangeError(`The operations do not form a group within the tolerance ${tolerance}`);
|
|
158
|
+
return k;
|
|
159
|
+
}));
|
|
160
|
+
let f = group.map((g) => g.cartesian);
|
|
161
|
+
for (let pass = 0;; pass++) {
|
|
162
|
+
const inverses = f.map(inverse);
|
|
163
|
+
const next = f.map((_, x) => {
|
|
164
|
+
const sum = [
|
|
165
|
+
[0, 0, 0],
|
|
166
|
+
[0, 0, 0],
|
|
167
|
+
[0, 0, 0],
|
|
168
|
+
];
|
|
169
|
+
for (let y = 0; y < n; y++) {
|
|
170
|
+
const p = multiply(f[table[x][y]], inverses[y]);
|
|
171
|
+
for (let i = 0; i < 3; i++)
|
|
172
|
+
for (let j = 0; j < 3; j++)
|
|
173
|
+
sum[i][j] += p[i][j] / n;
|
|
174
|
+
}
|
|
175
|
+
return sum;
|
|
176
|
+
});
|
|
177
|
+
const change = Math.max(...next.map((m, k) => distance(m, f[k])));
|
|
178
|
+
f = next;
|
|
179
|
+
if (change < IDEAL_SETTLED)
|
|
180
|
+
break;
|
|
181
|
+
if (pass >= IDEAL_PASSES) {
|
|
182
|
+
if (change < IDEAL_UNSETTLED)
|
|
183
|
+
break;
|
|
184
|
+
throw new RangeError(`The operations do not settle into a group within the tolerance ${tolerance}`);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
// The representation is exact but need not be orthogonal: it may be an orthogonal one seen in a
|
|
188
|
+
// slightly oblique frame. Its invariant metric M = (1/n) Σ fᵀf gives that frame, and M^½ f M^-½
|
|
189
|
+
// is orthogonal.
|
|
190
|
+
const metric = f.reduce((sum, m) => add(sum, scale(multiply(transpose(m), m), 1 / n)), scale(IDENTITY.cartesian, 0));
|
|
191
|
+
const [root, inverseRoot] = squareRoots(metric);
|
|
192
|
+
f = f.map((m) => multiply(multiply(root, m), inverseRoot));
|
|
193
|
+
// Only rounding of the last bits is snapped: a group turned by a small angle has entries near the
|
|
194
|
+
// exact values that are not equal to them.
|
|
195
|
+
const exact = f.map((m, k) => ({ cartesian: snap(m, IDEAL_SNAP), timeReversal: group[k].timeReversal }));
|
|
196
|
+
return {
|
|
197
|
+
operations: exact,
|
|
198
|
+
deviation: Math.max(...exact.map((op, k) => distance(op.cartesian, group[k].cartesian))),
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
//# sourceMappingURL=closure.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"closure.js","sourceRoot":"","sources":["../src/closure.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAa,MAAM,aAAa,CAAC;AAExF,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAE1G,MAAM,QAAQ,GAAuB;IACnC,SAAS,EAAE;QACT,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QACT,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QACT,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;KACV;IACD,YAAY,EAAE,KAAK;CACpB,CAAC;AAEF,4GAA4G;AAC5G,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,CAAC;AAEnC,sGAAsG;AACtG,MAAM,UAAU,UAAU,CAAC,CAAqB,EAAE,CAAqB,EAAE,SAAiB;IACxF,OAAO,CACL,CAAC,CAAC,YAAY,KAAK,CAAC,CAAC,YAAY;QACjC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAChG,CAAC;AACJ,CAAC;AAED,wHAAwH;AACxH,MAAM,MAAM,GAAG,CAAC,EAAsB,EAAU,EAAE,CAChD,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,C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85), for d = 2 and d = 3 (#120, #137 G2). Internal; the
|
|
4
|
+
* entry points wrap it with their matrix types (docs/conventions.md, "Change of the coordinate
|
|
5
|
+
* system").
|
|
6
|
+
*
|
|
7
|
+
* The linear part P, the origin shift p and the operations (W, w) are read each number as the
|
|
8
|
+
* simplest fraction within the tolerance and transformed exactly, so that W′ = P⁻¹WP is exactly
|
|
9
|
+
* integral where it is and every result, the inverse pair included, is read back exactly; points,
|
|
10
|
+
* direction and plane coefficients and the metric are floating point.
|
|
11
|
+
*/
|
|
12
|
+
import { type ToleranceOptions } from './tolerances.js';
|
|
13
|
+
import type { Mat3, Vec3 } from './linalg.js';
|
|
14
|
+
/** A matrix as rows of numbers. */
|
|
15
|
+
type Rows = readonly (readonly number[])[];
|
|
16
|
+
/** The pair (P, p): the new basis (a′, b′, c′) = (a, b, c)·P and the new origin O′ = O + p. */
|
|
17
|
+
export interface GenericTransformation {
|
|
18
|
+
/** P, the linear part: its columns are the new basis vectors in the old basis (ITA eq. (1.5.1.4)). */
|
|
19
|
+
readonly linearPart: Rows;
|
|
20
|
+
/** p, the origin shift: the coordinates of the new origin in the old coordinate system; default zero. */
|
|
21
|
+
readonly originShift?: readonly number[];
|
|
22
|
+
}
|
|
23
|
+
/** An operation (W, w) in the lattice basis, x ↦ W·x + w. */
|
|
24
|
+
export interface GenericOperation {
|
|
25
|
+
/** The linear part W, integer entries. */
|
|
26
|
+
readonly matrix: Rows;
|
|
27
|
+
/** The translation part w; default zero (an operation of a point group). */
|
|
28
|
+
readonly translation?: readonly number[];
|
|
29
|
+
}
|
|
30
|
+
/** The quantities to transform; each is optional. */
|
|
31
|
+
export interface GenericQuantities {
|
|
32
|
+
/** Point coordinates x: x′ = P⁻¹(x − p), eq. (1.5.1.7). */
|
|
33
|
+
readonly points?: readonly (readonly number[])[];
|
|
34
|
+
/** Coefficients [uvw] of vectors (directions): [uvw]′ = P⁻¹[uvw], eq. (1.5.2.3). */
|
|
35
|
+
readonly directions?: readonly (readonly number[])[];
|
|
36
|
+
/** Miller indices (hkl) of planes, or coefficients of reciprocal vectors: (hkl)′ = (hkl)P, eq. (1.5.2.2). */
|
|
37
|
+
readonly planes?: readonly (readonly number[])[];
|
|
38
|
+
/** The metric tensor G: G′ = PᵀGP, eq. (1.5.2.4). */
|
|
39
|
+
readonly metric?: Rows;
|
|
40
|
+
/** Operations (W, w): W′ = P⁻¹WP, w′ = P⁻¹(w + (W − I)p), eqs. (1.5.2.12), (1.5.2.13). */
|
|
41
|
+
readonly operations?: readonly GenericOperation[];
|
|
42
|
+
}
|
|
43
|
+
/** The result: the inverse pair and every given quantity in the new coordinate system. */
|
|
44
|
+
export interface GenericChange {
|
|
45
|
+
/** The inverse pair (Q, q) = (P, p)⁻¹ = (P⁻¹, −P⁻¹p), eq. (1.5.1.7), which takes the new coordinates back. */
|
|
46
|
+
readonly inverse: {
|
|
47
|
+
readonly linearPart: Rows;
|
|
48
|
+
readonly originShift: readonly number[];
|
|
49
|
+
};
|
|
50
|
+
readonly points?: Rows;
|
|
51
|
+
readonly directions?: Rows;
|
|
52
|
+
readonly planes?: Rows;
|
|
53
|
+
readonly metric?: Rows;
|
|
54
|
+
readonly operations?: readonly {
|
|
55
|
+
readonly matrix: Rows;
|
|
56
|
+
readonly translation: readonly number[];
|
|
57
|
+
}[];
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* The change of the coordinate system (P, p) applied to the given quantities, in d = 2 or 3
|
|
61
|
+
* dimensions (ITA 2016 §§ 1.5.1.3, 1.5.2). `who` names the calling function in the messages.
|
|
62
|
+
*/
|
|
63
|
+
export declare function changeCoordinates(d: 2 | 3, transformation: GenericTransformation, quantities: GenericQuantities, options: ToleranceOptions | undefined, who: string): GenericChange;
|
|
64
|
+
/** A change of the coordinate system (P, p) (ITA 2016 § 1.5.1.3, p. 83): (a′, b′, c′) = (a, b, c)·P, origin O′ = O + p. */
|
|
65
|
+
export interface CoordinateTransformation {
|
|
66
|
+
/** P, the linear part: its columns are the new basis vectors a′, b′, c′ in the old basis (eq. (1.5.1.4)); det P ≠ 0, also negative. */
|
|
67
|
+
readonly linearPart: Mat3;
|
|
68
|
+
/** p, the origin shift: the coordinates of the new origin in the old coordinate system; default zero. */
|
|
69
|
+
readonly originShift?: Vec3;
|
|
70
|
+
}
|
|
71
|
+
/** An operation (W, w) in the lattice basis, x ↦ W·x + w; a record of `operations` passes as it is. */
|
|
72
|
+
export interface AffineOperation {
|
|
73
|
+
/** The linear part W, integer entries. */
|
|
74
|
+
readonly matrix: Mat3;
|
|
75
|
+
/** The translation part w; default zero, as for the operations of a point group. */
|
|
76
|
+
readonly translation?: Vec3;
|
|
77
|
+
}
|
|
78
|
+
/** An operation (W′, w′) in the new coordinate system. */
|
|
79
|
+
export interface TransformedOperation {
|
|
80
|
+
/** W′ = P⁻¹WP, integer entries. */
|
|
81
|
+
readonly matrix: Mat3;
|
|
82
|
+
/** w′ = P⁻¹(w + (W − I)p), not reduced modulo the lattice. */
|
|
83
|
+
readonly translation: Vec3;
|
|
84
|
+
}
|
|
85
|
+
/** The quantities that `changeOfCoordinates` transforms; each is optional. */
|
|
86
|
+
export interface CoordinateQuantities {
|
|
87
|
+
/** Point coordinates x: x′ = P⁻¹(x − p) (eq. (1.5.1.7)). */
|
|
88
|
+
readonly points?: readonly Vec3[];
|
|
89
|
+
/** Coefficients [uvw] of vectors, e.g. directions: [uvw]′ = P⁻¹[uvw] (eq. (1.5.2.3)); not changed by the origin shift. */
|
|
90
|
+
readonly directions?: readonly Vec3[];
|
|
91
|
+
/** Miller indices (hkl) of planes: (hkl)′ = (hkl)P (eq. (1.5.2.2)); not changed by the origin shift. */
|
|
92
|
+
readonly planes?: readonly Vec3[];
|
|
93
|
+
/** The metric tensor G: G′ = PᵀGP (eq. (1.5.2.4)). */
|
|
94
|
+
readonly metric?: Mat3;
|
|
95
|
+
/** Operations (W, w): W′ = P⁻¹WP, w′ = P⁻¹(w + (W − I)p) (eqs. (1.5.2.12), (1.5.2.13)). */
|
|
96
|
+
readonly operations?: readonly AffineOperation[];
|
|
97
|
+
}
|
|
98
|
+
/** The inverse change of the coordinate system (Q, q) = (P, p)⁻¹. */
|
|
99
|
+
export interface InverseTransformation {
|
|
100
|
+
/** Q = P⁻¹. */
|
|
101
|
+
readonly linearPart: Mat3;
|
|
102
|
+
/** q = −P⁻¹p. */
|
|
103
|
+
readonly originShift: Vec3;
|
|
104
|
+
}
|
|
105
|
+
/** The result of `changeOfCoordinates`: the inverse pair and each given quantity in the new coordinate system. */
|
|
106
|
+
export interface CoordinateChange {
|
|
107
|
+
/** (Q, q) = (P⁻¹, −P⁻¹p), which takes the new coordinates back to the old (eq. (1.5.1.7)). */
|
|
108
|
+
readonly inverse: InverseTransformation;
|
|
109
|
+
/** The points, as given, in the new coordinates. */
|
|
110
|
+
readonly points?: readonly Vec3[];
|
|
111
|
+
/** The vector coefficients, as given, in the new basis. */
|
|
112
|
+
readonly directions?: readonly Vec3[];
|
|
113
|
+
/** The Miller indices, as given, in the new basis. */
|
|
114
|
+
readonly planes?: readonly Vec3[];
|
|
115
|
+
/** The metric tensor in the new basis. */
|
|
116
|
+
readonly metric?: Mat3;
|
|
117
|
+
/** The operations, as given, in the new coordinate system. */
|
|
118
|
+
readonly operations?: readonly TransformedOperation[];
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Changes the coordinate system by the pair (P, p) of ITA (6th ed., 2016) § 1.5.1.3 (p. 83): the
|
|
122
|
+
* new basis is (a′, b′, c′) = (a, b, c)·P and the new origin lies at p. Transforms the given
|
|
123
|
+
* quantities by ITA's equations (§ 1.5.2, pp. 83–85): point coordinates x′ = P⁻¹(x − p), vector
|
|
124
|
+
* coefficients [uvw]′ = P⁻¹[uvw], Miller indices (hkl)′ = (hkl)P, the metric tensor G′ = PᵀGP, and
|
|
125
|
+
* operations W′ = P⁻¹WP, w′ = P⁻¹(w + (W − I)p); and gives the inverse pair (Q, q) = (P⁻¹, −P⁻¹p).
|
|
126
|
+
* det P may be negative (a change of handedness, which ITA allows; § 1.5.1.2, p. 76).
|
|
127
|
+
*
|
|
128
|
+
* P, p and the operations are read each number as the simplest fraction within the tolerance
|
|
129
|
+
* (default `EPSILON`; 0.3333333 is 1/3) and transformed exactly, so that every result, the inverse
|
|
130
|
+
* pair included, can be passed back; the other quantities are floating point. P is rational in a
|
|
131
|
+
* change between lattice bases, as in ITA; an irrational P (a rotation by 30°) is read as the
|
|
132
|
+
* nearby fractions, about as exact as the tolerance, and a much smaller tolerance can make the exact
|
|
133
|
+
* products leave the safe integers, a RangeError.
|
|
134
|
+
* A transformed
|
|
135
|
+
* operation is `{ matrix, translation }` alone: other fields of the record (`cartesian`, in the
|
|
136
|
+
* magnetic API `timeReversal`) are not carried over, so they are matched by index. Throws a
|
|
137
|
+
* RangeError for a singular P, a quantity of the wrong shape, an unknown quantity, an operation with
|
|
138
|
+
* det W ≠ ±1, and one whose W′ is not integral (the new basis does not span a lattice that the
|
|
139
|
+
* operation maps onto itself).
|
|
140
|
+
*/
|
|
141
|
+
export declare function changeOfCoordinates(transformation: CoordinateTransformation, quantities: CoordinateQuantities, options?: ToleranceOptions): CoordinateChange;
|
|
142
|
+
export {};
|
|
143
|
+
//# sourceMappingURL=coordinates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coordinates.d.ts","sourceRoot":"","sources":["../src/coordinates.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAAe,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAErE,OAAO,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAe9C,mCAAmC;AACnC,KAAK,IAAI,GAAG,SAAS,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,CAAC;AAG3C,+FAA+F;AAC/F,MAAM,WAAW,qBAAqB;IACpC,sGAAsG;IACtG,QAAQ,CAAC,UAAU,EAAE,IAAI,CAAC;IAC1B,yGAAyG;IACzG,QAAQ,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pC,eAAe;IACf,QAAQ,CAAC,UAAU,EAAE,IAAI,CAAC;IAC1B,iBAAiB;IACjB,QAAQ,CAAC,WAAW,EAAE,IAAI,CAAC;CAC5B;AAED,kHAAkH;AAClH,MAAM,WAAW,gBAAgB;IAC/B,8FAA8F;IAC9F,QAAQ,CAAC,OAAO,EAAE,qBAAqB,CAAC;IACxC,oDAAoD;IACpD,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,IAAI,EAAE,CAAC;IAClC,2DAA2D;IAC3D,QAAQ,CAAC,UAAU,CAAC,EAAE,SAAS,IAAI,EAAE,CAAC;IACtC,sDAAsD;IACtD,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,IAAI,EAAE,CAAC;IAClC,0CAA0C;IAC1C,QAAQ,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC;IACvB,8DAA8D;IAC9D,QAAQ,CAAC,UAAU,CAAC,EAAE,SAAS,oBAAoB,EAAE,CAAC;CACvD;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,mBAAmB,CACjC,cAAc,EAAE,wBAAwB,EACxC,UAAU,EAAE,oBAAoB,EAChC,OAAO,CAAC,EAAE,gBAAgB,GACzB,gBAAgB,CAIlB"}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The change of the coordinate system by a matrix–column pair (P, p) after ITA (6th ed., 2016)
|
|
3
|
+
* Chapter 1.5 (§§ 1.5.1.3, 1.5.2, pp. 83–85), for d = 2 and d = 3 (#120, #137 G2). Internal; the
|
|
4
|
+
* entry points wrap it with their matrix types (docs/conventions.md, "Change of the coordinate
|
|
5
|
+
* system").
|
|
6
|
+
*
|
|
7
|
+
* The linear part P, the origin shift p and the operations (W, w) are read each number as the
|
|
8
|
+
* simplest fraction within the tolerance and transformed exactly, so that W′ = P⁻¹WP is exactly
|
|
9
|
+
* integral where it is and every result, the inverse pair included, is read back exactly; points,
|
|
10
|
+
* direction and plane coefficients and the metric are floating point.
|
|
11
|
+
*/
|
|
12
|
+
import { checkObject, checkOptions, shown, TOLERANCE_KEYS } from './checks.js';
|
|
13
|
+
import { toleranceOf } from './tolerances.js';
|
|
14
|
+
import { deepFreeze } from './freeze.js';
|
|
15
|
+
import { ONE, add, isInteger, multiply, simplestFraction, negate, rational, subtract, toNumber, ZERO, } from './spaceGroups/rational.js';
|
|
16
|
+
const QUANTITY_KEYS = ['points', 'directions', 'planes', 'metric', 'operations'];
|
|
17
|
+
function isRows(m, d) {
|
|
18
|
+
return (Array.isArray(m) &&
|
|
19
|
+
m.length === d &&
|
|
20
|
+
m.every((r) => Array.isArray(r) && r.length === d && r.every((x) => typeof x === 'number' && Number.isFinite(x))));
|
|
21
|
+
}
|
|
22
|
+
function isVector(v, d) {
|
|
23
|
+
return Array.isArray(v) && v.length === d && v.every((x) => typeof x === 'number' && Number.isFinite(x));
|
|
24
|
+
}
|
|
25
|
+
function product(a, b) {
|
|
26
|
+
return a.map((row) => b[0].map((_, j) => row.reduce((s, x, k) => add(s, multiply(x, b[k][j])), ZERO)));
|
|
27
|
+
}
|
|
28
|
+
function apply(a, v) {
|
|
29
|
+
return a.map((row) => row.reduce((s, x, k) => add(s, multiply(x, v[k])), ZERO));
|
|
30
|
+
}
|
|
31
|
+
/** The determinant of a 2 × 2 or 3 × 3 rational matrix. */
|
|
32
|
+
function determinant(m) {
|
|
33
|
+
const t = (i, j) => m[i][j];
|
|
34
|
+
if (m.length === 2)
|
|
35
|
+
return subtract(multiply(t(0, 0), t(1, 1)), multiply(t(0, 1), t(1, 0)));
|
|
36
|
+
const minor = (i, j, k, l) => subtract(multiply(t(i, j), t(k, l)), multiply(t(i, l), t(k, j)));
|
|
37
|
+
return add(subtract(multiply(t(0, 0), minor(1, 1, 2, 2)), multiply(t(0, 1), minor(1, 0, 2, 2))), multiply(t(0, 2), minor(1, 0, 2, 1)));
|
|
38
|
+
}
|
|
39
|
+
/** The inverse of a regular 2 × 2 or 3 × 3 rational matrix, by the adjugate. */
|
|
40
|
+
function inverse(m) {
|
|
41
|
+
const det = determinant(m);
|
|
42
|
+
const over = (x) => multiply(x, rational(det[1], det[0]));
|
|
43
|
+
if (m.length === 2) {
|
|
44
|
+
return [
|
|
45
|
+
[over(m[1][1]), over(negate(m[0][1]))],
|
|
46
|
+
[over(negate(m[1][0])), over(m[0][0])],
|
|
47
|
+
];
|
|
48
|
+
}
|
|
49
|
+
const c = (i, j) => {
|
|
50
|
+
const rows = [0, 1, 2].filter((r) => r !== i);
|
|
51
|
+
const cols = [0, 1, 2].filter((k) => k !== j);
|
|
52
|
+
const minor = subtract(multiply(m[rows[0]][cols[0]], m[rows[1]][cols[1]]), multiply(m[rows[0]][cols[1]], m[rows[1]][cols[0]]));
|
|
53
|
+
return (i + j) % 2 === 0 ? minor : negate(minor);
|
|
54
|
+
};
|
|
55
|
+
// The inverse is the transposed matrix of cofactors over the determinant.
|
|
56
|
+
return [0, 1, 2].map((i) => [0, 1, 2].map((j) => over(c(j, i))));
|
|
57
|
+
}
|
|
58
|
+
const numbers = (v) => v.map((x) => toNumber(x) + 0);
|
|
59
|
+
const floats = (m) => m.map((row) => numbers(row));
|
|
60
|
+
function floatProduct(a, b) {
|
|
61
|
+
return a.map((row) => b[0].map((_, j) => row.reduce((s, x, k) => s + x * b[k][j], 0) + 0));
|
|
62
|
+
}
|
|
63
|
+
function floatApply(a, v) {
|
|
64
|
+
return a.map((row) => row.reduce((s, x, k) => s + x * v[k], 0) + 0);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* The change of the coordinate system (P, p) applied to the given quantities, in d = 2 or 3
|
|
68
|
+
* dimensions (ITA 2016 §§ 1.5.1.3, 1.5.2). `who` names the calling function in the messages.
|
|
69
|
+
*/
|
|
70
|
+
export function changeCoordinates(d, transformation, quantities, options, who) {
|
|
71
|
+
try {
|
|
72
|
+
return transform(d, transformation, quantities, options, who);
|
|
73
|
+
}
|
|
74
|
+
catch (e) {
|
|
75
|
+
// Exact arithmetic that leaves the safe integers names the function too.
|
|
76
|
+
if (e instanceof RangeError && !e.message.startsWith(`${who}`))
|
|
77
|
+
throw new RangeError(`${who}: ${e.message}`, { cause: e });
|
|
78
|
+
throw e;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
function transform(d, transformation, quantities, options, who) {
|
|
82
|
+
checkOptions(options, TOLERANCE_KEYS, who);
|
|
83
|
+
const tolerance = toleranceOf(options, 'operations');
|
|
84
|
+
checkObject(transformation, `${who} takes the transformation { linearPart, originShift }`);
|
|
85
|
+
checkObject(quantities, `${who} takes the quantities { ${QUANTITY_KEYS.join(', ')} }`);
|
|
86
|
+
for (const key of Object.keys(transformation)) {
|
|
87
|
+
if (key !== 'linearPart' && key !== 'originShift') {
|
|
88
|
+
throw new RangeError(`${who}: unknown field ${shown(key)} of the transformation (linearPart, originShift)`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
for (const key of Object.keys(quantities)) {
|
|
92
|
+
if (!QUANTITY_KEYS.includes(key)) {
|
|
93
|
+
throw new RangeError(`${who}: unknown quantity ${shown(key)} (${QUANTITY_KEYS.join(', ')})`);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
const P0 = transformation.linearPart;
|
|
97
|
+
if (!isRows(P0, d))
|
|
98
|
+
throw new RangeError(`${who}: the linear part P must be a ${d} × ${d} matrix, not ${shown(P0)}`);
|
|
99
|
+
const fraction = (x, what) => simplestFraction(x, tolerance, what);
|
|
100
|
+
const P = P0.map((row) => row.map((x) => fraction(x, 'entry of P')));
|
|
101
|
+
if (determinant(P)[0] === 0)
|
|
102
|
+
throw new RangeError(`${who}: the linear part P is singular (det P = 0)`);
|
|
103
|
+
// Only a missing origin shift is zero; null is a wrong value, not a missing one.
|
|
104
|
+
const shift0 = transformation.originShift === undefined ? Array.from({ length: d }, () => 0) : transformation.originShift;
|
|
105
|
+
if (!isVector(shift0, d))
|
|
106
|
+
throw new RangeError(`${who}: the origin shift p must be ${d} numbers, not ${shown(shift0)}`);
|
|
107
|
+
const p = shift0.map((x) => fraction(x, 'coordinate of p'));
|
|
108
|
+
const Q = inverse(P);
|
|
109
|
+
const q = apply(Q, p).map(negate);
|
|
110
|
+
const Pf = floats(P);
|
|
111
|
+
const Qf = floats(Q);
|
|
112
|
+
const pf = numbers(p);
|
|
113
|
+
const vectors = (name, list) => {
|
|
114
|
+
if (!Array.isArray(list) || !list.every((v) => isVector(v, d))) {
|
|
115
|
+
throw new RangeError(`${who}: ${name} must be a list of vectors of ${d} numbers, not ${shown(list)}`);
|
|
116
|
+
}
|
|
117
|
+
return list;
|
|
118
|
+
};
|
|
119
|
+
const result = { inverse: { linearPart: floats(Q), originShift: numbers(q) } };
|
|
120
|
+
if (quantities.points !== undefined) {
|
|
121
|
+
result.points = vectors('points', quantities.points).map((x) => floatApply(Qf, x.map((xi, i) => xi - pf[i])));
|
|
122
|
+
}
|
|
123
|
+
if (quantities.directions !== undefined) {
|
|
124
|
+
result.directions = vectors('directions', quantities.directions).map((u) => floatApply(Qf, u));
|
|
125
|
+
}
|
|
126
|
+
if (quantities.planes !== undefined) {
|
|
127
|
+
// A row (hkl) times P: the j-th index is Σ_i h_i P_ij.
|
|
128
|
+
result.planes = vectors('planes', quantities.planes).map((h) => Pf[0].map((_, j) => h.reduce((s, hi, i) => s + hi * Pf[i][j], 0) + 0));
|
|
129
|
+
}
|
|
130
|
+
if (quantities.metric !== undefined) {
|
|
131
|
+
const G = quantities.metric;
|
|
132
|
+
if (!isRows(G, d))
|
|
133
|
+
throw new RangeError(`${who}: the metric must be a ${d} × ${d} matrix, not ${shown(G)}`);
|
|
134
|
+
const Pt = Pf[0].map((_, j) => Pf.map((row) => row[j]));
|
|
135
|
+
result.metric = floatProduct(floatProduct(Pt, G), Pf);
|
|
136
|
+
}
|
|
137
|
+
if (quantities.operations !== undefined) {
|
|
138
|
+
const ops = quantities.operations;
|
|
139
|
+
if (!Array.isArray(ops))
|
|
140
|
+
throw new RangeError(`${who}: operations must be a list, not ${shown(ops)}`);
|
|
141
|
+
result.operations = ops.map((op, n) => {
|
|
142
|
+
checkObject(op, `${who}: operation ${n + 1} is a record { matrix, translation }`);
|
|
143
|
+
const { matrix, translation } = op;
|
|
144
|
+
if (!isRows(matrix, d)) {
|
|
145
|
+
throw new RangeError(`${who}: the matrix W of operation ${n + 1} must be ${d} × ${d}, not ${shown(matrix)}`);
|
|
146
|
+
}
|
|
147
|
+
const W = matrix.map((row) => row.map((x) => {
|
|
148
|
+
if (Math.abs(x - Math.round(x)) >= tolerance) {
|
|
149
|
+
throw new RangeError(`${who}: the matrix W of operation ${n + 1} has integer entries, not ${shown(matrix)}`);
|
|
150
|
+
}
|
|
151
|
+
return rational(Math.round(x));
|
|
152
|
+
}));
|
|
153
|
+
if (determinant(W)[1] !== 1 || Math.abs(determinant(W)[0]) !== 1) {
|
|
154
|
+
throw new RangeError(`${who}: the matrix W of operation ${n + 1} has det W = ±1, not ${shown(matrix)}`);
|
|
155
|
+
}
|
|
156
|
+
const t0 = translation === undefined ? Array.from({ length: d }, () => 0) : translation;
|
|
157
|
+
if (!isVector(t0, d)) {
|
|
158
|
+
throw new RangeError(`${who}: the translation of operation ${n + 1} must be ${d} numbers, not ${shown(t0)}`);
|
|
159
|
+
}
|
|
160
|
+
const w = t0.map((x) => fraction(x, 'translation'));
|
|
161
|
+
const W1 = product(product(Q, W), P);
|
|
162
|
+
if (!W1.every((row) => row.every(isInteger))) {
|
|
163
|
+
throw new RangeError(`${who}: operation ${n + 1} has no integral matrix in the new basis (P⁻¹WP = ${shown(floats(W1))}): ` +
|
|
164
|
+
'the new basis does not span a lattice that the operation maps onto itself');
|
|
165
|
+
}
|
|
166
|
+
// w′ = Q(w + (W − I)p)
|
|
167
|
+
const WminusI = W.map((row, i) => row.map((x, j) => (i === j ? subtract(x, ONE) : x)));
|
|
168
|
+
const shifted = apply(WminusI, p).map((x, i) => add(w[i], x));
|
|
169
|
+
return { matrix: floats(W1), translation: numbers(apply(Q, shifted)) };
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
return result;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Changes the coordinate system by the pair (P, p) of ITA (6th ed., 2016) § 1.5.1.3 (p. 83): the
|
|
176
|
+
* new basis is (a′, b′, c′) = (a, b, c)·P and the new origin lies at p. Transforms the given
|
|
177
|
+
* quantities by ITA's equations (§ 1.5.2, pp. 83–85): point coordinates x′ = P⁻¹(x − p), vector
|
|
178
|
+
* coefficients [uvw]′ = P⁻¹[uvw], Miller indices (hkl)′ = (hkl)P, the metric tensor G′ = PᵀGP, and
|
|
179
|
+
* operations W′ = P⁻¹WP, w′ = P⁻¹(w + (W − I)p); and gives the inverse pair (Q, q) = (P⁻¹, −P⁻¹p).
|
|
180
|
+
* det P may be negative (a change of handedness, which ITA allows; § 1.5.1.2, p. 76).
|
|
181
|
+
*
|
|
182
|
+
* P, p and the operations are read each number as the simplest fraction within the tolerance
|
|
183
|
+
* (default `EPSILON`; 0.3333333 is 1/3) and transformed exactly, so that every result, the inverse
|
|
184
|
+
* pair included, can be passed back; the other quantities are floating point. P is rational in a
|
|
185
|
+
* change between lattice bases, as in ITA; an irrational P (a rotation by 30°) is read as the
|
|
186
|
+
* nearby fractions, about as exact as the tolerance, and a much smaller tolerance can make the exact
|
|
187
|
+
* products leave the safe integers, a RangeError.
|
|
188
|
+
* A transformed
|
|
189
|
+
* operation is `{ matrix, translation }` alone: other fields of the record (`cartesian`, in the
|
|
190
|
+
* magnetic API `timeReversal`) are not carried over, so they are matched by index. Throws a
|
|
191
|
+
* RangeError for a singular P, a quantity of the wrong shape, an unknown quantity, an operation with
|
|
192
|
+
* det W ≠ ±1, and one whose W′ is not integral (the new basis does not span a lattice that the
|
|
193
|
+
* operation maps onto itself).
|
|
194
|
+
*/
|
|
195
|
+
export function changeOfCoordinates(transformation, quantities, options) {
|
|
196
|
+
return deepFreeze(changeCoordinates(3, transformation, quantities, options, 'changeOfCoordinates'));
|
|
197
|
+
}
|
|
198
|
+
//# source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