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.
Files changed (218) hide show
  1. package/README.md +6 -6
  2. package/dist/cell.d.ts +19 -16
  3. package/dist/cell.d.ts.map +1 -1
  4. package/dist/cell.js +63 -35
  5. package/dist/cell.js.map +1 -1
  6. package/dist/checks.d.ts +29 -0
  7. package/dist/checks.d.ts.map +1 -0
  8. package/dist/checks.js +79 -0
  9. package/dist/checks.js.map +1 -0
  10. package/dist/closure.d.ts +43 -0
  11. package/dist/closure.d.ts.map +1 -0
  12. package/dist/closure.js +201 -0
  13. package/dist/closure.js.map +1 -0
  14. package/dist/crystalClasses.d.ts +146 -118
  15. package/dist/crystalClasses.d.ts.map +1 -1
  16. package/dist/crystalClasses.js +163 -124
  17. package/dist/crystalClasses.js.map +1 -1
  18. package/dist/freeze.d.ts +7 -0
  19. package/dist/freeze.d.ts.map +1 -0
  20. package/dist/freeze.js +15 -0
  21. package/dist/freeze.js.map +1 -0
  22. package/dist/index.d.ts +11 -10
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +4 -3
  25. package/dist/index.js.map +1 -1
  26. package/dist/indices.d.ts +31 -5
  27. package/dist/indices.d.ts.map +1 -1
  28. package/dist/indices.js +104 -13
  29. package/dist/indices.js.map +1 -1
  30. package/dist/lattice.d.ts +15 -1
  31. package/dist/lattice.d.ts.map +1 -1
  32. package/dist/lattice.js +30 -1
  33. package/dist/lattice.js.map +1 -1
  34. package/dist/linalg.d.ts +2 -2
  35. package/dist/linalg.d.ts.map +1 -1
  36. package/dist/linalg.js +3 -3
  37. package/dist/linalg.js.map +1 -1
  38. package/dist/magnetic.d.ts +12 -10
  39. package/dist/magnetic.d.ts.map +1 -1
  40. package/dist/magnetic.js +8 -6
  41. package/dist/magnetic.js.map +1 -1
  42. package/dist/notation.d.ts +16 -0
  43. package/dist/notation.d.ts.map +1 -0
  44. package/dist/notation.js +66 -0
  45. package/dist/notation.js.map +1 -0
  46. package/dist/operations.d.ts +40 -26
  47. package/dist/operations.d.ts.map +1 -1
  48. package/dist/operations.js +48 -60
  49. package/dist/operations.js.map +1 -1
  50. package/dist/plane.d.ts +141 -79
  51. package/dist/plane.d.ts.map +1 -1
  52. package/dist/plane.js +147 -77
  53. package/dist/plane.js.map +1 -1
  54. package/dist/pointGroups/crystalForms.d.ts +6 -21
  55. package/dist/pointGroups/crystalForms.d.ts.map +1 -1
  56. package/dist/pointGroups/crystalForms.js +9 -16
  57. package/dist/pointGroups/crystalForms.js.map +1 -1
  58. package/dist/pointGroups/crystalFormsData.d.ts +4 -1
  59. package/dist/pointGroups/crystalFormsData.d.ts.map +1 -1
  60. package/dist/pointGroups/crystalFormsData.js +64 -1
  61. package/dist/pointGroups/crystalFormsData.js.map +1 -1
  62. package/dist/pointGroups/elements.d.ts +19 -17
  63. package/dist/pointGroups/elements.d.ts.map +1 -1
  64. package/dist/pointGroups/elements.js +65 -83
  65. package/dist/pointGroups/elements.js.map +1 -1
  66. package/dist/pointGroups/identify.d.ts +10 -18
  67. package/dist/pointGroups/identify.d.ts.map +1 -1
  68. package/dist/pointGroups/identify.js +27 -79
  69. package/dist/pointGroups/identify.js.map +1 -1
  70. package/dist/pointGroups/itaOrder.d.ts +15 -14
  71. package/dist/pointGroups/itaOrder.d.ts.map +1 -1
  72. package/dist/pointGroups/itaOrder.js +116 -94
  73. package/dist/pointGroups/itaOrder.js.map +1 -1
  74. package/dist/pointGroups/itcData.d.ts +96 -0
  75. package/dist/pointGroups/itcData.d.ts.map +1 -0
  76. package/dist/pointGroups/itcData.js +336 -0
  77. package/dist/pointGroups/itcData.js.map +1 -0
  78. package/dist/pointGroups/itcMagneticData.d.ts +55 -0
  79. package/dist/pointGroups/itcMagneticData.d.ts.map +1 -0
  80. package/dist/pointGroups/itcMagneticData.js +172 -0
  81. package/dist/pointGroups/itcMagneticData.js.map +1 -0
  82. package/dist/pointGroups/keys.d.ts +32 -0
  83. package/dist/pointGroups/keys.d.ts.map +1 -0
  84. package/dist/pointGroups/keys.js +120 -0
  85. package/dist/pointGroups/keys.js.map +1 -0
  86. package/dist/pointGroups/magneticSymbols.d.ts +6 -5
  87. package/dist/pointGroups/magneticSymbols.d.ts.map +1 -1
  88. package/dist/pointGroups/magneticSymbols.js +15 -12
  89. package/dist/pointGroups/magneticSymbols.js.map +1 -1
  90. package/dist/pointGroups/orbits.d.ts +23 -42
  91. package/dist/pointGroups/orbits.d.ts.map +1 -1
  92. package/dist/pointGroups/orbits.js +20 -62
  93. package/dist/pointGroups/orbits.js.map +1 -1
  94. package/dist/pointGroups/pointGroups.d.ts +135 -67
  95. package/dist/pointGroups/pointGroups.d.ts.map +1 -1
  96. package/dist/pointGroups/pointGroups.js +409 -244
  97. package/dist/pointGroups/pointGroups.js.map +1 -1
  98. package/dist/pointGroups/properties.d.ts +21 -22
  99. package/dist/pointGroups/properties.d.ts.map +1 -1
  100. package/dist/pointGroups/properties.js +40 -37
  101. package/dist/pointGroups/properties.js.map +1 -1
  102. package/dist/pointGroups/seitzData.d.ts +26 -0
  103. package/dist/pointGroups/seitzData.d.ts.map +1 -0
  104. package/dist/pointGroups/seitzData.js +130 -0
  105. package/dist/pointGroups/seitzData.js.map +1 -0
  106. package/dist/pointGroups/wyckoff.d.ts +70 -40
  107. package/dist/pointGroups/wyckoff.d.ts.map +1 -1
  108. package/dist/pointGroups/wyckoff.js +98 -91
  109. package/dist/pointGroups/wyckoff.js.map +1 -1
  110. package/dist/pointGroups/wyckoffData.d.ts +7 -4
  111. package/dist/pointGroups/wyckoffData.d.ts.map +1 -1
  112. package/dist/pointGroups/wyckoffData.js +789 -168
  113. package/dist/pointGroups/wyckoffData.js.map +1 -1
  114. package/dist/siteSymmetry.d.ts +9 -17
  115. package/dist/siteSymmetry.d.ts.map +1 -1
  116. package/dist/siteSymmetry.js +62 -47
  117. package/dist/siteSymmetry.js.map +1 -1
  118. package/dist/spaceGroups/affine.d.ts.map +1 -1
  119. package/dist/spaceGroups/affine.js +3 -2
  120. package/dist/spaceGroups/affine.js.map +1 -1
  121. package/dist/spaceGroups/cell.d.ts +43 -31
  122. package/dist/spaceGroups/cell.d.ts.map +1 -1
  123. package/dist/spaceGroups/cell.js +173 -85
  124. package/dist/spaceGroups/cell.js.map +1 -1
  125. package/dist/spaceGroups/describe.d.ts +12 -10
  126. package/dist/spaceGroups/describe.d.ts.map +1 -1
  127. package/dist/spaceGroups/describe.js +11 -10
  128. package/dist/spaceGroups/describe.js.map +1 -1
  129. package/dist/spaceGroups/planeGroupData.d.ts +1 -1
  130. package/dist/spaceGroups/planeGroupData.d.ts.map +1 -1
  131. package/dist/spaceGroups/planeGroupData.js +8 -8
  132. package/dist/spaceGroups/planeGroupData.js.map +1 -1
  133. package/dist/spaceGroups/planeGroups.d.ts.map +1 -1
  134. package/dist/spaceGroups/planeGroups.js +2 -1
  135. package/dist/spaceGroups/planeGroups.js.map +1 -1
  136. package/dist/spaceGroups/positions.d.ts +48 -19
  137. package/dist/spaceGroups/positions.d.ts.map +1 -1
  138. package/dist/spaceGroups/positions.js +166 -67
  139. package/dist/spaceGroups/positions.js.map +1 -1
  140. package/dist/tensors/propertyTable.d.ts +3 -1
  141. package/dist/tensors/propertyTable.d.ts.map +1 -1
  142. package/dist/tensors/propertyTable.js +17 -10
  143. package/dist/tensors/propertyTable.js.map +1 -1
  144. package/dist/tensors/rowEchelon.d.ts +12 -4
  145. package/dist/tensors/rowEchelon.d.ts.map +1 -1
  146. package/dist/tensors/rowEchelon.js +24 -11
  147. package/dist/tensors/rowEchelon.js.map +1 -1
  148. package/dist/tensors/tensorForm.d.ts +75 -34
  149. package/dist/tensors/tensorForm.d.ts.map +1 -1
  150. package/dist/tensors/tensorForm.js +173 -68
  151. package/dist/tensors/tensorForm.js.map +1 -1
  152. package/dist/tensors/tensorProperties.d.ts +10 -9
  153. package/dist/tensors/tensorProperties.d.ts.map +1 -1
  154. package/dist/tensors/tensorProperties.js +22 -12
  155. package/dist/tensors/tensorProperties.js.map +1 -1
  156. package/dist/tolerances.d.ts +56 -1
  157. package/dist/tolerances.d.ts.map +1 -1
  158. package/dist/tolerances.js +51 -1
  159. package/dist/tolerances.js.map +1 -1
  160. package/dist/version.d.ts +1 -1
  161. package/dist/version.js +1 -1
  162. package/package.json +1 -1
  163. package/src/cell.ts +78 -51
  164. package/src/checks.ts +84 -0
  165. package/src/closure.ts +214 -0
  166. package/src/crystalClasses.ts +234 -160
  167. package/src/freeze.ts +14 -0
  168. package/src/index.ts +21 -10
  169. package/src/indices.ts +108 -18
  170. package/src/lattice.ts +41 -1
  171. package/src/linalg.ts +3 -3
  172. package/src/magnetic.ts +14 -9
  173. package/src/notation.ts +73 -0
  174. package/src/operations.ts +78 -69
  175. package/src/plane.ts +253 -127
  176. package/src/pointGroups/crystalForms.ts +11 -44
  177. package/src/pointGroups/crystalFormsData.ts +66 -1
  178. package/src/pointGroups/elements.ts +82 -92
  179. package/src/pointGroups/identify.ts +38 -97
  180. package/src/pointGroups/itaOrder.ts +117 -101
  181. package/src/pointGroups/itcData.ts +404 -0
  182. package/src/pointGroups/itcMagneticData.ts +206 -0
  183. package/src/pointGroups/keys.ts +144 -0
  184. package/src/pointGroups/magneticSymbols.ts +18 -17
  185. package/src/pointGroups/orbits.ts +41 -89
  186. package/src/pointGroups/pointGroups.ts +540 -297
  187. package/src/pointGroups/properties.ts +44 -40
  188. package/src/pointGroups/seitzData.ts +147 -0
  189. package/src/pointGroups/wyckoff.ts +137 -112
  190. package/src/pointGroups/wyckoffData.ts +793 -170
  191. package/src/siteSymmetry.ts +71 -64
  192. package/src/spaceGroups/affine.ts +3 -2
  193. package/src/spaceGroups/cell.ts +227 -116
  194. package/src/spaceGroups/describe.ts +22 -19
  195. package/src/spaceGroups/planeGroupData.ts +9 -9
  196. package/src/spaceGroups/planeGroups.ts +2 -1
  197. package/src/spaceGroups/positions.ts +202 -78
  198. package/src/tensors/propertyTable.ts +29 -17
  199. package/src/tensors/rowEchelon.ts +28 -9
  200. package/src/tensors/tensorForm.ts +260 -89
  201. package/src/tensors/tensorProperties.ts +34 -14
  202. package/src/tolerances.ts +66 -1
  203. package/src/version.ts +1 -1
  204. package/dist/pointGroups/data.d.ts +0 -75
  205. package/dist/pointGroups/data.d.ts.map +0 -1
  206. package/dist/pointGroups/data.js +0 -212
  207. package/dist/pointGroups/data.js.map +0 -1
  208. package/dist/pointGroups/magneticData.d.ts +0 -66
  209. package/dist/pointGroups/magneticData.d.ts.map +0 -1
  210. package/dist/pointGroups/magneticData.js +0 -184
  211. package/dist/pointGroups/magneticData.js.map +0 -1
  212. package/dist/spaceGroups/snap.d.ts +0 -20
  213. package/dist/spaceGroups/snap.d.ts.map +0 -1
  214. package/dist/spaceGroups/snap.js +0 -103
  215. package/dist/spaceGroups/snap.js.map +0 -1
  216. package/src/pointGroups/data.ts +0 -305
  217. package/src/pointGroups/magneticData.ts +0 -328
  218. package/src/spaceGroups/snap.ts +0 -121
@@ -1,11 +1,12 @@
1
1
  /**
2
- * The asymmetric unit of a plane group and its symmetry elements in the conventional cell, as numbers
3
- * (CLAUDE.md, "The API of `symcrys/plane`"): the asymmetric unit as inequalities with its vertices,
4
- * the elements as rotation centres with their order and as mirror and glide lines with the segment
5
- * that lies in the cell [0, 1]². Exact, in the lattice basis; drawing them stays with the
6
- * applications. Internal for now.
2
+ * The asymmetric unit of a plane group and its symmetry elements, as numbers (CLAUDE.md, "Elements
3
+ * and the asymmetric unit as data"): the asymmetric unit as its printed inequalities with the
4
+ * polygon they bound, the elements as rotation points with their n and as mirror and glide lines
5
+ * by a point and a direction, once modulo the lattice or all translates in a box. Exact, in the
6
+ * lattice basis; drawing them stays with the applications. Internal for now.
7
7
  */
8
8
 
9
+ import { shown } from '../checks.js';
9
10
  import { type ExactOperation } from './affine.js';
10
11
  import { describePlaneOperation } from './describe.js';
11
12
  import { planeGroupEntry, planeGroupOperations } from './planeGroups.js';
@@ -28,44 +29,49 @@ import {
28
29
  /** An inequality a·x + b·y ≤ c with integer coefficients without a common factor. */
29
30
  export type Inequality = readonly [a: number, b: number, c: number];
30
31
 
31
- /** The asymmetric unit of a plane group, a convex polygon in the lattice basis. */
32
+ /** The asymmetric unit of a plane group: the printed inequalities, and the convex polygon they bound. */
32
33
  export interface AsymmetricUnit {
33
- /** Its vertices, counter-clockwise in the lattice basis (a towards b), starting at the vertex with the smallest y, then x. */
34
- readonly vertices: readonly (readonly Rational[])[];
35
- /** Its edges as inequalities: inequality i holds the edge from vertex i to vertex i + 1. */
34
+ /** The inequalities as printed, in printed order, also those that hold no edge (p3: x ≤ 2/3). */
36
35
  readonly inequalities: readonly Inequality[];
36
+ /** The vertices of the polygon, counter-clockwise in the lattice basis (a towards b), starting at the vertex with the smallest y, then x. */
37
+ readonly vertices: readonly (readonly Rational[])[];
38
+ /** Per edge, from vertex i to vertex i + 1, the index into `inequalities` of the one that holds it. */
39
+ readonly edges: readonly number[];
37
40
  }
38
41
 
39
- /** A rotation centre in the cell. */
40
- export interface RotationCentre {
41
- /** The highest order of a rotation about it. */
42
- readonly order: number;
43
- /** Its position in [0, 1]². */
42
+ /** A rotation point (ITA 2016 Table 2.1.2.1, p. 145: the symmetry element of a rotation in the plane). */
43
+ export interface RotationPoint {
44
+ /** The highest n of an n-fold rotation about it. */
45
+ readonly n: number;
46
+ /** Its location. */
44
47
  readonly point: readonly Rational[];
45
48
  }
46
49
 
47
- /** A mirror or glide line, the part of it in the cell. */
50
+ /** A mirror or glide line, as a point and a direction. */
48
51
  export interface SymmetryLine {
49
52
  /** `'mirror'` or `'glide'`. */
50
53
  readonly kind: 'mirror' | 'glide';
51
54
  /** The direction of the line, the shortest integer vector, first non-zero component positive. */
52
55
  readonly direction: readonly [number, number];
53
- /** The normal of the line in the lattice basis, as `PlaneOperationDescription.normal`. */
54
- readonly normal: readonly [number, number];
56
+ /** The normal of the line in the lattice basis, as `PlaneOperationDescription.axis`. */
57
+ readonly axis: readonly [number, number];
55
58
  /** For a glide line: its glide vector s·direction with 0 < s < 1; for a mirror line (0, 0). */
56
59
  readonly glide: readonly Rational[];
57
- /** The ends of the segment of the line in the cell [0, 1]², in the order of `direction`. */
58
- readonly segment: readonly [readonly Rational[], readonly Rational[]];
60
+ /** A point of the line: its intersection with y = 0, or with x = 0 for a line along a. */
61
+ readonly point: readonly Rational[];
59
62
  }
60
63
 
61
- /** The symmetry elements of a plane group in the cell [0, 1]². */
64
+ /** Symmetry elements of a plane group. */
62
65
  export interface CellElements {
63
- /** The rotation centres, by descending order, then by y and x. */
64
- readonly rotations: readonly RotationCentre[];
65
- /** The mirror and glide lines with a segment of non-zero length in the cell, by direction, then by the start of the segment (y, then x). */
66
+ /** The rotation points, by descending n, then by y and x. */
67
+ readonly rotationPoints: readonly RotationPoint[];
68
+ /** The mirror and glide lines, by direction, then by their point (x on y = 0, or y on x = 0), then mirror before glide. */
66
69
  readonly lines: readonly SymmetryLine[];
67
70
  }
68
71
 
72
+ /** A box [x₀, y₀] – [x₁, y₁] of the plane, lattice basis, boundary included. */
73
+ export type Box = readonly [readonly [number, number], readonly [number, number]];
74
+
69
75
  // ---------------------------------------------------------------------------------------------
70
76
  // Asymmetric unit
71
77
 
@@ -215,9 +221,10 @@ const samePoint = (p: readonly Rational[], q: readonly Rational[]): boolean =>
215
221
  const unitCache = new Map<string, AsymmetricUnit>();
216
222
 
217
223
  /**
218
- * The asymmetric unit of a plane group as ITA prints it, a convex polygon: its vertices and, for each
219
- * edge, the inequality a·x + b·y ≤ c that holds it. Printed inequalities that hold no edge are
220
- * left out. Frozen.
224
+ * The asymmetric unit of a plane group as ITA prints it (#137 F3): the printed inequalities
225
+ * a·x + b·y ≤ c, all of them in printed order (a double inequality and a `min` give one each), and
226
+ * the convex polygon they bound: its vertices and, per edge, the index of the inequality that holds
227
+ * it. Frozen.
221
228
  */
222
229
  export function planeAsymmetricUnit(key: string | number): AsymmetricUnit {
223
230
  const entry = planeGroupEntry(key);
@@ -225,15 +232,16 @@ export function planeAsymmetricUnit(key: string | number): AsymmetricUnit {
225
232
  if (!unit) {
226
233
  const printed = parseAsymmetricUnit(entry.asymmetricUnit);
227
234
  const vertices = polygon(printed);
228
- const inequalities = vertices.map((p, i) => {
235
+ const edges = vertices.map((p, i) => {
229
236
  const q = vertices[(i + 1) % vertices.length];
230
- const edge = printed.find((e) => excess(e, p)[0] === 0 && excess(e, q)[0] === 0);
231
- if (!edge) throw new Error(`No printed inequality of ${entry.symbol} holds an edge`);
232
- return Object.freeze(edge);
237
+ const edge = printed.findIndex((e) => excess(e, p)[0] === 0 && excess(e, q)[0] === 0);
238
+ if (edge < 0) throw new Error(`No printed inequality of ${entry.symbol} holds an edge`);
239
+ return edge;
233
240
  });
234
241
  unit = Object.freeze({
242
+ inequalities: Object.freeze(printed.map((e) => Object.freeze(e))),
235
243
  vertices: Object.freeze(vertices.map((v) => Object.freeze(v))),
236
- inequalities: Object.freeze(inequalities),
244
+ edges: Object.freeze(edges),
237
245
  });
238
246
  unitCache.set(entry.symbol, unit);
239
247
  }
@@ -241,74 +249,103 @@ export function planeAsymmetricUnit(key: string | number): AsymmetricUnit {
241
249
  }
242
250
 
243
251
  // ---------------------------------------------------------------------------------------------
244
- // Symmetry elements in the cell
252
+ // Symmetry elements
245
253
 
246
254
  const inCell = (p: readonly Rational[]): boolean => p.every((v) => v[0] >= 0 && v[0] <= v[1]);
247
255
 
248
256
  /**
249
257
  * The lattice shifts t, |t_i| ≤ 3, added to each coset representative (W, w), w in [0, 1). Enough to
250
- * reach every element that meets the cell: a centre p in [0, 1]² of (W, w + t) has
251
- * t = (I − W)p − w, and the entries of I − W (at most 2 on the diagonal, 1 off it) give
252
- * (I − W)p in [−2, 3]; a line through p in the cell, taken with its glide g along it reduced to
253
- * g = d/2 (in a plane group s is 0 or 1/2, and |d_i| ≤ 2, so |g_i| ≤ 1), has t = (I − W)p + g − w, where for a reflection (I − W)p lies in [−1, 2].
258
+ * reach every element that meets the cell [0, 1]², and so every element modulo the lattice: a centre
259
+ * p in [0, 1]² of (W, w + t) has t = (I − W)p − w, and the entries of I − W (at most 2 on the
260
+ * diagonal, 1 off it) give (I − W)p in [−2, 3]; a line through p in the cell, taken with its glide
261
+ * g along it reduced to g = d/2 (in a plane group s is 0 or 1/2, and |d_i| ≤ 2, so |g_i| ≤ 1), has
262
+ * t = (I − W)p + g − w, where for a reflection (I − W)p lies in [−1, 2].
254
263
  */
255
264
  const SHIFTS: Rational[][] = [];
256
265
  for (let i = -3; i <= 3; i++) for (let j = -3; j <= 3; j++) SHIFTS.push([r(i), r(j)]);
257
266
 
258
- /**
259
- * The segment of the line through p along d in [0, 1]², or undefined if it has no length there.
260
- * Exact: the parameter λ of p + λd is bounded by each coordinate.
261
- */
262
- function clip(
263
- p: readonly Rational[],
264
- d: readonly [number, number],
265
- ): [readonly Rational[], readonly Rational[]] | undefined {
266
- let lo: Rational | undefined;
267
- let hi: Rational | undefined;
268
- for (let k = 0; k < 2; k++) {
269
- if (d[k] === 0) {
270
- if (p[k][0] < 0 || p[k][0] > p[k][1]) return undefined;
271
- continue;
272
- }
273
- // 0 ≤ p_k + λ d_k ≤ 1
274
- const a = rational(-p[k][0], p[k][1] * d[k]);
275
- const b = rational(p[k][1] - p[k][0], p[k][1] * d[k]);
276
- const [l, h] = d[k] > 0 ? [a, b] : [b, a];
277
- if (lo === undefined || toNumber(subtract(l, lo)) > 0) lo = l;
278
- if (hi === undefined || toNumber(subtract(h, hi)) < 0) hi = h;
279
- }
280
- if (lo === undefined || hi === undefined || toNumber(subtract(hi, lo)) <= 0) return undefined;
281
- const at = (lambda: Rational) => [add(p[0], scale(d[0], lambda)), add(p[1], scale(d[1], lambda))];
282
- return [at(lo), at(hi)];
283
- }
284
-
285
267
  /** s mod 1 in [0, 1). */
286
268
  function frac(s: Rational): Rational {
287
269
  const n = Math.floor(s[0] / s[1]);
288
270
  return subtract(s, r(n));
289
271
  }
290
272
 
291
- const elementCache = new Map<string, CellElements>();
273
+ /** A line: {x : (−d_y, d_x)·x = c} with its glide s·d; for a class, c as `classOffset` chooses it. */
274
+ interface LineClass {
275
+ kind: 'mirror' | 'glide';
276
+ direction: [number, number];
277
+ axis: readonly [number, number];
278
+ s: Rational;
279
+ c: Rational;
280
+ /** The step of c between the translates of the line (1, or 1/2 under a centring). */
281
+ step: Rational;
282
+ }
283
+
284
+ /** The point of the line (d, c) on y = 0, or on x = 0 for a line along a. */
285
+ function linePoint(d: readonly [number, number], c: Rational): Rational[] {
286
+ return d[1] !== 0 ? [rational(-c[0], c[1] * d[1]), ZERO] : [ZERO, rational(c[0], c[1] * d[0])];
287
+ }
288
+
289
+ /** The coordinate of that point that is not 0: where the line crosses y = 0 (or x = 0). */
290
+ const lineParameter = (l: LineClass): number => {
291
+ const p = linePoint(l.direction, l.c);
292
+ return toNumber(l.direction[1] !== 0 ? p[0] : p[1]);
293
+ };
292
294
 
293
295
  /**
294
- * The symmetry elements of a plane group in its conventional cell [0, 1]², boundary included: every
295
- * rotation centre with the highest order of a rotation about it, and every mirror and glide line
296
- * that crosses the cell, with the segment inside it. A line that carries a glide is a glide line
297
- * with its shortest glide vector along the line (between 0 and the lattice vector). Frozen.
296
+ * The offset c of a line class, one for all its lattice translates: a lattice translation t changes c
297
+ * by (−d_y, d_x)·t, which for a primitive lattice is any integer and with the centring (1/2, 1/2) also
298
+ * (d_x − d_y)/2; so the class is c modulo `step` (1, or 1/2 where that is odd in a centred group). Of
299
+ * the translates the one is taken whose point on y = 0 (on x = 0 for a line along a) lies nearest to
300
+ * 0 from above.
298
301
  */
299
- export function planeCellElements(key: string | number): CellElements {
302
+ function classOffset(d: readonly [number, number], c: Rational, step: Rational): Rational {
303
+ const modulo = (v: Rational, m: Rational): Rational =>
304
+ subtract(v, scale(Math.floor(toNumber(v) / toNumber(m) + 1e-12), m));
305
+ const reduced = modulo(c, step);
306
+ if (d[1] === 0) return reduced; // the point is (0, c/d_x) with d_x = 1
307
+ // x = −c/d_y; c' = c − m·step moves x by m·step/d_y: take x in [0, step/|d_y|).
308
+ const x = rational(-reduced[0], reduced[1] * d[1]);
309
+ const shifted = modulo(x, rational(step[0], step[1] * Math.abs(d[1])));
310
+ return rational(-shifted[0] * d[1], shifted[1]);
311
+ }
312
+
313
+ /** The centring translations of a plane group besides (0, 0), exact. */
314
+ function centrings(entry: { readonly centring: readonly string[] }): Rational[][] {
315
+ return entry.centring.map((t) => t.split(',').map((v) => parseRational(v.trim())));
316
+ }
317
+
318
+ /** The step of c for a line along d under the lattice with these centrings: 1, or a fraction of it. */
319
+ function lineStep(d: readonly [number, number], taus: readonly Rational[][]): Rational {
320
+ let step = r(1);
321
+ for (const tau of taus) {
322
+ const shift = frac(add(scale(-d[1], tau[0]), scale(d[0], tau[1])));
323
+ if (shift[0] !== 0 && toNumber(shift) < toNumber(step)) step = shift;
324
+ }
325
+ return step;
326
+ }
327
+
328
+ /** Of the points p + τ (mod 1) of one class under the centrings, the lowest (y, then x). */
329
+ function classPoint(p: readonly Rational[], taus: readonly Rational[][]): Rational[] {
330
+ let best = [...p];
331
+ for (const tau of taus) {
332
+ const q = [frac(add(p[0], tau[0])), frac(add(p[1], tau[1]))];
333
+ const dy = toNumber(subtract(q[1], best[1]));
334
+ if (dy < 0 || (dy === 0 && toNumber(subtract(q[0], best[0])) < 0)) best = q;
335
+ }
336
+ return best;
337
+ }
338
+
339
+ const classCache = new Map<string, { rotations: { n: number; point: Rational[] }[]; lines: LineClass[] }>();
340
+
341
+ /** The elements of a plane group modulo the lattice: rotation points in [0, 1)², one translate of each line (`classOffset`). */
342
+ function elementClasses(key: string | number) {
300
343
  const entry = planeGroupEntry(key);
301
- const cached = elementCache.get(entry.symbol);
344
+ const cached = classCache.get(entry.symbol);
302
345
  if (cached) return cached;
303
- const rotations: { order: number; point: Rational[] }[] = [];
304
- const lines: {
305
- kind: 'mirror' | 'glide';
306
- direction: [number, number];
307
- normal: readonly [number, number];
308
- s: Rational;
309
- c: Rational;
310
- segment: [readonly Rational[], readonly Rational[]];
311
- }[] = [];
346
+ const rotations: { n: number; point: Rational[] }[] = [];
347
+ const lines: LineClass[] = [];
348
+ const taus = centrings(entry);
312
349
  for (const op of planeGroupOperations(entry.symbol)) {
313
350
  for (const t of SHIFTS) {
314
351
  const shifted: ExactOperation = {
@@ -317,66 +354,140 @@ export function planeCellElements(key: string | number): CellElements {
317
354
  };
318
355
  const d = describePlaneOperation(shifted);
319
356
  if (d.kind === 'rotation') {
320
- const p = [...(d.location ?? [])];
321
- if (!inCell(p)) continue;
357
+ const loc = d.location ?? [];
358
+ if (!inCell(loc)) continue;
359
+ const p = classPoint(loc.map(frac), taus);
322
360
  const known = rotations.find((x) => samePoint(x.point, p));
323
- if (!known) rotations.push({ order: d.order, point: p });
324
- else known.order = Math.max(known.order, d.order);
325
- } else if (d.kind === 'mirror' || d.kind === 'glide') {
361
+ if (!known) rotations.push({ n: d.n, point: p });
362
+ else known.n = Math.max(known.n, d.n);
363
+ } else if (d.kind === 'reflection' || d.kind === 'glide-reflection') {
326
364
  const dir = d.direction ?? [0, 0];
327
365
  const p = d.location ?? [];
328
366
  // The glide vector is s·dir; s modulo 1, since a lattice translation along the line changes nothing.
329
367
  const g = d.glide ?? [ZERO, ZERO];
330
368
  const s = frac(dir[0] !== 0 ? rational(g[0][0], g[0][1] * dir[0]) : rational(g[1][0], g[1][1] * dir[1]));
331
- // The line is the set of x with (−dir_y, dir_x)·x = c.
332
- const c = add(scale(-dir[1], p[0]), scale(dir[0], p[1]));
333
- if (
334
- lines.some(
335
- (l) =>
336
- l.direction[0] === dir[0] &&
337
- l.direction[1] === dir[1] &&
338
- rationalsEqual(l.c, c) &&
339
- rationalsEqual(l.s, s),
340
- )
341
- ) {
342
- continue;
369
+ // The line is the set of x with (−dir_y, dir_x)·x = c; the lattice shifts c by multiples of step.
370
+ const step = lineStep([dir[0], dir[1]], taus);
371
+ const c = classOffset([dir[0], dir[1]], add(scale(-dir[1], p[0]), scale(dir[0], p[1])), step);
372
+ const known = lines.some(
373
+ (l) =>
374
+ l.direction[0] === dir[0] && l.direction[1] === dir[1] && rationalsEqual(l.c, c) && rationalsEqual(l.s, s),
375
+ );
376
+ if (!known) {
377
+ lines.push({
378
+ kind: s[0] === 0 ? 'mirror' : 'glide',
379
+ direction: [dir[0], dir[1]],
380
+ axis: d.axis ?? [0, 0],
381
+ s,
382
+ c,
383
+ step,
384
+ });
343
385
  }
344
- const segment = clip(p, dir);
345
- if (!segment) continue;
346
- lines.push({
347
- kind: s[0] === 0 ? 'mirror' : 'glide',
348
- direction: [dir[0], dir[1]],
349
- normal: d.normal ?? [0, 0],
350
- s,
351
- c,
352
- segment,
353
- });
354
386
  }
355
387
  }
356
388
  }
357
- const num = (v: Rational) => toNumber(v);
358
- rotations.sort((a, b) => b.order - a.order || num(a.point[1]) - num(b.point[1]) || num(a.point[0]) - num(b.point[0]));
389
+ const result = { rotations, lines };
390
+ classCache.set(entry.symbol, result);
391
+ return result;
392
+ }
393
+
394
+ const num = (v: Rational) => toNumber(v);
395
+
396
+ /** The elements as frozen records, sorted. */
397
+ function freezeElements(rotations: { n: number; point: Rational[] }[], lines: LineClass[]): CellElements {
398
+ rotations.sort((a, b) => b.n - a.n || num(a.point[1]) - num(b.point[1]) || num(a.point[0]) - num(b.point[0]));
359
399
  lines.sort(
360
400
  (a, b) =>
361
401
  a.direction[0] - b.direction[0] ||
362
402
  a.direction[1] - b.direction[1] ||
363
- num(a.segment[0][1]) - num(b.segment[0][1]) ||
364
- num(a.segment[0][0]) - num(b.segment[0][0]),
403
+ lineParameter(a) - lineParameter(b) ||
404
+ num(a.s) - num(b.s),
365
405
  );
366
- const result: CellElements = Object.freeze({
367
- rotations: Object.freeze(rotations.map((x) => Object.freeze({ order: x.order, point: Object.freeze(x.point) }))),
406
+ return Object.freeze({
407
+ rotationPoints: Object.freeze(rotations.map((x) => Object.freeze({ n: x.n, point: Object.freeze(x.point) }))),
368
408
  lines: Object.freeze(
369
409
  lines.map((l) =>
370
410
  Object.freeze({
371
411
  kind: l.kind,
372
- direction: Object.freeze(l.direction) as readonly [number, number],
373
- normal: Object.freeze([...l.normal]) as readonly [number, number],
412
+ direction: Object.freeze([...l.direction]) as readonly [number, number],
413
+ axis: Object.freeze([...l.axis]) as readonly [number, number],
374
414
  glide: Object.freeze([scale(l.direction[0], l.s), scale(l.direction[1], l.s)]),
375
- segment: Object.freeze(l.segment.map((p) => Object.freeze([...p]))) as unknown as SymmetryLine['segment'],
415
+ point: Object.freeze(linePoint(l.direction, l.c)),
376
416
  }),
377
417
  ),
378
418
  ),
379
419
  });
380
- elementCache.set(entry.symbol, result);
420
+ }
421
+
422
+ const elementCache = new Map<string, CellElements>();
423
+
424
+ /** The most rotation points a box may hold: a guard against a box far larger than any drawing. */
425
+ const MAX_ELEMENTS = 1_000_000;
426
+
427
+ /**
428
+ * The symmetry elements of a plane group, each once modulo the lattice translations (the centring
429
+ * included), as ITA
430
+ * describes them (#137 F2): every rotation point in [0, 1)² with the highest n of a rotation about
431
+ * it, and every mirror and glide line, as a point and a direction. A line that carries a glide is a
432
+ * glide line with its shortest glide vector along the line (between 0 and the lattice vector). Frozen.
433
+ */
434
+ export function planeElements(key: string | number): CellElements {
435
+ const entry = planeGroupEntry(key);
436
+ let result = elementCache.get(entry.symbol);
437
+ if (!result) {
438
+ const { rotations, lines } = elementClasses(entry.symbol);
439
+ result = freezeElements(
440
+ rotations.map((x) => ({ n: x.n, point: [...x.point] })),
441
+ lines.map((l) => ({ ...l })),
442
+ );
443
+ elementCache.set(entry.symbol, result);
444
+ }
381
445
  return result;
382
446
  }
447
+
448
+ /**
449
+ * The symmetry elements of a plane group with all their lattice translates that meet a box
450
+ * (boundary included): the rotation points inside it, and the lines that cross or touch it, as a
451
+ * point and a direction (not clipped). Frozen.
452
+ */
453
+ export function planeElementsInBox(key: string | number, box: Box): CellElements {
454
+ const [[x0, y0], [x1, y1]] = box;
455
+ const entry = planeGroupEntry(key);
456
+ const { rotations, lines } = elementClasses(entry.symbol);
457
+ const taus = [[ZERO, ZERO], ...centrings(entry)];
458
+ // A bound on the output (#121 step 10b review): the rotation points of a class in the box.
459
+ const estimate = rotations.length * taus.length * (x1 - x0 + 2) * (y1 - y0 + 2);
460
+ if (!(estimate <= MAX_ELEMENTS)) {
461
+ throw new RangeError(
462
+ `The box ${shown(box)} holds about ${Math.round(estimate)} rotation points, more than ${MAX_ELEMENTS}`,
463
+ );
464
+ }
465
+ const inside: { n: number; point: Rational[] }[] = [];
466
+ for (const { n, point } of rotations) {
467
+ for (const tau of taus) {
468
+ const base = [add(point[0], tau[0]), add(point[1], tau[1])];
469
+ const [px, py] = base.map(num);
470
+ for (let i = Math.ceil(x0 - px - 1e-12); i <= Math.floor(x1 - px + 1e-12); i++) {
471
+ for (let j = Math.ceil(y0 - py - 1e-12); j <= Math.floor(y1 - py + 1e-12); j++) {
472
+ const p = [add(base[0], r(i)), add(base[1], r(j))];
473
+ const [qx, qy] = p.map(num);
474
+ if (qx >= x0 - 1e-12 && qx <= x1 + 1e-12 && qy >= y0 - 1e-12 && qy <= y1 + 1e-12)
475
+ inside.push({ n, point: p });
476
+ }
477
+ }
478
+ }
479
+ }
480
+ const crossing: LineClass[] = [];
481
+ for (const l of lines) {
482
+ // (−d_y, d_x)·x over the corners of the box: the translate c + k·step meets it if that lies within.
483
+ const values = [x0, x1].flatMap((x) => [y0, y1].map((y) => -l.direction[1] * x + l.direction[0] * y));
484
+ const lo = Math.min(...values);
485
+ const hi = Math.max(...values);
486
+ const c = num(l.c);
487
+ const step = num(l.step);
488
+ for (let k = Math.ceil((lo - c) / step - 1e-12); k <= Math.floor((hi - c) / step + 1e-12); k++) {
489
+ crossing.push({ ...l, c: add(l.c, scale(k, l.step)) });
490
+ }
491
+ }
492
+ return freezeElements(inside, crossing);
493
+ }
@@ -1,25 +1,26 @@
1
1
  /**
2
2
  * The geometric description of an operation of a plane group, as ITA gives it under "Symmetry
3
- * operations" (ITA 2016, § 2.1.3.9, pp. 160–161): what it is, its order and sense, where its
3
+ * operations" (ITA 2016, § 2.1.3.9, pp. 160–161): what it is, its n and sense, where its
4
4
  * symmetry element lies and its glide part. Structured data; the symbols such as `g(1/2,1/2) x,x`
5
5
  * stay with the applications (CLAUDE.md, "Symmetry elements as structured data").
6
6
  */
7
7
 
8
+ import { shown } from '../checks.js';
8
9
  import { determinant, dimensionOf, trace, type ExactOperation, type IntMatrix } from './affine.js';
9
10
  import { ZERO, add, multiply, rational, scale, type Rational } from './rational.js';
10
11
 
11
12
  /**
12
- * What an operation of a plane group is: `'mirror'` (a reflection in a line, as `'mirror'` of the
13
- * point groups) and `'glide'` (a glide reflection).
13
+ * What an operation of a plane group is, as ITA names the operations (ITA 2016 Table 2.1.2.1, p. 145): `'reflection'`
14
+ * (in a line, as `'reflection'` of the point groups) and `'glide-reflection'`.
14
15
  */
15
- export type PlaneOperationKind = 'identity' | 'translation' | 'rotation' | 'mirror' | 'glide';
16
+ export type PlaneOperationKind = 'identity' | 'translation' | 'rotation' | 'reflection' | 'glide-reflection';
16
17
 
17
18
  /** One operation of a plane group described geometrically, in the lattice basis. */
18
19
  export interface PlaneOperationDescription {
19
20
  /** What the operation is. */
20
21
  readonly kind: PlaneOperationKind;
21
- /** The order n of its linear part: 1 for identity and translation, 2 for a mirror or glide. */
22
- readonly order: number;
22
+ /** The n of its linear part (an n-fold rotation): 1 for identity and translation, 2 for a reflection or glide reflection. */
23
+ readonly n: number;
23
24
  /** For a rotation with n ≥ 3: `'+'` if it turns a towards b, `'-'` otherwise. */
24
25
  readonly sense?: '+' | '-';
25
26
  /** For a translation: the translation vector. */
@@ -33,12 +34,14 @@ export interface PlaneOperationDescription {
33
34
  /** For a mirror or glide: the direction of its line, the shortest integer vector, first non-zero component positive. */
34
35
  readonly direction?: readonly [number, number];
35
36
  /**
36
- * For a mirror or glide: the normal of its line in the lattice basis, its symmetry direction in
37
- * the sense of ITA Table 2.1.3.1: the shortest integer vector along the columns of W − I, first
38
- * non-zero component positive. Without a metric it is not the perpendicular of `direction`: in a
37
+ * For a reflection or glide reflection: its axis, the normal of its line in the lattice basis (as
38
+ * the `axis` of a reflection of the point groups is the normal of its plane, #137 C3), its symmetry
39
+ * direction with the sign of its Seitz symbol (ITA 2016 Tables 1.4.2.4, 1.4.2.5, p. 53: `m₁₀`, `m₁₂`,
40
+ * #107, #114): the shortest integer vector along the columns of W − I, first non-zero component
41
+ * positive, which is the Seitz direction for every plane group (tested). Without a metric it is not the perpendicular of `direction`: in a
39
42
  * hexagonal basis the normal of a line along [1,0] is [1,2].
40
43
  */
41
- readonly normal?: readonly [number, number];
44
+ readonly axis?: readonly [number, number];
42
45
  /**
43
46
  * For a glide: the glide vector (w + W·w)/2, not reduced modulo the lattice. An operation whose
44
47
  * glide vector is a non-zero lattice vector is a glide, as it is geometrically, although the
@@ -89,12 +92,12 @@ export function describePlaneOperation(op: ExactOperation): PlaneOperationDescri
89
92
  if (det === 1) {
90
93
  const n = ORDER_BY_TRACE[trace(w)];
91
94
  if (n === undefined || !isIdentity(power(w, n))) {
92
- throw new RangeError(`Not a crystallographic rotation: ${JSON.stringify(w)}`);
95
+ throw new RangeError(`Not a crystallographic rotation: ${shown(w)}`);
93
96
  }
94
97
  if (n === 1) {
95
98
  return t.every((v) => v[0] === 0)
96
- ? { kind: 'identity', order: 1 }
97
- : { kind: 'translation', order: 1, translation: [...t] };
99
+ ? { kind: 'identity', n: 1 }
100
+ : { kind: 'translation', n: 1, translation: [...t] };
98
101
  }
99
102
  // The centre p solves (I − W) p = w; det(I − W) = 2 − trace W ≠ 0 for a rotation.
100
103
  const a = [
@@ -107,12 +110,12 @@ export function describePlaneOperation(op: ExactOperation): PlaneOperationDescri
107
110
  multiply(add(scale(a[1][1], t[0]), scale(-a[0][1], t[1])), inv),
108
111
  multiply(add(scale(-a[1][0], t[0]), scale(a[0][0], t[1])), inv),
109
112
  ];
110
- const description: PlaneOperationDescription = { kind: 'rotation', order: n, location: Object.freeze(location) };
113
+ const description: PlaneOperationDescription = { kind: 'rotation', n, location: Object.freeze(location) };
111
114
  // The sense: the sign of a × W·a with a = (1, 0), the same in any right-handed basis.
112
115
  return Object.freeze(n === 2 ? description : { ...description, sense: w[1][0] > 0 ? '+' : '-' });
113
116
  }
114
117
  if (det !== -1 || trace(w) !== 0 || !isIdentity(power(w, 2))) {
115
- throw new RangeError(`Not a crystallographic reflection: ${JSON.stringify(w)}`);
118
+ throw new RangeError(`Not a crystallographic reflection: ${shown(w)}`);
116
119
  }
117
120
  // A mirror or glide: W² = I. Glide vector g = (w + W·w)/2, along the line; the line is the set of p with (I − W) p = w − g.
118
121
  const wt = [add(scale(w[0][0], t[0]), scale(w[0][1], t[1])), add(scale(w[1][0], t[0]), scale(w[1][1], t[1]))];
@@ -136,14 +139,14 @@ export function describePlaneOperation(op: ExactOperation): PlaneOperationDescri
136
139
  const location: Rational[] =
137
140
  a[i][0] !== 0 ? [multiply(s[i], rational(1, a[i][0])), ZERO] : [ZERO, multiply(s[i], rational(1, a[i][1]))];
138
141
  const line = {
139
- order: 2,
142
+ n: 2,
140
143
  location: Object.freeze(location),
141
144
  direction: Object.freeze(direction),
142
- normal: Object.freeze(normal),
145
+ axis: Object.freeze(normal),
143
146
  };
144
147
  return Object.freeze(
145
148
  glide.some((v) => v[0] !== 0)
146
- ? { kind: 'glide' as const, ...line, glide: Object.freeze(glide) }
147
- : { kind: 'mirror' as const, ...line },
149
+ ? { kind: 'glide-reflection' as const, ...line, glide: Object.freeze(glide) }
150
+ : { kind: 'reflection' as const, ...line },
148
151
  );
149
152
  }
@@ -27,7 +27,7 @@ export interface PlaneGroupEntry {
27
27
  readonly system: PlaneSystem;
28
28
  /** Printed page. */
29
29
  readonly page: number;
30
- /** The block "Origin" as printed, e.g. `at 21g`. */
30
+ /** The block "Origin" as printed, its positions spaced, e.g. `at 2 1 g`. */
31
31
  readonly origin: string;
32
32
  /** The block "Asymmetric unit" as printed. */
33
33
  readonly asymmetricUnit: string;
@@ -135,7 +135,7 @@ export const PLANE_GROUP_DATA: readonly PlaneGroupEntry[] = [
135
135
  pointGroup: '2mm',
136
136
  system: 'rectangular',
137
137
  page: 181,
138
- origin: 'at 2mm',
138
+ origin: 'at 2 m m',
139
139
  asymmetricUnit: '0 <= x <= 1/2; 0 <= y <= 1/2',
140
140
  centring: [],
141
141
  generalPosition: ['x,y', '-x,-y', '-x,y', 'x,-y'],
@@ -159,7 +159,7 @@ export const PLANE_GROUP_DATA: readonly PlaneGroupEntry[] = [
159
159
  pointGroup: '2mm',
160
160
  system: 'rectangular',
161
161
  page: 182,
162
- origin: 'at 21g',
162
+ origin: 'at 2 1 g',
163
163
  asymmetricUnit: '0 <= x <= 1/4; 0 <= y <= 1',
164
164
  centring: [],
165
165
  generalPosition: ['x,y', '-x,-y', '-x+1/2,y', 'x+1/2,-y'],
@@ -196,7 +196,7 @@ export const PLANE_GROUP_DATA: readonly PlaneGroupEntry[] = [
196
196
  pointGroup: '2mm',
197
197
  system: 'rectangular',
198
198
  page: 184,
199
- origin: 'at 2mm',
199
+ origin: 'at 2 m m',
200
200
  asymmetricUnit: '0 <= x <= 1/4; 0 <= y <= 1/2',
201
201
  centring: ['1/2,1/2'],
202
202
  generalPosition: ['x,y', '-x,-y', '-x,y', 'x,-y'],
@@ -236,7 +236,7 @@ export const PLANE_GROUP_DATA: readonly PlaneGroupEntry[] = [
236
236
  pointGroup: '4mm',
237
237
  system: 'square',
238
238
  page: 186,
239
- origin: 'at 4mm',
239
+ origin: 'at 4 m m',
240
240
  asymmetricUnit: '0 <= x <= 1/2; 0 <= y <= 1/2; x <= y',
241
241
  centring: [],
242
242
  generalPosition: ['x,y', '-x,-y', '-y,x', 'y,-x', '-x,y', 'x,-y', 'y,x', '-y,-x'],
@@ -258,7 +258,7 @@ export const PLANE_GROUP_DATA: readonly PlaneGroupEntry[] = [
258
258
  pointGroup: '4mm',
259
259
  system: 'square',
260
260
  page: 187,
261
- origin: 'at 41g',
261
+ origin: 'at 4 1 g',
262
262
  asymmetricUnit: '0 <= x <= 1/2; 0 <= y <= 1/2; y <= 1/2 - x',
263
263
  centring: [],
264
264
  generalPosition: ['x,y', '-x,-y', '-y,x', 'y,-x', '-x+1/2,y+1/2', 'x+1/2,-y+1/2', 'y+1/2,x+1/2', '-y+1/2,-x+1/2'],
@@ -297,7 +297,7 @@ export const PLANE_GROUP_DATA: readonly PlaneGroupEntry[] = [
297
297
  pointGroup: '3m',
298
298
  system: 'hexagonal',
299
299
  page: 189,
300
- origin: 'at 3m1',
300
+ origin: 'at 3 m 1',
301
301
  asymmetricUnit: '0 <= x <= 2/3; 0 <= y <= 2/3; x <= 2y; y <= min(1 - x, 2x)',
302
302
  vertices: ['0,0', '2/3,1/3', '1/3,2/3'],
303
303
  centring: [],
@@ -318,7 +318,7 @@ export const PLANE_GROUP_DATA: readonly PlaneGroupEntry[] = [
318
318
  pointGroup: '3m',
319
319
  system: 'hexagonal',
320
320
  page: 190,
321
- origin: 'at 31m',
321
+ origin: 'at 3 1 m',
322
322
  asymmetricUnit: '0 <= x <= 2/3; 0 <= y <= 1/2; x <= (1 + y)/2; y <= min(1 - x, x)',
323
323
  vertices: ['0,0', '1/2,0', '2/3,1/3', '1/2,1/2'],
324
324
  centring: [],
@@ -358,7 +358,7 @@ export const PLANE_GROUP_DATA: readonly PlaneGroupEntry[] = [
358
358
  pointGroup: '6mm',
359
359
  system: 'hexagonal',
360
360
  page: 192,
361
- origin: 'at 6mm',
361
+ origin: 'at 6 m m',
362
362
  asymmetricUnit: '0 <= x <= 2/3; 0 <= y <= 1/3; x <= (1 + y)/2; y <= x/2',
363
363
  vertices: ['0,0', '1/2,0', '2/3,1/3'],
364
364
  centring: [],
@@ -4,6 +4,7 @@
4
4
  * Internal for now; the entry point `symcrys/plane` comes later.
5
5
  */
6
6
 
7
+ import { shown } from '../checks.js';
7
8
  import {
8
9
  closure,
9
10
  compose,
@@ -23,7 +24,7 @@ export const PLANE_GROUP_KEYS = PLANE_GROUP_DATA.map((g) => g.symbol);
23
24
  export function planeGroupEntry(key: string | number): PlaneGroupEntry {
24
25
  const entry = PLANE_GROUP_DATA.find((g) => g.symbol === key || g.number === key);
25
26
  if (!entry) {
26
- throw new RangeError(`Unknown plane group: ${JSON.stringify(key)}`);
27
+ throw new RangeError(`Unknown plane group: ${shown(key)}`);
27
28
  }
28
29
  return entry;
29
30
  }