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/src/plane.ts
CHANGED
|
@@ -10,10 +10,26 @@
|
|
|
10
10
|
* `tolerance` (docs/conventions.md, "Plane groups").
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
13
|
+
import { TOLERANCE_KEYS, checkOptions, shown } from './checks.js';
|
|
14
|
+
import { describePlaneOperation, type PlaneOperationKind } from './spaceGroups/describe.js';
|
|
15
|
+
import { planeAsymmetricUnit, planeElements, planeElementsInBox } from './spaceGroups/cell.js';
|
|
15
16
|
import { toPlain, type ExactOperation } from './spaceGroups/affine.js';
|
|
16
17
|
import { type PlaneSystem } from './spaceGroups/planeGroupData.js';
|
|
18
|
+
import {
|
|
19
|
+
PLANE_FAMILIES,
|
|
20
|
+
planeBravaisLattice,
|
|
21
|
+
planeLatticeFromParameters,
|
|
22
|
+
planeLatticeParameters,
|
|
23
|
+
planeLaueClass,
|
|
24
|
+
planeMetricTensor,
|
|
25
|
+
planeReciprocalBasis,
|
|
26
|
+
type CellRestrictions,
|
|
27
|
+
type LatticeParameters,
|
|
28
|
+
type Mat2,
|
|
29
|
+
type PlaneBravaisLattice,
|
|
30
|
+
} from './spaceGroups/planeLattice.js';
|
|
31
|
+
import { deepFreeze } from './freeze.js';
|
|
32
|
+
import { changeCoordinates } from './coordinates.js';
|
|
17
33
|
import {
|
|
18
34
|
PLANE_GROUP_KEYS as GROUP_KEYS,
|
|
19
35
|
planeGroupEntry,
|
|
@@ -31,12 +47,29 @@ import {
|
|
|
31
47
|
planePointGroupSystem,
|
|
32
48
|
type PlanePointGroupKey,
|
|
33
49
|
} from './spaceGroups/planePointGroups.js';
|
|
34
|
-
import {
|
|
35
|
-
|
|
36
|
-
|
|
50
|
+
import {
|
|
51
|
+
planeMetric,
|
|
52
|
+
planeOrbit,
|
|
53
|
+
planeSiteOfPosition,
|
|
54
|
+
planeWyckoffDistances,
|
|
55
|
+
planeWyckoffPositionOf,
|
|
56
|
+
} from './spaceGroups/positions.js';
|
|
57
|
+
import { nearestFraction, parseRational, toNumber, type Rational } from './spaceGroups/rational.js';
|
|
37
58
|
|
|
38
59
|
export { VERSION } from './version.js';
|
|
60
|
+
export { EPSILON, type ToleranceOptions } from './tolerances.js';
|
|
61
|
+
import { toleranceOf, type ToleranceOptions } from './tolerances.js';
|
|
62
|
+
import { compactSymbol } from './notation.js';
|
|
39
63
|
export type { PlaneSystem } from './spaceGroups/planeGroupData.js';
|
|
64
|
+
export type {
|
|
65
|
+
CellRestrictions,
|
|
66
|
+
LatticeParameters,
|
|
67
|
+
Mat2,
|
|
68
|
+
PlaneBravaisLattice,
|
|
69
|
+
PlaneCellParameter,
|
|
70
|
+
PlaneFixedAngles,
|
|
71
|
+
} from './spaceGroups/planeLattice.js';
|
|
72
|
+
export type { PlaneOperationKind } from './spaceGroups/describe.js';
|
|
40
73
|
|
|
41
74
|
/** The short symbol of a plane group, e.g. `'p2mg'`. */
|
|
42
75
|
export type PlaneGroupKey =
|
|
@@ -69,17 +102,18 @@ export const POINT_GROUP_KEYS: readonly PointGroupKey[] = Object.freeze([...PLAN
|
|
|
69
102
|
|
|
70
103
|
/** Options that choose the setting of a plane point group. */
|
|
71
104
|
export interface SettingOptions {
|
|
72
|
-
/** 1-based setting: for the point group `3m` 1 is `3m1` (default) and 2 is `31m`; the other point groups have one, and a plane group takes only 1. */
|
|
73
|
-
readonly setting?: number;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/** Options of the functions that take a point. */
|
|
77
|
-
export interface PointOptions {
|
|
78
105
|
/**
|
|
79
|
-
*
|
|
80
|
-
*
|
|
106
|
+
* The setting, by its 1-based index or its symbol (spaces ignored): for the point group `3m` 1 or
|
|
107
|
+
* `'3m1'` (default) and 2 or `'31m'`, and the key `'3m'` names the default; the other point groups
|
|
108
|
+
* have one, and a plane group takes only 1 or its own symbol (short or full).
|
|
81
109
|
*/
|
|
82
|
-
readonly
|
|
110
|
+
readonly setting?: number | string;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** Options of `symbol`: the setting, and the form of a plane group's symbol. */
|
|
114
|
+
export interface SymbolOptions extends SettingOptions {
|
|
115
|
+
/** `'short'` (default): the symbol as one word, the key; `'full'`: the full symbol, positions separated by spaces (`'p 1 m 1'` for `pm`). */
|
|
116
|
+
readonly form?: 'short' | 'full';
|
|
83
117
|
}
|
|
84
118
|
|
|
85
119
|
/** An operation (W, w) in the lattice basis: x ↦ W·x + w. */
|
|
@@ -96,20 +130,23 @@ export interface PlaneGroup {
|
|
|
96
130
|
readonly key: PlaneGroupKey;
|
|
97
131
|
/** The number of the plane group, 1 to 17. */
|
|
98
132
|
readonly number: number;
|
|
99
|
-
/** The full symbol as ITA prints it, e.g. `'p2mg'` or `'p1m1'`. */
|
|
100
|
-
readonly fullSymbol: string;
|
|
101
133
|
/** The plane point group. */
|
|
102
134
|
readonly pointGroup: PointGroupKey;
|
|
103
135
|
/** The setting of the point group: 2 for `p31m`, otherwise 1. */
|
|
104
136
|
readonly pointGroupSetting: number;
|
|
105
137
|
/** The crystal system. */
|
|
106
138
|
readonly crystalSystem: PlaneSystem;
|
|
139
|
+
/** The Bravais lattice (ITA 2016 Table 2.1.1.1, p. 143): `'mp'`, `'op'`, `'oc'`, `'tp'` or `'hp'`. */
|
|
140
|
+
readonly bravaisLattice: PlaneBravaisLattice;
|
|
141
|
+
/**
|
|
142
|
+
* The Patterson symmetry as ITA prints it in the headline of the group (Chapter 2.2), a plane group:
|
|
143
|
+
* the lattice of the group with its Laue class, e.g. `'p2mm'` for `p2mg`, `'c2mm'` for `cm`.
|
|
144
|
+
*/
|
|
145
|
+
readonly pattersonSymmetry: PlaneGroupKey;
|
|
107
146
|
/** The centring translations besides (0, 0): `[[0.5, 0.5]]` for `cm` and `c2mm`, otherwise none. */
|
|
108
147
|
readonly centring: readonly (readonly number[])[];
|
|
109
|
-
/** The block "Origin" as ITA prints it, e.g. `'at
|
|
148
|
+
/** The block "Origin" as ITA prints it, its positions spaced as printed, e.g. `'at 2 m m'`, `'at 2 1 g'`. */
|
|
110
149
|
readonly origin: string;
|
|
111
|
-
/** The order of the group modulo the lattice: the number of `operations`. */
|
|
112
|
-
readonly order: number;
|
|
113
150
|
}
|
|
114
151
|
|
|
115
152
|
/** A plane point group. */
|
|
@@ -120,6 +157,25 @@ export interface PointGroup {
|
|
|
120
157
|
readonly crystalSystem: PlaneSystem;
|
|
121
158
|
/** The order of the group. */
|
|
122
159
|
readonly order: number;
|
|
160
|
+
/**
|
|
161
|
+
* The Laue class: the point group with the symmetry centre of the plane, the twofold rotation,
|
|
162
|
+
* added (ITA 2016 § 3.2.1.1, p. 720); one of `'2'`, `'2mm'`, `'4'`, `'4mm'`, `'6'`, `'6mm'`.
|
|
163
|
+
*/
|
|
164
|
+
readonly laueClass: PointGroupKey;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/** A plane group found by `findPlaneGroup`. */
|
|
168
|
+
export interface PlaneGroupFound {
|
|
169
|
+
/** The key of the plane group. */
|
|
170
|
+
readonly key: PlaneGroupKey;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/** A plane point group in a setting, as `findPointGroup` finds it. */
|
|
174
|
+
export interface PointGroupInSetting {
|
|
175
|
+
/** The key of the plane point group. */
|
|
176
|
+
readonly key: PointGroupKey;
|
|
177
|
+
/** The 1-based index of the setting. */
|
|
178
|
+
readonly setting: number;
|
|
123
179
|
}
|
|
124
180
|
|
|
125
181
|
/** A setting of a plane point group. */
|
|
@@ -129,15 +185,18 @@ export interface Setting {
|
|
|
129
185
|
/** Its symbol: `'3m1'` or `'31m'` for `3m`, otherwise the key. */
|
|
130
186
|
readonly symbol: string;
|
|
131
187
|
/** True for the default setting (setting 1). */
|
|
132
|
-
readonly
|
|
188
|
+
readonly isDefault: boolean;
|
|
133
189
|
}
|
|
134
190
|
|
|
135
191
|
/** What an operation is, geometrically, as ITA describes it under "Symmetry operations". */
|
|
136
192
|
export interface OperationDescription {
|
|
137
|
-
/**
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
193
|
+
/**
|
|
194
|
+
* `'identity'`, `'translation'`, `'rotation'`, `'reflection'` (in a line) or `'glide-reflection'`,
|
|
195
|
+
* as ITA names the operations (ITA 2016 Table 2.1.2.1, p. 145).
|
|
196
|
+
*/
|
|
197
|
+
readonly kind: PlaneOperationKind;
|
|
198
|
+
/** The n of the linear part (an n-fold rotation): 1 for the identity and a translation, 2 for a reflection or glide reflection. */
|
|
199
|
+
readonly n: number;
|
|
141
200
|
/** For a rotation of order 3 or more: `'+'` if it turns a towards b, `'-'` otherwise. */
|
|
142
201
|
readonly sense?: '+' | '-';
|
|
143
202
|
/** For a translation: the translation vector. */
|
|
@@ -150,12 +209,14 @@ export interface OperationDescription {
|
|
|
150
209
|
/** For a mirror or glide: the direction of its line, the shortest integer vector, first non-zero component positive. */
|
|
151
210
|
readonly direction?: readonly number[];
|
|
152
211
|
/**
|
|
153
|
-
* For a
|
|
154
|
-
*
|
|
155
|
-
*
|
|
212
|
+
* For a reflection or glide reflection: its axis, the normal of its line in the lattice basis (as
|
|
213
|
+
* the `axis` of a reflection of the point groups is the normal of its plane, #137 C3), its symmetry
|
|
214
|
+
* direction with the sign of its Seitz symbol (ITA 2016 Tables 1.4.2.4, 1.4.2.5, p. 53: `m₁₀`, `m₁₂`,
|
|
215
|
+
* #107, #114): the shortest integer vector along the columns of W − I, first non-zero component
|
|
216
|
+
* positive, which is the Seitz direction for every plane group (tested). Without a metric it is not the perpendicular of `direction`: in a hexagonal
|
|
156
217
|
* basis the normal of a line along [1,0] is [1,2].
|
|
157
218
|
*/
|
|
158
|
-
readonly
|
|
219
|
+
readonly axis?: readonly number[];
|
|
159
220
|
/** For a glide: the glide vector (w + W·w)/2, not reduced modulo the lattice. */
|
|
160
221
|
readonly glide?: readonly number[];
|
|
161
222
|
}
|
|
@@ -172,17 +233,34 @@ export interface WyckoffPosition {
|
|
|
172
233
|
readonly coordinates: readonly string[];
|
|
173
234
|
}
|
|
174
235
|
|
|
175
|
-
/**
|
|
176
|
-
export interface
|
|
177
|
-
/** The point
|
|
236
|
+
/** The distance of a point to a Wyckoff position: the position, as `wyckoffPositions` gives it, the nearest point of it, and the distance. */
|
|
237
|
+
export interface WyckoffDistance extends WyckoffPosition {
|
|
238
|
+
/** The point of the position nearest to the given one (lattice basis), modulo the lattice, in [0, 1). */
|
|
178
239
|
readonly point: readonly number[];
|
|
240
|
+
/**
|
|
241
|
+
* The distance of the given point to the position: without a basis the larger of the two
|
|
242
|
+
* coordinate differences modulo the lattice, with a basis Euclidean in its unit.
|
|
243
|
+
*/
|
|
244
|
+
readonly distance: number;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/** Options of `wyckoffDistances`. */
|
|
248
|
+
export interface WyckoffDistanceOptions {
|
|
249
|
+
/**
|
|
250
|
+
* The Cartesian basis of the lattice, a 2 × 2 matrix whose columns are a and b; with it the
|
|
251
|
+
* distances are Euclidean, without it they are measured per lattice coordinate.
|
|
252
|
+
*/
|
|
253
|
+
readonly basis?: readonly (readonly number[])[];
|
|
179
254
|
}
|
|
180
255
|
|
|
181
256
|
/** The site symmetry of a point under a plane group. */
|
|
182
257
|
export interface SiteSymmetry {
|
|
183
258
|
/** Indices into `operations` of those that map the point onto itself modulo the lattice, ascending: a subgroup. */
|
|
184
259
|
readonly operations: readonly number[];
|
|
185
|
-
/**
|
|
260
|
+
/**
|
|
261
|
+
* The point set onto the Wyckoff position it lies on (the nearest point of the position, as
|
|
262
|
+
* `wyckoffDistances` gives it), in [0, 1).
|
|
263
|
+
*/
|
|
186
264
|
readonly point: readonly number[];
|
|
187
265
|
/** The number of points in the conventional cell equivalent to it. */
|
|
188
266
|
readonly multiplicity: number;
|
|
@@ -190,59 +268,74 @@ export interface SiteSymmetry {
|
|
|
190
268
|
readonly general: boolean;
|
|
191
269
|
}
|
|
192
270
|
|
|
193
|
-
/** The asymmetric unit of a plane group,
|
|
271
|
+
/** The asymmetric unit of a plane group: the printed inequalities, and the convex polygon they bound (lattice basis). */
|
|
194
272
|
export interface AsymmetricUnit {
|
|
195
|
-
/**
|
|
196
|
-
|
|
197
|
-
|
|
273
|
+
/**
|
|
274
|
+
* The inequalities as ITA prints them, in printed order, each [a, b, c] for a·x + b·y ≤ c
|
|
275
|
+
* (integers, no common factor), also those that hold no edge of the polygon (p3: x ≤ 2/3).
|
|
276
|
+
*/
|
|
198
277
|
readonly inequalities: readonly (readonly number[])[];
|
|
278
|
+
/** The vertices of the polygon, counter-clockwise (a towards b), starting at the lowest (smallest y, then x). */
|
|
279
|
+
readonly vertices: readonly (readonly number[])[];
|
|
280
|
+
/** Per edge, from vertex i to vertex i + 1, the index into `inequalities` of the inequality that holds it. */
|
|
281
|
+
readonly edges: readonly number[];
|
|
199
282
|
}
|
|
200
283
|
|
|
201
|
-
/** A rotation
|
|
202
|
-
export interface
|
|
203
|
-
/** The highest
|
|
204
|
-
readonly
|
|
205
|
-
/** Its
|
|
284
|
+
/** A rotation point (ITA 2016 Table 2.1.2.1, p. 145: the symmetry element of a rotation in the plane). */
|
|
285
|
+
export interface RotationPoint {
|
|
286
|
+
/** The highest n of an n-fold rotation about it. */
|
|
287
|
+
readonly n: number;
|
|
288
|
+
/** Its location, lattice basis. */
|
|
206
289
|
readonly point: readonly number[];
|
|
207
290
|
}
|
|
208
291
|
|
|
209
|
-
/** A mirror or glide line
|
|
292
|
+
/** A mirror or glide line, as a point and a direction (lattice basis). */
|
|
210
293
|
export interface SymmetryLine {
|
|
211
294
|
/** `'mirror'` or `'glide'`. */
|
|
212
295
|
readonly kind: 'mirror' | 'glide';
|
|
213
296
|
/** The direction of the line, the shortest integer vector, first non-zero component positive. */
|
|
214
297
|
readonly direction: readonly number[];
|
|
215
|
-
/** The normal of the line in the lattice basis, as in `describeOperations`. */
|
|
216
|
-
readonly
|
|
298
|
+
/** The normal of the line in the lattice basis, its symmetry direction, as `axis` in `describeOperations`. */
|
|
299
|
+
readonly axis: readonly number[];
|
|
217
300
|
/** For a glide line its glide vector s·direction, 0 < s < 1; for a mirror line (0, 0). */
|
|
218
301
|
readonly glide: readonly number[];
|
|
219
|
-
/**
|
|
220
|
-
readonly
|
|
302
|
+
/** A point of the line: its intersection with y = 0, or with x = 0 for a line along a. */
|
|
303
|
+
readonly point: readonly number[];
|
|
221
304
|
}
|
|
222
305
|
|
|
223
|
-
/**
|
|
306
|
+
/** Symmetry elements of a plane group. */
|
|
224
307
|
export interface SymmetryElements {
|
|
225
|
-
/** The rotation
|
|
226
|
-
readonly
|
|
227
|
-
/** The mirror and glide lines
|
|
308
|
+
/** The rotation points, by descending n, then by y and x. */
|
|
309
|
+
readonly rotationPoints: readonly RotationPoint[];
|
|
310
|
+
/** The mirror and glide lines, by direction, then by their point (x on y = 0, or y on x = 0), mirror before glide. */
|
|
228
311
|
readonly lines: readonly SymmetryLine[];
|
|
229
312
|
}
|
|
230
313
|
|
|
314
|
+
/** Options of `symmetryElements`. */
|
|
315
|
+
export interface SymmetryElementsOptions {
|
|
316
|
+
/**
|
|
317
|
+
* A box of the plane, lattice basis, as its lower left and its upper right corner (x₀ ≤ x₁,
|
|
318
|
+
* y₀ ≤ y₁; a line or a point of the plane also): all lattice translates of the elements that meet
|
|
319
|
+
* it, boundary included, the lines not clipped.
|
|
320
|
+
*/
|
|
321
|
+
readonly box?: readonly (readonly number[])[];
|
|
322
|
+
}
|
|
323
|
+
|
|
231
324
|
// ---------------------------------------------------------------------------------------------
|
|
232
325
|
|
|
233
326
|
const numbers = (v: readonly Rational[]): number[] => v.map(toNumber);
|
|
234
327
|
|
|
235
|
-
function
|
|
328
|
+
function isGroupKey(key: unknown): key is PlaneGroupKey {
|
|
236
329
|
return typeof key === 'string' && (GROUP_KEYS as readonly string[]).includes(key);
|
|
237
330
|
}
|
|
238
331
|
|
|
239
332
|
function unknownKey(key: unknown, what = 'plane group or plane point group'): never {
|
|
240
|
-
throw new RangeError(`Unknown ${what}: ${
|
|
333
|
+
throw new RangeError(`Unknown ${what}: ${shown(key)}`);
|
|
241
334
|
}
|
|
242
335
|
|
|
243
336
|
/** The plane group of a key; throws for a point group or an unknown key. */
|
|
244
337
|
function groupKey(key: unknown, what: string): PlaneGroupKey {
|
|
245
|
-
if (
|
|
338
|
+
if (isGroupKey(key)) return key;
|
|
246
339
|
if (isPlanePointGroupKey(key)) {
|
|
247
340
|
throw new RangeError(`${what} takes the key of a plane group, not of the point group ${key}`);
|
|
248
341
|
}
|
|
@@ -252,26 +345,47 @@ function groupKey(key: unknown, what: string): PlaneGroupKey {
|
|
|
252
345
|
/** The key of a plane point group; throws for a plane group or an unknown key. */
|
|
253
346
|
function pointKey(key: unknown, what: string): PointGroupKey {
|
|
254
347
|
if (isPlanePointGroupKey(key)) return key;
|
|
255
|
-
if (
|
|
348
|
+
if (isGroupKey(key)) {
|
|
256
349
|
throw new RangeError(`${what} takes the key of a plane point group; ${key} is a plane group (planeGroup)`);
|
|
257
350
|
}
|
|
258
351
|
return unknownKey(key, 'plane point group');
|
|
259
352
|
}
|
|
260
353
|
|
|
261
|
-
|
|
262
|
-
|
|
354
|
+
/**
|
|
355
|
+
* The index of the setting that `options` names for a key, or undefined if it names none: an index
|
|
356
|
+
* is passed on (and checked where it is used), a symbol is looked up among the settings of the key.
|
|
357
|
+
*/
|
|
358
|
+
function settingOf(key: PlaneGroupKey | PointGroupKey, options: SettingOptions | undefined): number | undefined {
|
|
359
|
+
const setting = options?.setting;
|
|
360
|
+
if (typeof setting !== 'string') return setting;
|
|
361
|
+
const wanted = compactSymbol(setting);
|
|
362
|
+
if (isGroupKey(key)) {
|
|
363
|
+
if (wanted === key || wanted === planeGroupEntry(key).fullSymbol) return 1;
|
|
364
|
+
throw new RangeError(
|
|
365
|
+
`The plane group ${key} has no setting ${shown(setting)} (its symbols: ${key}, ${planeGroupEntry(key).fullSymbol})`,
|
|
366
|
+
);
|
|
367
|
+
}
|
|
368
|
+
const symbols = Array.from({ length: planePointGroupSettingCount(key) }, (_, i) => planePointGroupSymbol(key, i + 1));
|
|
369
|
+
const index = symbols.findIndex((s) => s === wanted);
|
|
370
|
+
if (index >= 0) return index + 1;
|
|
371
|
+
// The key of a point group with several settings is the symbol of none; it names the default.
|
|
372
|
+
if (wanted === key) return 1;
|
|
373
|
+
throw new RangeError(
|
|
374
|
+
`The plane point group ${key} has no setting ${shown(setting)} (settings: ${symbols.join(', ')})`,
|
|
375
|
+
);
|
|
263
376
|
}
|
|
264
377
|
|
|
265
378
|
/** The exact operations for a key: a plane group (setting 1 only) or a point group in a setting. */
|
|
266
379
|
function exact(key: unknown, options: SettingOptions | undefined, generatorsOnly: boolean): ExactOperation[] {
|
|
267
|
-
|
|
268
|
-
|
|
380
|
+
if (isGroupKey(key)) {
|
|
381
|
+
const setting = settingOf(key, options);
|
|
269
382
|
if (setting !== undefined && setting !== 1) {
|
|
270
383
|
throw new RangeError(`The plane group ${key} has no setting ${String(setting)}`);
|
|
271
384
|
}
|
|
272
385
|
return generatorsOnly ? planeGroupGenerators(key) : planeGroupOperations(key);
|
|
273
386
|
}
|
|
274
387
|
if (isPlanePointGroupKey(key)) {
|
|
388
|
+
const setting = settingOf(key, options);
|
|
275
389
|
return generatorsOnly ? planePointGroupGenerators(key, setting) : planePointGroupOperations(key, setting);
|
|
276
390
|
}
|
|
277
391
|
return unknownKey(key);
|
|
@@ -290,44 +404,18 @@ function describe(op: ExactOperation): OperationDescription {
|
|
|
290
404
|
const d = describePlaneOperation(op);
|
|
291
405
|
return Object.freeze({
|
|
292
406
|
kind: d.kind,
|
|
293
|
-
|
|
407
|
+
n: d.n,
|
|
294
408
|
...(d.sense ? { sense: d.sense } : {}),
|
|
295
409
|
...(d.translation ? { translation: Object.freeze(numbers(d.translation)) } : {}),
|
|
296
410
|
...(d.location ? { location: Object.freeze(numbers(d.location)) } : {}),
|
|
297
411
|
...(d.direction ? { direction: Object.freeze([...d.direction]) } : {}),
|
|
298
|
-
...(d.
|
|
412
|
+
...(d.axis ? { axis: Object.freeze([...d.axis]) } : {}),
|
|
299
413
|
...(d.glide ? { glide: Object.freeze(numbers(d.glide)) } : {}),
|
|
300
414
|
});
|
|
301
415
|
}
|
|
302
416
|
|
|
303
|
-
/** Tolerance for reading an integer or a fraction from a double. */
|
|
304
|
-
const READ_TOLERANCE = 1e-9;
|
|
305
|
-
/** The largest denominator of a translation that `describeOperationsOf` reads. */
|
|
306
|
-
const MAX_DENOMINATOR = 12;
|
|
307
|
-
|
|
308
|
-
function fractionOf(value: unknown): Rational {
|
|
309
|
-
if (typeof value === 'number' && Number.isFinite(value)) {
|
|
310
|
-
for (let d = 1; d <= MAX_DENOMINATOR; d++) {
|
|
311
|
-
const n = Math.round(value * d);
|
|
312
|
-
if (Math.abs(value * d - n) < READ_TOLERANCE * d) return rational(n, d);
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
throw new RangeError(
|
|
316
|
-
`Not within 10⁻⁹ of a translation with a denominator of at most ${MAX_DENOMINATOR}: ${shown(value)}`,
|
|
317
|
-
);
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
/** A value for an error message; never throws (BigInt, circular objects). */
|
|
321
|
-
function shown(value: unknown): string {
|
|
322
|
-
try {
|
|
323
|
-
return JSON.stringify(value) ?? String(value);
|
|
324
|
-
} catch {
|
|
325
|
-
return String(value);
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
|
|
329
417
|
/** An operation from a caller as an exact operation; throws a RangeError unless it has the shape of a plane operation. */
|
|
330
|
-
function exactOf(op: unknown): ExactOperation {
|
|
418
|
+
function exactOf(op: unknown, tolerance: number): ExactOperation {
|
|
331
419
|
const o = op as Partial<PlaneOperation> | null;
|
|
332
420
|
const m = o?.matrix;
|
|
333
421
|
const t = o?.translation;
|
|
@@ -337,13 +425,64 @@ function exactOf(op: unknown): ExactOperation {
|
|
|
337
425
|
}
|
|
338
426
|
const matrix = m.map((row) =>
|
|
339
427
|
row.map((v) => {
|
|
340
|
-
if (!(typeof v === 'number' && Math.abs(v - Math.round(v)) <
|
|
428
|
+
if (!(typeof v === 'number' && Math.abs(v - Math.round(v)) < tolerance)) {
|
|
341
429
|
throw new RangeError(`The matrix of a plane operation has integer entries, not ${shown(m)}`);
|
|
342
430
|
}
|
|
343
431
|
return Math.round(v) + 0;
|
|
344
432
|
}),
|
|
345
433
|
);
|
|
346
|
-
return { matrix, translation: t.map(
|
|
434
|
+
return { matrix, translation: t.map((v) => nearestFraction(v, tolerance, 'translation')) };
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
/** True if `key` is the key of one of the 17 plane groups (its short symbol, as ITA prints it). */
|
|
438
|
+
export function isPlaneGroupKey(key: string): key is PlaneGroupKey {
|
|
439
|
+
return isGroupKey(key);
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
/** True if `key` is the key of one of the 10 plane point groups. */
|
|
443
|
+
export function isPointGroupKey(key: string): key is PointGroupKey {
|
|
444
|
+
return isPlanePointGroupKey(key);
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
/** The 17 plane groups, in ITA's order (plane group n at index n − 1). */
|
|
448
|
+
export function planeGroups(): readonly PlaneGroup[] {
|
|
449
|
+
return Object.freeze(PLANE_GROUP_KEYS.map((key) => planeGroup(key)));
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
/** The 10 plane point groups, in the order of ITA Table 3.2.1.1. */
|
|
453
|
+
export function pointGroups(): readonly PointGroup[] {
|
|
454
|
+
return Object.freeze(POINT_GROUP_KEYS.map((key) => pointGroup(key)));
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
/**
|
|
458
|
+
* Finds a plane group by a symbol: the key (the short symbol, `'pm'`) or the full symbol (`'p1m1'`,
|
|
459
|
+
* `'p 1 m 1'`), spaces ignored (docs/conventions.md, "Reading symbols"). The lattice letter is
|
|
460
|
+
* lower case, as ITA prints it. Gives `undefined` if the symbol names no plane group; throws a
|
|
461
|
+
* RangeError for a value that is not a string.
|
|
462
|
+
*/
|
|
463
|
+
export function findPlaneGroup(symbol: string): PlaneGroupFound | undefined {
|
|
464
|
+
if (typeof symbol !== 'string') throw new RangeError(`A symbol is a string, not ${shown(symbol)}`);
|
|
465
|
+
const wanted = compactSymbol(symbol);
|
|
466
|
+
const key = PLANE_GROUP_KEYS.find((k) => k === wanted || planeGroupEntry(k).fullSymbol === wanted);
|
|
467
|
+
return key === undefined ? undefined : Object.freeze({ key });
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
/**
|
|
471
|
+
* Finds a plane point group by a symbol: the key, or the symbol of a setting (`'3m1'`, `'31m'`),
|
|
472
|
+
* spaces ignored; the key `'3m'` gives the default setting 1. Gives `undefined` if the symbol names
|
|
473
|
+
* no plane point group, also for the symbol of a plane group (that is `findPlaneGroup`); throws a
|
|
474
|
+
* RangeError for a value that is not a string.
|
|
475
|
+
*/
|
|
476
|
+
export function findPointGroup(symbol: string): PointGroupInSetting | undefined {
|
|
477
|
+
if (typeof symbol !== 'string') throw new RangeError(`A symbol is a string, not ${shown(symbol)}`);
|
|
478
|
+
const wanted = compactSymbol(symbol);
|
|
479
|
+
for (const key of POINT_GROUP_KEYS) {
|
|
480
|
+
for (let i = 1; i <= planePointGroupSettingCount(key); i++) {
|
|
481
|
+
if (planePointGroupSymbol(key, i) === wanted) return Object.freeze({ key, setting: i });
|
|
482
|
+
}
|
|
483
|
+
if (key === wanted) return Object.freeze({ key, setting: 1 });
|
|
484
|
+
}
|
|
485
|
+
return undefined;
|
|
347
486
|
}
|
|
348
487
|
|
|
349
488
|
/** The plane group with this key (short symbol). Throws a RangeError for an unknown key. */
|
|
@@ -353,22 +492,27 @@ export function planeGroup(key: PlaneGroupKey): PlaneGroup {
|
|
|
353
492
|
return Object.freeze({
|
|
354
493
|
key: entry.symbol as PlaneGroupKey,
|
|
355
494
|
number: entry.number,
|
|
356
|
-
fullSymbol: entry.fullSymbol,
|
|
357
495
|
pointGroup: point.key,
|
|
358
496
|
pointGroupSetting: point.setting,
|
|
359
497
|
crystalSystem: entry.system,
|
|
498
|
+
bravaisLattice: planeBravaisLattice(entry.system, entry.symbol),
|
|
499
|
+
pattersonSymmetry: entry.pattersonSymmetry as PlaneGroupKey,
|
|
360
500
|
centring: Object.freeze(
|
|
361
501
|
entry.centring.map((t) => Object.freeze(t.split(',').map((c) => toNumber(parseRational(c))))),
|
|
362
502
|
),
|
|
363
503
|
origin: entry.origin,
|
|
364
|
-
order: planeGroupOperations(entry.symbol).length,
|
|
365
504
|
});
|
|
366
505
|
}
|
|
367
506
|
|
|
368
507
|
/** The plane point group with this key. Throws a RangeError for an unknown key. */
|
|
369
508
|
export function pointGroup(key: PointGroupKey): PointGroup {
|
|
370
509
|
const k = pointKey(key, 'pointGroup');
|
|
371
|
-
return Object.freeze({
|
|
510
|
+
return Object.freeze({
|
|
511
|
+
key: k,
|
|
512
|
+
crystalSystem: planePointGroupSystem(k),
|
|
513
|
+
order: planePointGroupOperations(k).length,
|
|
514
|
+
laueClass: planeLaueClass(k),
|
|
515
|
+
});
|
|
372
516
|
}
|
|
373
517
|
|
|
374
518
|
/**
|
|
@@ -379,14 +523,37 @@ export function settings(key: PointGroupKey): readonly Setting[] {
|
|
|
379
523
|
const k = pointKey(key, 'settings');
|
|
380
524
|
return Object.freeze(
|
|
381
525
|
Array.from({ length: planePointGroupSettingCount(k) }, (_, i) =>
|
|
382
|
-
Object.freeze({ index: i + 1, symbol: planePointGroupSymbol(k, i + 1),
|
|
526
|
+
Object.freeze({ index: i + 1, symbol: planePointGroupSymbol(k, i + 1), isDefault: i === 0 }),
|
|
383
527
|
),
|
|
384
528
|
);
|
|
385
529
|
}
|
|
386
530
|
|
|
387
|
-
/**
|
|
388
|
-
|
|
389
|
-
|
|
531
|
+
/**
|
|
532
|
+
* The symbol of a plane group or a plane point group (#137 F4). In the short form (the default) the
|
|
533
|
+
* Hermann–Mauguin symbol as one word: for a plane group the key (`'p2mg'`, `'pm'`), for a plane
|
|
534
|
+
* point group in a setting `'3m1'` or `'31m'` for `3m`, otherwise the key. In the form `'full'`
|
|
535
|
+
* the full symbol with its positions separated by spaces, as in the other entry points: `'p 1 m 1'`
|
|
536
|
+
* for `pm` (ITA prints `p1m1`), `'p 2 m g'`, `'3 m 1'`; ITA prints no other full symbol for a plane
|
|
537
|
+
* point group (Ch. 3.2, p. 721, and Table 3.2.3.1). A plane group has setting 1 only. Throws a
|
|
538
|
+
* RangeError for an unknown key, setting or form.
|
|
539
|
+
*/
|
|
540
|
+
export function symbol(key: PlaneGroupKey | PointGroupKey, options?: SymbolOptions): string {
|
|
541
|
+
checkOptions(options, ['setting', 'form'], 'symbol');
|
|
542
|
+
const form = options?.form ?? 'short';
|
|
543
|
+
if (form !== 'short' && form !== 'full') {
|
|
544
|
+
throw new RangeError(`Unknown symbol form: ${shown(form)} (short or full)`);
|
|
545
|
+
}
|
|
546
|
+
// Every position of a plane symbol is one character, the lattice letter included.
|
|
547
|
+
const spaced = (text: string) => (form === 'full' ? [...text].join(' ') : text);
|
|
548
|
+
if (isGroupKey(key)) {
|
|
549
|
+
const setting = settingOf(key, options);
|
|
550
|
+
if (setting !== undefined && setting !== 1) {
|
|
551
|
+
throw new RangeError(`The plane group ${key} has no setting ${shown(setting)}`);
|
|
552
|
+
}
|
|
553
|
+
return spaced(form === 'full' ? planeGroupEntry(key).fullSymbol : key);
|
|
554
|
+
}
|
|
555
|
+
if (!isPlanePointGroupKey(key)) return unknownKey(key);
|
|
556
|
+
return spaced(planePointGroupSymbol(key, settingOf(key, options)));
|
|
390
557
|
}
|
|
391
558
|
|
|
392
559
|
/**
|
|
@@ -398,6 +565,7 @@ export function symbol(key: PointGroupKey, options?: SettingOptions): string {
|
|
|
398
565
|
* or setting.
|
|
399
566
|
*/
|
|
400
567
|
export function operations(key: PlaneGroupKey | PointGroupKey, options?: SettingOptions): readonly PlaneOperation[] {
|
|
568
|
+
checkOptions(options, ['setting'], 'operations');
|
|
401
569
|
return Object.freeze(exact(key, options, false).map(plain));
|
|
402
570
|
}
|
|
403
571
|
|
|
@@ -407,18 +575,20 @@ export function operations(key: PlaneGroupKey | PointGroupKey, options?: Setting
|
|
|
407
575
|
* generators of its symmorphic plane group. Throws a RangeError for an unknown key or setting.
|
|
408
576
|
*/
|
|
409
577
|
export function generators(key: PlaneGroupKey | PointGroupKey, options?: SettingOptions): readonly PlaneOperation[] {
|
|
578
|
+
checkOptions(options, ['setting'], 'generators');
|
|
410
579
|
return Object.freeze(exact(key, options, true).map(plain));
|
|
411
580
|
}
|
|
412
581
|
|
|
413
582
|
/**
|
|
414
583
|
* Each operation of `operations` (same key and setting) described geometrically, index for index:
|
|
415
|
-
* what it is, its
|
|
584
|
+
* what it is, its n and sense, where its symmetry element lies, its glide part. Throws a
|
|
416
585
|
* RangeError for an unknown key or setting.
|
|
417
586
|
*/
|
|
418
587
|
export function describeOperations(
|
|
419
588
|
key: PlaneGroupKey | PointGroupKey,
|
|
420
589
|
options?: SettingOptions,
|
|
421
590
|
): readonly OperationDescription[] {
|
|
591
|
+
checkOptions(options, ['setting'], 'describeOperations');
|
|
422
592
|
return Object.freeze(exact(key, options, false).map(describe));
|
|
423
593
|
}
|
|
424
594
|
|
|
@@ -427,16 +597,22 @@ export function describeOperations(
|
|
|
427
597
|
* `describeOperations` describes those of a group: for instance a product of operations, an
|
|
428
598
|
* operation shifted by a lattice translation, or the operations of a site symmetry. Each operation is
|
|
429
599
|
* `{ matrix, translation }` as `operations` gives it. Each matrix must have integer entries (within
|
|
430
|
-
*
|
|
431
|
-
* 2, 3, 4 or 6); each
|
|
432
|
-
* 12 (1/3
|
|
433
|
-
* RangeError otherwise
|
|
600
|
+
* the tolerance, per entry) and be the linear part of a crystallographic plane point group
|
|
601
|
+
* (determinant ±1, order 1, 2, 3, 4 or 6); each component of a translation is read as the fraction
|
|
602
|
+
* with a denominator of at most 12 within the tolerance (1/3 from 0.333…), as the translations of
|
|
603
|
+
* `operations` and their products are. Throws a RangeError otherwise, also for a component within
|
|
604
|
+
* the tolerance of two such fractions (which can lie 1/132 apart).
|
|
434
605
|
*/
|
|
435
|
-
export function describeOperationsOf(
|
|
606
|
+
export function describeOperationsOf(
|
|
607
|
+
operations: readonly PlaneOperation[],
|
|
608
|
+
options?: ToleranceOptions,
|
|
609
|
+
): readonly OperationDescription[] {
|
|
610
|
+
checkOptions(options, TOLERANCE_KEYS, 'describeOperationsOf');
|
|
611
|
+
const tolerance = toleranceOf(options, 'operations');
|
|
436
612
|
if (!Array.isArray(operations)) {
|
|
437
613
|
throw new RangeError('describeOperationsOf takes a list of operations { matrix, translation }');
|
|
438
614
|
}
|
|
439
|
-
return Object.freeze(operations.map((op) => describe(exactOf(op))));
|
|
615
|
+
return Object.freeze(operations.map((op) => describe(exactOf(op, tolerance))));
|
|
440
616
|
}
|
|
441
617
|
|
|
442
618
|
/**
|
|
@@ -454,13 +630,15 @@ export function wyckoffPositions(key: PlaneGroupKey): readonly WyckoffPosition[]
|
|
|
454
630
|
}
|
|
455
631
|
|
|
456
632
|
/**
|
|
457
|
-
* The site symmetry of a point (lattice basis) under a plane group
|
|
458
|
-
*
|
|
459
|
-
*
|
|
460
|
-
*
|
|
633
|
+
* The site symmetry of a point (lattice basis) under a plane group, as one notion with its Wyckoff
|
|
634
|
+
* position (#137 F1): the point is set onto the position it lies on within the tolerance
|
|
635
|
+
* (`wyckoffPosition`), and the site symmetry is that of the point there; `point` is the point on the
|
|
636
|
+
* position. Throws a RangeError for an unknown key, a point that is not two finite numbers, or a
|
|
637
|
+
* tolerance outside (0, 1/2).
|
|
461
638
|
*/
|
|
462
|
-
export function siteSymmetry(key: PlaneGroupKey, point: readonly number[], options?:
|
|
463
|
-
|
|
639
|
+
export function siteSymmetry(key: PlaneGroupKey, point: readonly number[], options?: ToleranceOptions): SiteSymmetry {
|
|
640
|
+
checkOptions(options, TOLERANCE_KEYS, 'siteSymmetry');
|
|
641
|
+
const site = planeSiteOfPosition(groupKey(key, 'siteSymmetry'), point, options);
|
|
464
642
|
return Object.freeze({
|
|
465
643
|
operations: Object.freeze([...site.operations]),
|
|
466
644
|
point: Object.freeze([...site.point]),
|
|
@@ -471,15 +649,18 @@ export function siteSymmetry(key: PlaneGroupKey, point: readonly number[], optio
|
|
|
471
649
|
|
|
472
650
|
/**
|
|
473
651
|
* The Wyckoff position of a point (lattice basis) under a plane group, as `wyckoffPositions` gives
|
|
474
|
-
* it: the printed position
|
|
475
|
-
*
|
|
652
|
+
* it: the most special printed position whose point set lies within the tolerance of the point,
|
|
653
|
+
* measured per coordinate modulo the lattice, and among positions of equal multiplicity the nearest
|
|
654
|
+
* (the distance of `wyckoffDistances`); the general position always holds the point. Throws a
|
|
655
|
+
* RangeError as `siteSymmetry`.
|
|
476
656
|
*/
|
|
477
|
-
export function
|
|
657
|
+
export function wyckoffPosition(
|
|
478
658
|
key: PlaneGroupKey,
|
|
479
659
|
point: readonly number[],
|
|
480
|
-
options?:
|
|
660
|
+
options?: ToleranceOptions,
|
|
481
661
|
): WyckoffPosition {
|
|
482
|
-
|
|
662
|
+
checkOptions(options, TOLERANCE_KEYS, 'wyckoffPosition');
|
|
663
|
+
const k = groupKey(key, 'wyckoffPosition');
|
|
483
664
|
const { letter } = planeWyckoffPositionOf(k, point, options);
|
|
484
665
|
const found = wyckoffPositions(k).find((w) => w.letter === letter);
|
|
485
666
|
if (!found) throw new Error(`No Wyckoff position ${letter} in ${k}`);
|
|
@@ -487,76 +668,275 @@ export function wyckoffPositionOf(
|
|
|
487
668
|
}
|
|
488
669
|
|
|
489
670
|
/**
|
|
490
|
-
*
|
|
491
|
-
*
|
|
492
|
-
*
|
|
493
|
-
*
|
|
494
|
-
*
|
|
495
|
-
*
|
|
496
|
-
*
|
|
497
|
-
*
|
|
498
|
-
* lattice
|
|
671
|
+
* The distance of a point (lattice basis) to every Wyckoff position of a plane group, in the
|
|
672
|
+
* printed order of `wyckoffPositions`, each with the nearest point of the position (#137 F1, #108).
|
|
673
|
+
* The point set of a position is the union of its printed coordinates with every centring and
|
|
674
|
+
* lattice translation: a point, a line or the plane. Without a basis the distance is the larger of
|
|
675
|
+
* the two coordinate differences modulo the lattice, the metric of the tolerance of
|
|
676
|
+
* `wyckoffPosition`; with a basis (columns a, b) it is Euclidean, and the nearest point is the
|
|
677
|
+
* Euclidean nearest one; per coordinate the nearest point of a line need not be unique (on x,0 every x
|
|
678
|
+
* within the distance is as near), and then it is one of them. The basis should be a reduced cell,
|
|
679
|
+
* such as the conventional one: the nearest lattice translate is sought near the rounded
|
|
680
|
+
* coordinates. How to snap a dragged point onto a position (which position wins, within
|
|
681
|
+
* which radius) is the application's choice; this gives the numbers for it. Throws a RangeError for
|
|
682
|
+
* an unknown key, a point that is not two finite numbers, and a basis that is not a non-singular
|
|
683
|
+
* 2 × 2 matrix.
|
|
499
684
|
*/
|
|
500
|
-
export function
|
|
685
|
+
export function wyckoffDistances(
|
|
501
686
|
key: PlaneGroupKey,
|
|
502
687
|
point: readonly number[],
|
|
503
|
-
options?:
|
|
504
|
-
):
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
688
|
+
options?: WyckoffDistanceOptions,
|
|
689
|
+
): readonly WyckoffDistance[] {
|
|
690
|
+
checkOptions(options, ['basis'], 'wyckoffDistances');
|
|
691
|
+
const k = groupKey(key, 'wyckoffDistances');
|
|
692
|
+
const g = options?.basis === undefined ? undefined : planeMetric(options.basis);
|
|
693
|
+
const positions = wyckoffPositions(k);
|
|
694
|
+
return Object.freeze(
|
|
695
|
+
planeWyckoffDistances(k, point, g).map((d) =>
|
|
696
|
+
Object.freeze({ ...positions[d.row], point: Object.freeze([...d.point]), distance: d.distance }),
|
|
697
|
+
),
|
|
698
|
+
);
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
/** One point of the orbit of a point. */
|
|
702
|
+
export interface PointOrbitEntry {
|
|
703
|
+
/** The image, in the lattice basis, in [0, 1). */
|
|
704
|
+
readonly point: readonly number[];
|
|
705
|
+
/** Indices into `operations` of the operations that map the given point here (modulo the lattice), ascending. */
|
|
706
|
+
readonly operations: readonly number[];
|
|
512
707
|
}
|
|
513
708
|
|
|
514
709
|
/**
|
|
515
|
-
* The orbit of a point (lattice basis) under a plane group:
|
|
516
|
-
*
|
|
517
|
-
*
|
|
710
|
+
* The orbit of a point (lattice basis) under a plane group: the images of the point set onto its
|
|
711
|
+
* Wyckoff position (as `siteSymmetry` sets it), each in [0, 1), in the order of the operations that
|
|
712
|
+
* first give them, each with the indices of the operations that map the point there (as the
|
|
713
|
+
* entries of the orbits of the point groups): one entry per coset of the site symmetry, so the
|
|
714
|
+
* first entry holds the operations of `siteSymmetry`. Throws a RangeError as `siteSymmetry`.
|
|
518
715
|
*/
|
|
519
716
|
export function orbit(
|
|
520
717
|
key: PlaneGroupKey,
|
|
521
718
|
point: readonly number[],
|
|
522
|
-
options?:
|
|
523
|
-
): readonly
|
|
524
|
-
|
|
719
|
+
options?: ToleranceOptions,
|
|
720
|
+
): readonly PointOrbitEntry[] {
|
|
721
|
+
checkOptions(options, TOLERANCE_KEYS, 'orbit');
|
|
722
|
+
return Object.freeze(
|
|
723
|
+
planeOrbit(groupKey(key, 'orbit'), point, options).map((e) =>
|
|
724
|
+
Object.freeze({ point: Object.freeze(e.point), operations: Object.freeze(e.operations) }),
|
|
725
|
+
),
|
|
726
|
+
);
|
|
525
727
|
}
|
|
526
728
|
|
|
527
729
|
/**
|
|
528
|
-
* The asymmetric unit of a plane group as ITA prints it
|
|
529
|
-
*
|
|
730
|
+
* The asymmetric unit of a plane group as ITA prints it (#137 F3): the printed inequalities, all of
|
|
731
|
+
* them in printed order (a double inequality and a `min` give one each), and the convex polygon
|
|
732
|
+
* they bound, with its vertices and, per edge, the index of the inequality that holds it. Throws a
|
|
733
|
+
* RangeError for an unknown key.
|
|
530
734
|
*/
|
|
531
735
|
export function asymmetricUnit(key: PlaneGroupKey): AsymmetricUnit {
|
|
532
736
|
const unit = planeAsymmetricUnit(groupKey(key, 'asymmetricUnit'));
|
|
533
737
|
return Object.freeze({
|
|
534
|
-
vertices: Object.freeze(unit.vertices.map((v) => Object.freeze(numbers(v)))),
|
|
535
738
|
inequalities: Object.freeze(unit.inequalities.map((q) => Object.freeze([...q]))),
|
|
739
|
+
vertices: Object.freeze(unit.vertices.map((v) => Object.freeze(numbers(v)))),
|
|
740
|
+
edges: Object.freeze([...unit.edges]),
|
|
536
741
|
});
|
|
537
742
|
}
|
|
538
743
|
|
|
539
744
|
/**
|
|
540
|
-
* The symmetry elements of a plane group
|
|
541
|
-
*
|
|
542
|
-
*
|
|
745
|
+
* The symmetry elements of a plane group (#137 F2). Without a box, each element once modulo the
|
|
746
|
+
* lattice translations, the centring (1/2, 1/2) included, as ITA describes them (cm: the mirror line
|
|
747
|
+
* 0,y and the glide line 1/4,y): every rotation point in [0, 1)² with the highest n of a rotation
|
|
748
|
+
* about it, and every mirror and glide line, as a point in [0, 1)² and a direction. With a box, all
|
|
749
|
+
* their lattice translates that meet it, boundary included; the lines are not clipped, since
|
|
750
|
+
* clipping is drawing. Throws a RangeError for an unknown key, a box that is not two corners of
|
|
751
|
+
* finite numbers, the first not above or right of the second, and a box with more than a million
|
|
752
|
+
* rotation points.
|
|
543
753
|
*/
|
|
544
|
-
export function symmetryElements(key: PlaneGroupKey): SymmetryElements {
|
|
545
|
-
|
|
754
|
+
export function symmetryElements(key: PlaneGroupKey, options?: SymmetryElementsOptions): SymmetryElements {
|
|
755
|
+
checkOptions(options, ['box'], 'symmetryElements');
|
|
756
|
+
const k = groupKey(key, 'symmetryElements');
|
|
757
|
+
const box = options?.box;
|
|
758
|
+
let e;
|
|
759
|
+
if (box === undefined) e = planeElements(k);
|
|
760
|
+
else {
|
|
761
|
+
const ok =
|
|
762
|
+
Array.isArray(box) &&
|
|
763
|
+
box.length === 2 &&
|
|
764
|
+
box.every(
|
|
765
|
+
(c) => Array.isArray(c) && c.length === 2 && c.every((v) => typeof v === 'number' && Number.isFinite(v)),
|
|
766
|
+
);
|
|
767
|
+
if (!ok || !(box[0][0] <= box[1][0] && box[0][1] <= box[1][1])) {
|
|
768
|
+
throw new RangeError(`A box is two corners [[x0, y0], [x1, y1]] with x0 <= x1 and y0 <= y1, not ${shown(box)}`);
|
|
769
|
+
}
|
|
770
|
+
e = planeElementsInBox(k, [
|
|
771
|
+
[box[0][0], box[0][1]],
|
|
772
|
+
[box[1][0], box[1][1]],
|
|
773
|
+
]);
|
|
774
|
+
}
|
|
546
775
|
return Object.freeze({
|
|
547
|
-
|
|
548
|
-
e.
|
|
776
|
+
rotationPoints: Object.freeze(
|
|
777
|
+
e.rotationPoints.map((r) => Object.freeze({ n: r.n, point: Object.freeze(numbers(r.point)) })),
|
|
549
778
|
),
|
|
550
779
|
lines: Object.freeze(
|
|
551
780
|
e.lines.map((l) =>
|
|
552
781
|
Object.freeze({
|
|
553
782
|
kind: l.kind,
|
|
554
783
|
direction: Object.freeze([...l.direction]),
|
|
555
|
-
|
|
784
|
+
axis: Object.freeze([...l.axis]),
|
|
556
785
|
glide: Object.freeze(numbers(l.glide)),
|
|
557
|
-
|
|
786
|
+
point: Object.freeze(numbers(l.point)),
|
|
558
787
|
}),
|
|
559
788
|
),
|
|
560
789
|
),
|
|
561
790
|
});
|
|
562
791
|
}
|
|
792
|
+
|
|
793
|
+
// --- lattices and cells (#119, #137 G5) ---------------------------------------------------------------
|
|
794
|
+
|
|
795
|
+
const PLANE_SYSTEMS = Object.keys(PLANE_FAMILIES) as PlaneSystem[];
|
|
796
|
+
|
|
797
|
+
const copy = (m: Mat2): Mat2 => [
|
|
798
|
+
[m[0][0], m[0][1]],
|
|
799
|
+
[m[1][0], m[1][1]],
|
|
800
|
+
];
|
|
801
|
+
|
|
802
|
+
/**
|
|
803
|
+
* The restrictions on the cell parameters of a crystal system of the plane, as ITA 2016 Table
|
|
804
|
+
* 2.1.1.1 (p. 143) gives them for the conventional cell: the parameters to be determined, the pairs
|
|
805
|
+
* of equal parameters, the fixed angles, and the angles conventionally taken non-acute. Throws a
|
|
806
|
+
* RangeError for anything that is not one of the four crystal systems of the plane.
|
|
807
|
+
*/
|
|
808
|
+
export function cellRestrictions(system: PlaneSystem): CellRestrictions {
|
|
809
|
+
if (!(PLANE_SYSTEMS as readonly unknown[]).includes(system)) {
|
|
810
|
+
throw new RangeError(`Unknown crystal system of the plane: ${shown(system)} (${PLANE_SYSTEMS.join(', ')})`);
|
|
811
|
+
}
|
|
812
|
+
const r = PLANE_FAMILIES[system].restrictions;
|
|
813
|
+
return deepFreeze({
|
|
814
|
+
parameters: [...r.parameters],
|
|
815
|
+
equal: r.equal.map((pair) => [...pair]),
|
|
816
|
+
angles: { ...r.angles },
|
|
817
|
+
nonAcute: [...r.nonAcute],
|
|
818
|
+
});
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
/**
|
|
822
|
+
* The Cartesian basis of a plane cell as the columns of a 2 × 2 matrix: a along x, b at γ from a
|
|
823
|
+
* towards +y (right-handed), in the unit of the edge lengths. Throws a RangeError for an edge that is
|
|
824
|
+
* not a positive number and for γ outside (0°, 180°).
|
|
825
|
+
*/
|
|
826
|
+
export function latticeFromParameters(parameters: LatticeParameters): Mat2 {
|
|
827
|
+
return deepFreeze(copy(planeLatticeFromParameters(parameters, 'latticeFromParameters')));
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
/**
|
|
831
|
+
* The parameters a, b, γ of a basis given as the columns of a 2 × 2 Cartesian matrix, independent of
|
|
832
|
+
* its orientation and handedness. Throws a RangeError for a basis that is not a non-singular 2 × 2
|
|
833
|
+
* matrix.
|
|
834
|
+
*/
|
|
835
|
+
export function latticeParameters(basis: Mat2): LatticeParameters {
|
|
836
|
+
return Object.freeze(planeLatticeParameters(basis, 'latticeParameters'));
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
/** The metric tensor G = AᵀA of a basis A (columns a, b): g_ij = a_i · a_j. Throws a RangeError for a basis that is not a non-singular 2 × 2 matrix. */
|
|
840
|
+
export function metricTensor(basis: Mat2): Mat2 {
|
|
841
|
+
return deepFreeze(copy(planeMetricTensor(basis, 'metricTensor')));
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
/**
|
|
845
|
+
* The reciprocal basis B = A⁻ᵀ of a basis A (columns a, b) as the columns a*, b*, with
|
|
846
|
+
* a_i · a*_j = δ_ij (no factor 2π). Throws a RangeError for a basis that is not a non-singular 2 × 2
|
|
847
|
+
* matrix.
|
|
848
|
+
*/
|
|
849
|
+
export function reciprocalBasis(basis: Mat2): Mat2 {
|
|
850
|
+
return deepFreeze(copy(planeReciprocalBasis(basis, 'reciprocalBasis')));
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
// --- change of the coordinate system (#120, #137 G2) ---------------------------------------------------
|
|
854
|
+
|
|
855
|
+
/** A change of the coordinate system (P, p) of the plane (ITA 2016 § 1.5.1.3, p. 83): (a′, b′) = (a, b)·P, origin O′ = O + p. */
|
|
856
|
+
export interface CoordinateTransformation {
|
|
857
|
+
/** P, the linear part: its columns are the new basis vectors a′, b′ in the old basis; det P ≠ 0, also negative. */
|
|
858
|
+
readonly linearPart: Mat2;
|
|
859
|
+
/** p, the origin shift: the coordinates of the new origin in the old coordinate system; default zero. */
|
|
860
|
+
readonly originShift?: readonly number[];
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
/** An operation (W, w) in the lattice basis, x ↦ W·x + w; a record of `operations` passes as it is. */
|
|
864
|
+
export interface AffineOperation {
|
|
865
|
+
/** The linear part W, a 2 × 2 matrix with integer entries. */
|
|
866
|
+
readonly matrix: readonly (readonly number[])[];
|
|
867
|
+
/** The translation part w; default zero, as for the operations of a point group. */
|
|
868
|
+
readonly translation?: readonly number[];
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
/** An operation (W′, w′) in the new coordinate system. */
|
|
872
|
+
export interface TransformedOperation {
|
|
873
|
+
/** W′ = P⁻¹WP, integer entries. */
|
|
874
|
+
readonly matrix: Mat2;
|
|
875
|
+
/** w′ = P⁻¹(w + (W − I)p), not reduced modulo the lattice. */
|
|
876
|
+
readonly translation: readonly number[];
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
/** The quantities that `changeOfCoordinates` transforms; each is optional. */
|
|
880
|
+
export interface CoordinateQuantities {
|
|
881
|
+
/** Point coordinates x: x′ = P⁻¹(x − p) (eq. (1.5.1.7)). */
|
|
882
|
+
readonly points?: readonly (readonly number[])[];
|
|
883
|
+
/** Coefficients [uv] of vectors, e.g. directions: [uv]′ = P⁻¹[uv] (eq. (1.5.2.3)); not changed by the origin shift. */
|
|
884
|
+
readonly directions?: readonly (readonly number[])[];
|
|
885
|
+
/** Miller indices (hk) of lines: (hk)′ = (hk)P (eq. (1.5.2.2)); not changed by the origin shift. */
|
|
886
|
+
readonly planes?: readonly (readonly number[])[];
|
|
887
|
+
/** The metric tensor G: G′ = PᵀGP (eq. (1.5.2.4)). */
|
|
888
|
+
readonly metric?: Mat2;
|
|
889
|
+
/** Operations (W, w): W′ = P⁻¹WP, w′ = P⁻¹(w + (W − I)p) (eqs. (1.5.2.12), (1.5.2.13)). */
|
|
890
|
+
readonly operations?: readonly AffineOperation[];
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
/** The inverse change of the coordinate system (Q, q) = (P, p)⁻¹. */
|
|
894
|
+
export interface InverseTransformation {
|
|
895
|
+
/** Q = P⁻¹. */
|
|
896
|
+
readonly linearPart: Mat2;
|
|
897
|
+
/** q = −P⁻¹p. */
|
|
898
|
+
readonly originShift: readonly number[];
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
/** The result of `changeOfCoordinates`: the inverse pair and each given quantity in the new coordinate system. */
|
|
902
|
+
export interface CoordinateChange {
|
|
903
|
+
/** (Q, q) = (P⁻¹, −P⁻¹p), which takes the new coordinates back to the old (eq. (1.5.1.7)). */
|
|
904
|
+
readonly inverse: InverseTransformation;
|
|
905
|
+
/** The points, as given, in the new coordinates. */
|
|
906
|
+
readonly points?: readonly (readonly number[])[];
|
|
907
|
+
/** The vector coefficients, as given, in the new basis. */
|
|
908
|
+
readonly directions?: readonly (readonly number[])[];
|
|
909
|
+
/** The Miller indices, as given, in the new basis. */
|
|
910
|
+
readonly planes?: readonly (readonly number[])[];
|
|
911
|
+
/** The metric tensor in the new basis. */
|
|
912
|
+
readonly metric?: Mat2;
|
|
913
|
+
/** The operations, as given, in the new coordinate system. */
|
|
914
|
+
readonly operations?: readonly TransformedOperation[];
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
/**
|
|
918
|
+
* Changes the coordinate system of the plane by the pair (P, p) of ITA (6th ed., 2016) § 1.5.1.3
|
|
919
|
+
* (p. 83), with 2 × 2 matrices: the new basis is (a′, b′) = (a, b)·P and the new origin lies at p.
|
|
920
|
+
* Transforms the given quantities by ITA's equations (§ 1.5.2, pp. 83–85): point coordinates
|
|
921
|
+
* x′ = P⁻¹(x − p), vector coefficients [uv]′ = P⁻¹[uv], Miller indices (hk)′ = (hk)P, the metric
|
|
922
|
+
* tensor G′ = PᵀGP, and operations W′ = P⁻¹WP, w′ = P⁻¹(w + (W − I)p); and gives the inverse pair
|
|
923
|
+
* (Q, q) = (P⁻¹, −P⁻¹p). det P may be negative.
|
|
924
|
+
*
|
|
925
|
+
* P, p and the operations are read each number as the simplest fraction within the tolerance
|
|
926
|
+
* (default `EPSILON`; 0.3333333 is 1/3) and transformed exactly, so that every result, the inverse
|
|
927
|
+
* pair included, can be passed back; the other quantities are floating point. P is rational in a
|
|
928
|
+
* change between lattice bases, as in ITA; an irrational P (a rotation by 30°) is read as the
|
|
929
|
+
* nearby fractions, about as exact as the tolerance, and a much smaller tolerance can make the exact
|
|
930
|
+
* products leave the safe integers, a RangeError.
|
|
931
|
+
* A transformed operation is `{ matrix, translation }`. Throws a RangeError for a singular P, a quantity of the
|
|
932
|
+
* wrong shape, an unknown quantity, an operation with det W ≠ ±1, and one whose W′ is not integral.
|
|
933
|
+
*/
|
|
934
|
+
export function changeOfCoordinates(
|
|
935
|
+
transformation: CoordinateTransformation,
|
|
936
|
+
quantities: CoordinateQuantities,
|
|
937
|
+
options?: ToleranceOptions,
|
|
938
|
+
): CoordinateChange {
|
|
939
|
+
return deepFreeze(
|
|
940
|
+
changeCoordinates(2, transformation, quantities, options, 'changeOfCoordinates') as unknown as CoordinateChange,
|
|
941
|
+
);
|
|
942
|
+
}
|