symcrys 0.10.0 → 0.11.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/crystalClasses.d.ts +146 -118
- package/dist/crystalClasses.d.ts.map +1 -1
- package/dist/crystalClasses.js +163 -124
- 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 +11 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/dist/indices.d.ts +31 -5
- package/dist/indices.d.ts.map +1 -1
- package/dist/indices.js +104 -13
- 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 +12 -10
- package/dist/magnetic.d.ts.map +1 -1
- package/dist/magnetic.js +8 -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 +141 -79
- package/dist/plane.d.ts.map +1 -1
- package/dist/plane.js +147 -77
- 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 +135 -67
- package/dist/pointGroups/pointGroups.d.ts.map +1 -1
- package/dist/pointGroups/pointGroups.js +409 -244
- 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/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 +9 -17
- package/dist/siteSymmetry.d.ts.map +1 -1
- package/dist/siteSymmetry.js +62 -47
- 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 +12 -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 +1 -1
- package/dist/spaceGroups/planeGroupData.d.ts.map +1 -1
- package/dist/spaceGroups/planeGroupData.js +8 -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/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/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 +12 -4
- package/dist/tensors/rowEchelon.d.ts.map +1 -1
- package/dist/tensors/rowEchelon.js +24 -11
- 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 +173 -68
- 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/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/crystalClasses.ts +234 -160
- package/src/freeze.ts +14 -0
- package/src/index.ts +21 -10
- package/src/indices.ts +108 -18
- package/src/lattice.ts +41 -1
- package/src/linalg.ts +3 -3
- package/src/magnetic.ts +14 -9
- package/src/notation.ts +73 -0
- package/src/operations.ts +78 -69
- package/src/plane.ts +253 -127
- 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 +540 -297
- package/src/pointGroups/properties.ts +44 -40
- package/src/pointGroups/seitzData.ts +147 -0
- package/src/pointGroups/wyckoff.ts +137 -112
- package/src/pointGroups/wyckoffData.ts +793 -170
- package/src/siteSymmetry.ts +71 -64
- package/src/spaceGroups/affine.ts +3 -2
- package/src/spaceGroups/cell.ts +227 -116
- package/src/spaceGroups/describe.ts +22 -19
- package/src/spaceGroups/planeGroupData.ts +9 -9
- package/src/spaceGroups/planeGroups.ts +2 -1
- package/src/spaceGroups/positions.ts +202 -78
- package/src/tensors/propertyTable.ts +29 -17
- package/src/tensors/rowEchelon.ts +28 -9
- package/src/tensors/tensorForm.ts +260 -89
- package/src/tensors/tensorProperties.ts +34 -14
- 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,8 +10,9 @@
|
|
|
10
10
|
* `tolerance` (docs/conventions.md, "Plane groups").
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
+
import { TOLERANCE_KEYS, checkOptions, shown } from './checks.js';
|
|
13
14
|
import { describePlaneOperation } from './spaceGroups/describe.js';
|
|
14
|
-
import { planeAsymmetricUnit,
|
|
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';
|
|
17
18
|
import {
|
|
@@ -31,11 +32,18 @@ import {
|
|
|
31
32
|
planePointGroupSystem,
|
|
32
33
|
type PlanePointGroupKey,
|
|
33
34
|
} from './spaceGroups/planePointGroups.js';
|
|
34
|
-
import {
|
|
35
|
-
|
|
35
|
+
import {
|
|
36
|
+
planeMetric,
|
|
37
|
+
planeOrbit,
|
|
38
|
+
planeSiteOfPosition,
|
|
39
|
+
planeWyckoffDistances,
|
|
40
|
+
planeWyckoffPositionOf,
|
|
41
|
+
} from './spaceGroups/positions.js';
|
|
36
42
|
import { parseRational, rational, toNumber, type Rational } from './spaceGroups/rational.js';
|
|
37
43
|
|
|
38
44
|
export { VERSION } from './version.js';
|
|
45
|
+
export { EPSILON, type ToleranceOptions } from './tolerances.js';
|
|
46
|
+
import { toleranceOf, type ToleranceOptions } from './tolerances.js';
|
|
39
47
|
export type { PlaneSystem } from './spaceGroups/planeGroupData.js';
|
|
40
48
|
|
|
41
49
|
/** The short symbol of a plane group, e.g. `'p2mg'`. */
|
|
@@ -73,13 +81,10 @@ export interface SettingOptions {
|
|
|
73
81
|
readonly setting?: number;
|
|
74
82
|
}
|
|
75
83
|
|
|
76
|
-
/** Options of the
|
|
77
|
-
export interface
|
|
78
|
-
/**
|
|
79
|
-
|
|
80
|
-
* by less than this from an integer. Default 10⁻⁶; must be below 1/2.
|
|
81
|
-
*/
|
|
82
|
-
readonly tolerance?: number;
|
|
84
|
+
/** Options of `symbol`: the setting, and the form of a plane group's symbol. */
|
|
85
|
+
export interface SymbolOptions extends SettingOptions {
|
|
86
|
+
/** `'short'` (default): the symbol as one word, the key; `'full'`: the full symbol, positions separated by spaces (`'p 1 m 1'` for `pm`). */
|
|
87
|
+
readonly form?: 'short' | 'full';
|
|
83
88
|
}
|
|
84
89
|
|
|
85
90
|
/** An operation (W, w) in the lattice basis: x ↦ W·x + w. */
|
|
@@ -96,8 +101,6 @@ export interface PlaneGroup {
|
|
|
96
101
|
readonly key: PlaneGroupKey;
|
|
97
102
|
/** The number of the plane group, 1 to 17. */
|
|
98
103
|
readonly number: number;
|
|
99
|
-
/** The full symbol as ITA prints it, e.g. `'p2mg'` or `'p1m1'`. */
|
|
100
|
-
readonly fullSymbol: string;
|
|
101
104
|
/** The plane point group. */
|
|
102
105
|
readonly pointGroup: PointGroupKey;
|
|
103
106
|
/** The setting of the point group: 2 for `p31m`, otherwise 1. */
|
|
@@ -106,10 +109,8 @@ export interface PlaneGroup {
|
|
|
106
109
|
readonly crystalSystem: PlaneSystem;
|
|
107
110
|
/** The centring translations besides (0, 0): `[[0.5, 0.5]]` for `cm` and `c2mm`, otherwise none. */
|
|
108
111
|
readonly centring: readonly (readonly number[])[];
|
|
109
|
-
/** The block "Origin" as ITA prints it, e.g. `'at
|
|
112
|
+
/** The block "Origin" as ITA prints it, its positions spaced as printed, e.g. `'at 2 m m'`, `'at 2 1 g'`. */
|
|
110
113
|
readonly origin: string;
|
|
111
|
-
/** The order of the group modulo the lattice: the number of `operations`. */
|
|
112
|
-
readonly order: number;
|
|
113
114
|
}
|
|
114
115
|
|
|
115
116
|
/** A plane point group. */
|
|
@@ -129,15 +130,18 @@ export interface Setting {
|
|
|
129
130
|
/** Its symbol: `'3m1'` or `'31m'` for `3m`, otherwise the key. */
|
|
130
131
|
readonly symbol: string;
|
|
131
132
|
/** True for the default setting (setting 1). */
|
|
132
|
-
readonly
|
|
133
|
+
readonly isDefault: boolean;
|
|
133
134
|
}
|
|
134
135
|
|
|
135
136
|
/** What an operation is, geometrically, as ITA describes it under "Symmetry operations". */
|
|
136
137
|
export interface OperationDescription {
|
|
137
|
-
/**
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
138
|
+
/**
|
|
139
|
+
* `'identity'`, `'translation'`, `'rotation'`, `'reflection'` (in a line) or `'glide-reflection'`,
|
|
140
|
+
* as ITA names the operations (ITA 2016 Table 2.1.2.1, p. 145).
|
|
141
|
+
*/
|
|
142
|
+
readonly kind: 'identity' | 'translation' | 'rotation' | 'reflection' | 'glide-reflection';
|
|
143
|
+
/** The n of the linear part (an n-fold rotation): 1 for the identity and a translation, 2 for a reflection or glide reflection. */
|
|
144
|
+
readonly n: number;
|
|
141
145
|
/** For a rotation of order 3 or more: `'+'` if it turns a towards b, `'-'` otherwise. */
|
|
142
146
|
readonly sense?: '+' | '-';
|
|
143
147
|
/** For a translation: the translation vector. */
|
|
@@ -150,12 +154,14 @@ export interface OperationDescription {
|
|
|
150
154
|
/** For a mirror or glide: the direction of its line, the shortest integer vector, first non-zero component positive. */
|
|
151
155
|
readonly direction?: readonly number[];
|
|
152
156
|
/**
|
|
153
|
-
* For a
|
|
154
|
-
*
|
|
155
|
-
*
|
|
157
|
+
* For a reflection or glide reflection: its axis, the normal of its line in the lattice basis (as
|
|
158
|
+
* the `axis` of a reflection of the point groups is the normal of its plane, #137 C3), its symmetry
|
|
159
|
+
* direction with the sign of its Seitz symbol (ITA 2016 Tables 1.4.2.4, 1.4.2.5, p. 53: `m₁₀`, `m₁₂`,
|
|
160
|
+
* #107, #114): the shortest integer vector along the columns of W − I, first non-zero component
|
|
161
|
+
* 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
162
|
* basis the normal of a line along [1,0] is [1,2].
|
|
157
163
|
*/
|
|
158
|
-
readonly
|
|
164
|
+
readonly axis?: readonly number[];
|
|
159
165
|
/** For a glide: the glide vector (w + W·w)/2, not reduced modulo the lattice. */
|
|
160
166
|
readonly glide?: readonly number[];
|
|
161
167
|
}
|
|
@@ -172,17 +178,34 @@ export interface WyckoffPosition {
|
|
|
172
178
|
readonly coordinates: readonly string[];
|
|
173
179
|
}
|
|
174
180
|
|
|
175
|
-
/**
|
|
176
|
-
export interface
|
|
177
|
-
/** The point
|
|
181
|
+
/** The distance of a point to a Wyckoff position: the position, as `wyckoffPositions` gives it, the nearest point of it, and the distance. */
|
|
182
|
+
export interface WyckoffDistance extends WyckoffPosition {
|
|
183
|
+
/** The point of the position nearest to the given one (lattice basis), modulo the lattice, in [0, 1). */
|
|
178
184
|
readonly point: readonly number[];
|
|
185
|
+
/**
|
|
186
|
+
* The distance of the given point to the position: without a basis the larger of the two
|
|
187
|
+
* coordinate differences modulo the lattice, with a basis Euclidean in its unit.
|
|
188
|
+
*/
|
|
189
|
+
readonly distance: number;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/** Options of `wyckoffDistances`. */
|
|
193
|
+
export interface WyckoffDistanceOptions {
|
|
194
|
+
/**
|
|
195
|
+
* The Cartesian basis of the lattice, a 2 × 2 matrix whose columns are a and b; with it the
|
|
196
|
+
* distances are Euclidean, without it they are measured per lattice coordinate.
|
|
197
|
+
*/
|
|
198
|
+
readonly basis?: readonly (readonly number[])[];
|
|
179
199
|
}
|
|
180
200
|
|
|
181
201
|
/** The site symmetry of a point under a plane group. */
|
|
182
202
|
export interface SiteSymmetry {
|
|
183
203
|
/** Indices into `operations` of those that map the point onto itself modulo the lattice, ascending: a subgroup. */
|
|
184
204
|
readonly operations: readonly number[];
|
|
185
|
-
/**
|
|
205
|
+
/**
|
|
206
|
+
* The point set onto the Wyckoff position it lies on (the nearest point of the position, as
|
|
207
|
+
* `wyckoffDistances` gives it), in [0, 1).
|
|
208
|
+
*/
|
|
186
209
|
readonly point: readonly number[];
|
|
187
210
|
/** The number of points in the conventional cell equivalent to it. */
|
|
188
211
|
readonly multiplicity: number;
|
|
@@ -190,44 +213,59 @@ export interface SiteSymmetry {
|
|
|
190
213
|
readonly general: boolean;
|
|
191
214
|
}
|
|
192
215
|
|
|
193
|
-
/** The asymmetric unit of a plane group,
|
|
216
|
+
/** The asymmetric unit of a plane group: the printed inequalities, and the convex polygon they bound (lattice basis). */
|
|
194
217
|
export interface AsymmetricUnit {
|
|
195
|
-
/**
|
|
196
|
-
|
|
197
|
-
|
|
218
|
+
/**
|
|
219
|
+
* The inequalities as ITA prints them, in printed order, each [a, b, c] for a·x + b·y ≤ c
|
|
220
|
+
* (integers, no common factor), also those that hold no edge of the polygon (p3: x ≤ 2/3).
|
|
221
|
+
*/
|
|
198
222
|
readonly inequalities: readonly (readonly number[])[];
|
|
223
|
+
/** The vertices of the polygon, counter-clockwise (a towards b), starting at the lowest (smallest y, then x). */
|
|
224
|
+
readonly vertices: readonly (readonly number[])[];
|
|
225
|
+
/** Per edge, from vertex i to vertex i + 1, the index into `inequalities` of the inequality that holds it. */
|
|
226
|
+
readonly edges: readonly number[];
|
|
199
227
|
}
|
|
200
228
|
|
|
201
|
-
/** A rotation
|
|
202
|
-
export interface
|
|
203
|
-
/** The highest
|
|
204
|
-
readonly
|
|
205
|
-
/** Its
|
|
229
|
+
/** A rotation point (ITA 2016 Table 2.1.2.1, p. 145: the symmetry element of a rotation in the plane). */
|
|
230
|
+
export interface RotationPoint {
|
|
231
|
+
/** The highest n of an n-fold rotation about it. */
|
|
232
|
+
readonly n: number;
|
|
233
|
+
/** Its location, lattice basis. */
|
|
206
234
|
readonly point: readonly number[];
|
|
207
235
|
}
|
|
208
236
|
|
|
209
|
-
/** A mirror or glide line
|
|
237
|
+
/** A mirror or glide line, as a point and a direction (lattice basis). */
|
|
210
238
|
export interface SymmetryLine {
|
|
211
239
|
/** `'mirror'` or `'glide'`. */
|
|
212
240
|
readonly kind: 'mirror' | 'glide';
|
|
213
241
|
/** The direction of the line, the shortest integer vector, first non-zero component positive. */
|
|
214
242
|
readonly direction: readonly number[];
|
|
215
|
-
/** The normal of the line in the lattice basis, as in `describeOperations`. */
|
|
216
|
-
readonly
|
|
243
|
+
/** The normal of the line in the lattice basis, its symmetry direction, as `axis` in `describeOperations`. */
|
|
244
|
+
readonly axis: readonly number[];
|
|
217
245
|
/** For a glide line its glide vector s·direction, 0 < s < 1; for a mirror line (0, 0). */
|
|
218
246
|
readonly glide: readonly number[];
|
|
219
|
-
/**
|
|
220
|
-
readonly
|
|
247
|
+
/** A point of the line: its intersection with y = 0, or with x = 0 for a line along a. */
|
|
248
|
+
readonly point: readonly number[];
|
|
221
249
|
}
|
|
222
250
|
|
|
223
|
-
/**
|
|
251
|
+
/** Symmetry elements of a plane group. */
|
|
224
252
|
export interface SymmetryElements {
|
|
225
|
-
/** The rotation
|
|
226
|
-
readonly
|
|
227
|
-
/** The mirror and glide lines
|
|
253
|
+
/** The rotation points, by descending n, then by y and x. */
|
|
254
|
+
readonly rotationPoints: readonly RotationPoint[];
|
|
255
|
+
/** The mirror and glide lines, by direction, then by their point (x on y = 0, or y on x = 0), mirror before glide. */
|
|
228
256
|
readonly lines: readonly SymmetryLine[];
|
|
229
257
|
}
|
|
230
258
|
|
|
259
|
+
/** Options of `symmetryElements`. */
|
|
260
|
+
export interface SymmetryElementsOptions {
|
|
261
|
+
/**
|
|
262
|
+
* A box of the plane, lattice basis, as its lower left and its upper right corner (x₀ ≤ x₁,
|
|
263
|
+
* y₀ ≤ y₁; a line or a point of the plane also): all lattice translates of the elements that meet
|
|
264
|
+
* it, boundary included, the lines not clipped.
|
|
265
|
+
*/
|
|
266
|
+
readonly box?: readonly (readonly number[])[];
|
|
267
|
+
}
|
|
268
|
+
|
|
231
269
|
// ---------------------------------------------------------------------------------------------
|
|
232
270
|
|
|
233
271
|
const numbers = (v: readonly Rational[]): number[] => v.map(toNumber);
|
|
@@ -237,7 +275,7 @@ function isPlaneGroupKey(key: unknown): key is PlaneGroupKey {
|
|
|
237
275
|
}
|
|
238
276
|
|
|
239
277
|
function unknownKey(key: unknown, what = 'plane group or plane point group'): never {
|
|
240
|
-
throw new RangeError(`Unknown ${what}: ${
|
|
278
|
+
throw new RangeError(`Unknown ${what}: ${shown(key)}`);
|
|
241
279
|
}
|
|
242
280
|
|
|
243
281
|
/** The plane group of a key; throws for a point group or an unknown key. */
|
|
@@ -290,44 +328,49 @@ function describe(op: ExactOperation): OperationDescription {
|
|
|
290
328
|
const d = describePlaneOperation(op);
|
|
291
329
|
return Object.freeze({
|
|
292
330
|
kind: d.kind,
|
|
293
|
-
|
|
331
|
+
n: d.n,
|
|
294
332
|
...(d.sense ? { sense: d.sense } : {}),
|
|
295
333
|
...(d.translation ? { translation: Object.freeze(numbers(d.translation)) } : {}),
|
|
296
334
|
...(d.location ? { location: Object.freeze(numbers(d.location)) } : {}),
|
|
297
335
|
...(d.direction ? { direction: Object.freeze([...d.direction]) } : {}),
|
|
298
|
-
...(d.
|
|
336
|
+
...(d.axis ? { axis: Object.freeze([...d.axis]) } : {}),
|
|
299
337
|
...(d.glide ? { glide: Object.freeze(numbers(d.glide)) } : {}),
|
|
300
338
|
});
|
|
301
339
|
}
|
|
302
340
|
|
|
303
341
|
/** Tolerance for reading an integer or a fraction from a double. */
|
|
304
|
-
const READ_TOLERANCE = 1e-9;
|
|
305
342
|
/** The largest denominator of a translation that `describeOperationsOf` reads. */
|
|
306
343
|
const MAX_DENOMINATOR = 12;
|
|
307
344
|
|
|
308
|
-
|
|
345
|
+
/**
|
|
346
|
+
* The fraction with a denominator of at most `MAX_DENOMINATOR` within `tolerance` of the value.
|
|
347
|
+
* Two such fractions can lie as close as 1/132 (1/11 and 1/12): a value within the tolerance of two
|
|
348
|
+
* different ones is refused, not read as either.
|
|
349
|
+
*/
|
|
350
|
+
function fractionOf(value: unknown, tolerance: number): Rational {
|
|
309
351
|
if (typeof value === 'number' && Number.isFinite(value)) {
|
|
352
|
+
const found: Rational[] = [];
|
|
310
353
|
for (let d = 1; d <= MAX_DENOMINATOR; d++) {
|
|
311
|
-
const n
|
|
312
|
-
|
|
354
|
+
for (const n of [Math.floor(value * d), Math.ceil(value * d)]) {
|
|
355
|
+
if (Math.abs(value - n / d) >= tolerance) continue;
|
|
356
|
+
const r = rational(n, d);
|
|
357
|
+
if (!found.some((f) => f[0] === r[0] && f[1] === r[1])) found.push(r);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
if (found.length === 1) return found[0];
|
|
361
|
+
if (found.length > 1) {
|
|
362
|
+
throw new RangeError(
|
|
363
|
+
`The translation ${shown(value)} lies within ${tolerance} of ${found.map((f) => `${f[0]}/${f[1]}`).join(' and ')}: pass a smaller tolerance`,
|
|
364
|
+
);
|
|
313
365
|
}
|
|
314
366
|
}
|
|
315
367
|
throw new RangeError(
|
|
316
|
-
`Not within
|
|
368
|
+
`Not within ${tolerance} of a translation with a denominator of at most ${MAX_DENOMINATOR}: ${shown(value)}`,
|
|
317
369
|
);
|
|
318
370
|
}
|
|
319
371
|
|
|
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
372
|
/** 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 {
|
|
373
|
+
function exactOf(op: unknown, tolerance: number): ExactOperation {
|
|
331
374
|
const o = op as Partial<PlaneOperation> | null;
|
|
332
375
|
const m = o?.matrix;
|
|
333
376
|
const t = o?.translation;
|
|
@@ -337,13 +380,13 @@ function exactOf(op: unknown): ExactOperation {
|
|
|
337
380
|
}
|
|
338
381
|
const matrix = m.map((row) =>
|
|
339
382
|
row.map((v) => {
|
|
340
|
-
if (!(typeof v === 'number' && Math.abs(v - Math.round(v)) <
|
|
383
|
+
if (!(typeof v === 'number' && Math.abs(v - Math.round(v)) < tolerance)) {
|
|
341
384
|
throw new RangeError(`The matrix of a plane operation has integer entries, not ${shown(m)}`);
|
|
342
385
|
}
|
|
343
386
|
return Math.round(v) + 0;
|
|
344
387
|
}),
|
|
345
388
|
);
|
|
346
|
-
return { matrix, translation: t.map(fractionOf) };
|
|
389
|
+
return { matrix, translation: t.map((v) => fractionOf(v, tolerance)) };
|
|
347
390
|
}
|
|
348
391
|
|
|
349
392
|
/** The plane group with this key (short symbol). Throws a RangeError for an unknown key. */
|
|
@@ -353,7 +396,6 @@ export function planeGroup(key: PlaneGroupKey): PlaneGroup {
|
|
|
353
396
|
return Object.freeze({
|
|
354
397
|
key: entry.symbol as PlaneGroupKey,
|
|
355
398
|
number: entry.number,
|
|
356
|
-
fullSymbol: entry.fullSymbol,
|
|
357
399
|
pointGroup: point.key,
|
|
358
400
|
pointGroupSetting: point.setting,
|
|
359
401
|
crystalSystem: entry.system,
|
|
@@ -361,7 +403,6 @@ export function planeGroup(key: PlaneGroupKey): PlaneGroup {
|
|
|
361
403
|
entry.centring.map((t) => Object.freeze(t.split(',').map((c) => toNumber(parseRational(c))))),
|
|
362
404
|
),
|
|
363
405
|
origin: entry.origin,
|
|
364
|
-
order: planeGroupOperations(entry.symbol).length,
|
|
365
406
|
});
|
|
366
407
|
}
|
|
367
408
|
|
|
@@ -379,14 +420,37 @@ export function settings(key: PointGroupKey): readonly Setting[] {
|
|
|
379
420
|
const k = pointKey(key, 'settings');
|
|
380
421
|
return Object.freeze(
|
|
381
422
|
Array.from({ length: planePointGroupSettingCount(k) }, (_, i) =>
|
|
382
|
-
Object.freeze({ index: i + 1, symbol: planePointGroupSymbol(k, i + 1),
|
|
423
|
+
Object.freeze({ index: i + 1, symbol: planePointGroupSymbol(k, i + 1), isDefault: i === 0 }),
|
|
383
424
|
),
|
|
384
425
|
);
|
|
385
426
|
}
|
|
386
427
|
|
|
387
|
-
/**
|
|
388
|
-
|
|
389
|
-
|
|
428
|
+
/**
|
|
429
|
+
* The symbol of a plane group or a plane point group (#137 F4). In the short form (the default) the
|
|
430
|
+
* Hermann–Mauguin symbol as one word: for a plane group the key (`'p2mg'`, `'pm'`), for a plane
|
|
431
|
+
* point group in a setting `'3m1'` or `'31m'` for `3m`, otherwise the key. In the form `'full'`
|
|
432
|
+
* the full symbol with its positions separated by spaces, as in the other entry points: `'p 1 m 1'`
|
|
433
|
+
* for `pm` (ITA prints `p1m1`), `'p 2 m g'`, `'3 m 1'`; ITA prints no other full symbol for a plane
|
|
434
|
+
* point group (Ch. 3.2, p. 721, and Table 3.2.3.1). A plane group has setting 1 only. Throws a
|
|
435
|
+
* RangeError for an unknown key, setting or form.
|
|
436
|
+
*/
|
|
437
|
+
export function symbol(key: PlaneGroupKey | PointGroupKey, options?: SymbolOptions): string {
|
|
438
|
+
checkOptions(options, ['setting', 'form'], 'symbol');
|
|
439
|
+
const form = options?.form ?? 'short';
|
|
440
|
+
if (form !== 'short' && form !== 'full') {
|
|
441
|
+
throw new RangeError(`Unknown symbol form: ${shown(form)} (short or full)`);
|
|
442
|
+
}
|
|
443
|
+
// Every position of a plane symbol is one character, the lattice letter included.
|
|
444
|
+
const spaced = (text: string) => (form === 'full' ? [...text].join(' ') : text);
|
|
445
|
+
if (isPlaneGroupKey(key)) {
|
|
446
|
+
const setting = settingOf(options);
|
|
447
|
+
if (setting !== undefined && setting !== 1) {
|
|
448
|
+
throw new RangeError(`The plane group ${key} has no setting ${shown(setting)}`);
|
|
449
|
+
}
|
|
450
|
+
return spaced(form === 'full' ? planeGroupEntry(key).fullSymbol : key);
|
|
451
|
+
}
|
|
452
|
+
if (!isPlanePointGroupKey(key)) return unknownKey(key);
|
|
453
|
+
return spaced(planePointGroupSymbol(key, settingOf(options)));
|
|
390
454
|
}
|
|
391
455
|
|
|
392
456
|
/**
|
|
@@ -398,6 +462,7 @@ export function symbol(key: PointGroupKey, options?: SettingOptions): string {
|
|
|
398
462
|
* or setting.
|
|
399
463
|
*/
|
|
400
464
|
export function operations(key: PlaneGroupKey | PointGroupKey, options?: SettingOptions): readonly PlaneOperation[] {
|
|
465
|
+
checkOptions(options, ['setting'], 'operations');
|
|
401
466
|
return Object.freeze(exact(key, options, false).map(plain));
|
|
402
467
|
}
|
|
403
468
|
|
|
@@ -407,18 +472,20 @@ export function operations(key: PlaneGroupKey | PointGroupKey, options?: Setting
|
|
|
407
472
|
* generators of its symmorphic plane group. Throws a RangeError for an unknown key or setting.
|
|
408
473
|
*/
|
|
409
474
|
export function generators(key: PlaneGroupKey | PointGroupKey, options?: SettingOptions): readonly PlaneOperation[] {
|
|
475
|
+
checkOptions(options, ['setting'], 'generators');
|
|
410
476
|
return Object.freeze(exact(key, options, true).map(plain));
|
|
411
477
|
}
|
|
412
478
|
|
|
413
479
|
/**
|
|
414
480
|
* Each operation of `operations` (same key and setting) described geometrically, index for index:
|
|
415
|
-
* what it is, its
|
|
481
|
+
* what it is, its n and sense, where its symmetry element lies, its glide part. Throws a
|
|
416
482
|
* RangeError for an unknown key or setting.
|
|
417
483
|
*/
|
|
418
484
|
export function describeOperations(
|
|
419
485
|
key: PlaneGroupKey | PointGroupKey,
|
|
420
486
|
options?: SettingOptions,
|
|
421
487
|
): readonly OperationDescription[] {
|
|
488
|
+
checkOptions(options, ['setting'], 'describeOperations');
|
|
422
489
|
return Object.freeze(exact(key, options, false).map(describe));
|
|
423
490
|
}
|
|
424
491
|
|
|
@@ -427,16 +494,22 @@ export function describeOperations(
|
|
|
427
494
|
* `describeOperations` describes those of a group: for instance a product of operations, an
|
|
428
495
|
* operation shifted by a lattice translation, or the operations of a site symmetry. Each operation is
|
|
429
496
|
* `{ 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
|
|
497
|
+
* the tolerance, per entry) and be the linear part of a crystallographic plane point group
|
|
498
|
+
* (determinant ±1, order 1, 2, 3, 4 or 6); each component of a translation is read as the fraction
|
|
499
|
+
* with a denominator of at most 12 within the tolerance (1/3 from 0.333…), as the translations of
|
|
500
|
+
* `operations` and their products are. Throws a RangeError otherwise, also for a component within
|
|
501
|
+
* the tolerance of two such fractions (which can lie 1/132 apart).
|
|
434
502
|
*/
|
|
435
|
-
export function describeOperationsOf(
|
|
503
|
+
export function describeOperationsOf(
|
|
504
|
+
operations: readonly PlaneOperation[],
|
|
505
|
+
options?: ToleranceOptions,
|
|
506
|
+
): readonly OperationDescription[] {
|
|
507
|
+
checkOptions(options, TOLERANCE_KEYS, 'describeOperationsOf');
|
|
508
|
+
const tolerance = toleranceOf(options, 'operations');
|
|
436
509
|
if (!Array.isArray(operations)) {
|
|
437
510
|
throw new RangeError('describeOperationsOf takes a list of operations { matrix, translation }');
|
|
438
511
|
}
|
|
439
|
-
return Object.freeze(operations.map((op) => describe(exactOf(op))));
|
|
512
|
+
return Object.freeze(operations.map((op) => describe(exactOf(op, tolerance))));
|
|
440
513
|
}
|
|
441
514
|
|
|
442
515
|
/**
|
|
@@ -454,13 +527,15 @@ export function wyckoffPositions(key: PlaneGroupKey): readonly WyckoffPosition[]
|
|
|
454
527
|
}
|
|
455
528
|
|
|
456
529
|
/**
|
|
457
|
-
* The site symmetry of a point (lattice basis) under a plane group
|
|
458
|
-
*
|
|
459
|
-
*
|
|
460
|
-
*
|
|
530
|
+
* The site symmetry of a point (lattice basis) under a plane group, as one notion with its Wyckoff
|
|
531
|
+
* position (#137 F1): the point is set onto the position it lies on within the tolerance
|
|
532
|
+
* (`wyckoffPosition`), and the site symmetry is that of the point there; `point` is the point on the
|
|
533
|
+
* position. Throws a RangeError for an unknown key, a point that is not two finite numbers, or a
|
|
534
|
+
* tolerance outside (0, 1/2).
|
|
461
535
|
*/
|
|
462
|
-
export function siteSymmetry(key: PlaneGroupKey, point: readonly number[], options?:
|
|
463
|
-
|
|
536
|
+
export function siteSymmetry(key: PlaneGroupKey, point: readonly number[], options?: ToleranceOptions): SiteSymmetry {
|
|
537
|
+
checkOptions(options, TOLERANCE_KEYS, 'siteSymmetry');
|
|
538
|
+
const site = planeSiteOfPosition(groupKey(key, 'siteSymmetry'), point, options);
|
|
464
539
|
return Object.freeze({
|
|
465
540
|
operations: Object.freeze([...site.operations]),
|
|
466
541
|
point: Object.freeze([...site.point]),
|
|
@@ -471,15 +546,18 @@ export function siteSymmetry(key: PlaneGroupKey, point: readonly number[], optio
|
|
|
471
546
|
|
|
472
547
|
/**
|
|
473
548
|
* The Wyckoff position of a point (lattice basis) under a plane group, as `wyckoffPositions` gives
|
|
474
|
-
* it: the printed position
|
|
475
|
-
*
|
|
549
|
+
* it: the most special printed position whose point set lies within the tolerance of the point,
|
|
550
|
+
* measured per coordinate modulo the lattice, and among positions of equal multiplicity the nearest
|
|
551
|
+
* (the distance of `wyckoffDistances`); the general position always holds the point. Throws a
|
|
552
|
+
* RangeError as `siteSymmetry`.
|
|
476
553
|
*/
|
|
477
|
-
export function
|
|
554
|
+
export function wyckoffPosition(
|
|
478
555
|
key: PlaneGroupKey,
|
|
479
556
|
point: readonly number[],
|
|
480
|
-
options?:
|
|
557
|
+
options?: ToleranceOptions,
|
|
481
558
|
): WyckoffPosition {
|
|
482
|
-
|
|
559
|
+
checkOptions(options, TOLERANCE_KEYS, 'wyckoffPosition');
|
|
560
|
+
const k = groupKey(key, 'wyckoffPosition');
|
|
483
561
|
const { letter } = planeWyckoffPositionOf(k, point, options);
|
|
484
562
|
const found = wyckoffPositions(k).find((w) => w.letter === letter);
|
|
485
563
|
if (!found) throw new Error(`No Wyckoff position ${letter} in ${k}`);
|
|
@@ -487,74 +565,122 @@ export function wyckoffPositionOf(
|
|
|
487
565
|
}
|
|
488
566
|
|
|
489
567
|
/**
|
|
490
|
-
*
|
|
491
|
-
*
|
|
492
|
-
*
|
|
493
|
-
*
|
|
494
|
-
*
|
|
495
|
-
*
|
|
496
|
-
*
|
|
497
|
-
*
|
|
498
|
-
* lattice
|
|
568
|
+
* The distance of a point (lattice basis) to every Wyckoff position of a plane group, in the
|
|
569
|
+
* printed order of `wyckoffPositions`, each with the nearest point of the position (#137 F1, #108).
|
|
570
|
+
* The point set of a position is the union of its printed coordinates with every centring and
|
|
571
|
+
* lattice translation: a point, a line or the plane. Without a basis the distance is the larger of
|
|
572
|
+
* the two coordinate differences modulo the lattice, the metric of the tolerance of
|
|
573
|
+
* `wyckoffPosition`; with a basis (columns a, b) it is Euclidean, and the nearest point is the
|
|
574
|
+
* Euclidean nearest one; per coordinate the nearest point of a line need not be unique (on x,0 every x
|
|
575
|
+
* within the distance is as near), and then it is one of them. The basis should be a reduced cell,
|
|
576
|
+
* such as the conventional one: the nearest lattice translate is sought near the rounded
|
|
577
|
+
* coordinates. How to snap a dragged point onto a position (which position wins, within
|
|
578
|
+
* which radius) is the application's choice; this gives the numbers for it. Throws a RangeError for
|
|
579
|
+
* an unknown key, a point that is not two finite numbers, and a basis that is not a non-singular
|
|
580
|
+
* 2 × 2 matrix.
|
|
499
581
|
*/
|
|
500
|
-
export function
|
|
582
|
+
export function wyckoffDistances(
|
|
501
583
|
key: PlaneGroupKey,
|
|
502
584
|
point: readonly number[],
|
|
503
|
-
options?:
|
|
504
|
-
):
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
585
|
+
options?: WyckoffDistanceOptions,
|
|
586
|
+
): readonly WyckoffDistance[] {
|
|
587
|
+
checkOptions(options, ['basis'], 'wyckoffDistances');
|
|
588
|
+
const k = groupKey(key, 'wyckoffDistances');
|
|
589
|
+
const g = options?.basis === undefined ? undefined : planeMetric(options.basis);
|
|
590
|
+
const positions = wyckoffPositions(k);
|
|
591
|
+
return Object.freeze(
|
|
592
|
+
planeWyckoffDistances(k, point, g).map((d) =>
|
|
593
|
+
Object.freeze({ ...positions[d.row], point: Object.freeze([...d.point]), distance: d.distance }),
|
|
594
|
+
),
|
|
595
|
+
);
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
/** One point of the orbit of a point. */
|
|
599
|
+
export interface PointOrbitEntry {
|
|
600
|
+
/** The image, in the lattice basis, in [0, 1). */
|
|
601
|
+
readonly point: readonly number[];
|
|
602
|
+
/** Indices into `operations` of the operations that map the given point here (modulo the lattice), ascending. */
|
|
603
|
+
readonly operations: readonly number[];
|
|
512
604
|
}
|
|
513
605
|
|
|
514
606
|
/**
|
|
515
|
-
* The orbit of a point (lattice basis) under a plane group:
|
|
516
|
-
*
|
|
517
|
-
*
|
|
607
|
+
* The orbit of a point (lattice basis) under a plane group: the images of the point set onto its
|
|
608
|
+
* Wyckoff position (as `siteSymmetry` sets it), each in [0, 1), in the order of the operations that
|
|
609
|
+
* first give them, each with the indices of the operations that map the point there (as the
|
|
610
|
+
* entries of the orbits of the point groups): one entry per coset of the site symmetry, so the
|
|
611
|
+
* first entry holds the operations of `siteSymmetry`. Throws a RangeError as `siteSymmetry`.
|
|
518
612
|
*/
|
|
519
613
|
export function orbit(
|
|
520
614
|
key: PlaneGroupKey,
|
|
521
615
|
point: readonly number[],
|
|
522
|
-
options?:
|
|
523
|
-
): readonly
|
|
524
|
-
|
|
616
|
+
options?: ToleranceOptions,
|
|
617
|
+
): readonly PointOrbitEntry[] {
|
|
618
|
+
checkOptions(options, TOLERANCE_KEYS, 'orbit');
|
|
619
|
+
return Object.freeze(
|
|
620
|
+
planeOrbit(groupKey(key, 'orbit'), point, options).map((e) =>
|
|
621
|
+
Object.freeze({ point: Object.freeze(e.point), operations: Object.freeze(e.operations) }),
|
|
622
|
+
),
|
|
623
|
+
);
|
|
525
624
|
}
|
|
526
625
|
|
|
527
626
|
/**
|
|
528
|
-
* The asymmetric unit of a plane group as ITA prints it
|
|
529
|
-
*
|
|
627
|
+
* The asymmetric unit of a plane group as ITA prints it (#137 F3): the printed inequalities, all of
|
|
628
|
+
* them in printed order (a double inequality and a `min` give one each), and the convex polygon
|
|
629
|
+
* they bound, with its vertices and, per edge, the index of the inequality that holds it. Throws a
|
|
630
|
+
* RangeError for an unknown key.
|
|
530
631
|
*/
|
|
531
632
|
export function asymmetricUnit(key: PlaneGroupKey): AsymmetricUnit {
|
|
532
633
|
const unit = planeAsymmetricUnit(groupKey(key, 'asymmetricUnit'));
|
|
533
634
|
return Object.freeze({
|
|
534
|
-
vertices: Object.freeze(unit.vertices.map((v) => Object.freeze(numbers(v)))),
|
|
535
635
|
inequalities: Object.freeze(unit.inequalities.map((q) => Object.freeze([...q]))),
|
|
636
|
+
vertices: Object.freeze(unit.vertices.map((v) => Object.freeze(numbers(v)))),
|
|
637
|
+
edges: Object.freeze([...unit.edges]),
|
|
536
638
|
});
|
|
537
639
|
}
|
|
538
640
|
|
|
539
641
|
/**
|
|
540
|
-
* The symmetry elements of a plane group
|
|
541
|
-
*
|
|
542
|
-
*
|
|
642
|
+
* The symmetry elements of a plane group (#137 F2). Without a box, each element once modulo the
|
|
643
|
+
* lattice translations, the centring (1/2, 1/2) included, as ITA describes them (cm: the mirror line
|
|
644
|
+
* 0,y and the glide line 1/4,y): every rotation point in [0, 1)² with the highest n of a rotation
|
|
645
|
+
* about it, and every mirror and glide line, as a point in [0, 1)² and a direction. With a box, all
|
|
646
|
+
* their lattice translates that meet it, boundary included; the lines are not clipped, since
|
|
647
|
+
* clipping is drawing. Throws a RangeError for an unknown key, a box that is not two corners of
|
|
648
|
+
* finite numbers, the first not above or right of the second, and a box with more than a million
|
|
649
|
+
* rotation points.
|
|
543
650
|
*/
|
|
544
|
-
export function symmetryElements(key: PlaneGroupKey): SymmetryElements {
|
|
545
|
-
|
|
651
|
+
export function symmetryElements(key: PlaneGroupKey, options?: SymmetryElementsOptions): SymmetryElements {
|
|
652
|
+
checkOptions(options, ['box'], 'symmetryElements');
|
|
653
|
+
const k = groupKey(key, 'symmetryElements');
|
|
654
|
+
const box = options?.box;
|
|
655
|
+
let e;
|
|
656
|
+
if (box === undefined) e = planeElements(k);
|
|
657
|
+
else {
|
|
658
|
+
const ok =
|
|
659
|
+
Array.isArray(box) &&
|
|
660
|
+
box.length === 2 &&
|
|
661
|
+
box.every(
|
|
662
|
+
(c) => Array.isArray(c) && c.length === 2 && c.every((v) => typeof v === 'number' && Number.isFinite(v)),
|
|
663
|
+
);
|
|
664
|
+
if (!ok || !(box[0][0] <= box[1][0] && box[0][1] <= box[1][1])) {
|
|
665
|
+
throw new RangeError(`A box is two corners [[x0, y0], [x1, y1]] with x0 <= x1 and y0 <= y1, not ${shown(box)}`);
|
|
666
|
+
}
|
|
667
|
+
e = planeElementsInBox(k, [
|
|
668
|
+
[box[0][0], box[0][1]],
|
|
669
|
+
[box[1][0], box[1][1]],
|
|
670
|
+
]);
|
|
671
|
+
}
|
|
546
672
|
return Object.freeze({
|
|
547
|
-
|
|
548
|
-
e.
|
|
673
|
+
rotationPoints: Object.freeze(
|
|
674
|
+
e.rotationPoints.map((r) => Object.freeze({ n: r.n, point: Object.freeze(numbers(r.point)) })),
|
|
549
675
|
),
|
|
550
676
|
lines: Object.freeze(
|
|
551
677
|
e.lines.map((l) =>
|
|
552
678
|
Object.freeze({
|
|
553
679
|
kind: l.kind,
|
|
554
680
|
direction: Object.freeze([...l.direction]),
|
|
555
|
-
|
|
681
|
+
axis: Object.freeze([...l.axis]),
|
|
556
682
|
glide: Object.freeze(numbers(l.glide)),
|
|
557
|
-
|
|
683
|
+
point: Object.freeze(numbers(l.point)),
|
|
558
684
|
}),
|
|
559
685
|
),
|
|
560
686
|
),
|