symcrys 0.1.0 → 0.2.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 (60) hide show
  1. package/README.md +35 -12
  2. package/dist/index.d.ts +7 -0
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +5 -0
  5. package/dist/index.js.map +1 -1
  6. package/dist/lattice.d.ts +22 -0
  7. package/dist/lattice.d.ts.map +1 -0
  8. package/dist/lattice.js +43 -0
  9. package/dist/lattice.js.map +1 -0
  10. package/dist/linalg.d.ts +32 -0
  11. package/dist/linalg.d.ts.map +1 -0
  12. package/dist/linalg.js +120 -0
  13. package/dist/linalg.js.map +1 -0
  14. package/dist/operations.d.ts +30 -0
  15. package/dist/operations.d.ts.map +1 -0
  16. package/dist/operations.js +49 -0
  17. package/dist/operations.js.map +1 -0
  18. package/dist/pointGroups/data.d.ts +40 -0
  19. package/dist/pointGroups/data.d.ts.map +1 -0
  20. package/dist/pointGroups/data.js +204 -0
  21. package/dist/pointGroups/data.js.map +1 -0
  22. package/dist/pointGroups/elements.d.ts +75 -0
  23. package/dist/pointGroups/elements.d.ts.map +1 -0
  24. package/dist/pointGroups/elements.js +181 -0
  25. package/dist/pointGroups/elements.js.map +1 -0
  26. package/dist/pointGroups/itaOrder.d.ts +22 -0
  27. package/dist/pointGroups/itaOrder.d.ts.map +1 -0
  28. package/dist/pointGroups/itaOrder.js +675 -0
  29. package/dist/pointGroups/itaOrder.js.map +1 -0
  30. package/dist/pointGroups/pointGroups.d.ts +84 -0
  31. package/dist/pointGroups/pointGroups.d.ts.map +1 -0
  32. package/dist/pointGroups/pointGroups.js +229 -0
  33. package/dist/pointGroups/pointGroups.js.map +1 -0
  34. package/dist/pointGroups/properties.d.ts +18 -0
  35. package/dist/pointGroups/properties.d.ts.map +1 -0
  36. package/dist/pointGroups/properties.js +60 -0
  37. package/dist/pointGroups/properties.js.map +1 -0
  38. package/dist/symmetryDirections.d.ts +18 -0
  39. package/dist/symmetryDirections.d.ts.map +1 -0
  40. package/dist/symmetryDirections.js +65 -0
  41. package/dist/symmetryDirections.js.map +1 -0
  42. package/dist/tolerances.d.ts +11 -0
  43. package/dist/tolerances.d.ts.map +1 -0
  44. package/dist/tolerances.js +11 -0
  45. package/dist/tolerances.js.map +1 -0
  46. package/dist/version.d.ts +1 -1
  47. package/dist/version.js +1 -1
  48. package/package.json +5 -4
  49. package/src/index.ts +41 -0
  50. package/src/lattice.ts +59 -0
  51. package/src/linalg.ts +138 -0
  52. package/src/operations.ts +63 -0
  53. package/src/pointGroups/data.ts +294 -0
  54. package/src/pointGroups/elements.ts +264 -0
  55. package/src/pointGroups/itaOrder.ts +688 -0
  56. package/src/pointGroups/pointGroups.ts +304 -0
  57. package/src/pointGroups/properties.ts +62 -0
  58. package/src/symmetryDirections.ts +72 -0
  59. package/src/tolerances.ts +12 -0
  60. package/src/version.ts +1 -1
@@ -0,0 +1,688 @@
1
+ /**
2
+ * The order of the operations: as ITA numbers them. ITA bases the sequence of the coordinate
3
+ * triplets on its "Generators selected" (Vol. A, 5th ed. 2006, § 2.2.11 (iv), p. 27; transcribed
4
+ * for the symmorphic P group of every setting it lists in references/itc/vol-a-2006-symmetry-operations.md)
5
+ * and takes the next generator as soon as a power of the current one lies in the group generated
6
+ * so far (§ 8.3.5, p. 737). So, starting from the identity, each generator g extends that group H
7
+ * by gH, g²H, … until a power of g lies in H. This gives ITA's numbering of the general
8
+ * position (ITA 6th ed. Table 3.2.3.2), as `elements.reference.test.ts` checks for all 40 settings.
9
+ * The generators are the printed triplets of Table 3.2.3.2, as matrices W in the conventional basis
10
+ * (x̃ = W x); docs/conventions.md, "Order of the operations".
11
+ */
12
+
13
+ import { inverse, multiply, snap, type Mat3 } from '../linalg.js';
14
+ import { crystalFamily, latticeBasis, type CrystalSystem } from '../lattice.js';
15
+ import { IDENTITY_OPERATION, compose, operation, operationsEqual, type Operation } from '../operations.js';
16
+
17
+ /** An integer matrix W in the conventional basis, rows as printed in a coordinate triplet. */
18
+ type IntMat3 = readonly [
19
+ readonly [number, number, number],
20
+ readonly [number, number, number],
21
+ readonly [number, number, number],
22
+ ];
23
+
24
+ /** ITA's selected generators per setting (`key#setting`), in printed order (identity and translations left out). */
25
+ const ITA_GENERATORS: Readonly<Record<string, readonly IntMat3[]>> = {
26
+ // 1: P1 (No. 1), p. 113
27
+ '1#1': [],
28
+ // -1: P-1 (No. 2), p. 115
29
+ '-1#1': [
30
+ /* (2) -x,-y,-z */ [
31
+ [-1, 0, 0],
32
+ [0, -1, 0],
33
+ [0, 0, -1],
34
+ ],
35
+ ],
36
+ // 2, unique axis b: P121 (No. 3), p. 117
37
+ '2#2': [
38
+ /* (2) -x,y,-z */ [
39
+ [-1, 0, 0],
40
+ [0, 1, 0],
41
+ [0, 0, -1],
42
+ ],
43
+ ],
44
+ // 2, unique axis c: P112 (No. 3), p. 119
45
+ '2#1': [
46
+ /* (2) -x,-y,z */ [
47
+ [-1, 0, 0],
48
+ [0, -1, 0],
49
+ [0, 0, 1],
50
+ ],
51
+ ],
52
+ // m, unique axis b: P1m1 (No. 6), p. 133
53
+ 'm#2': [
54
+ /* (2) x,-y,z */ [
55
+ [1, 0, 0],
56
+ [0, -1, 0],
57
+ [0, 0, 1],
58
+ ],
59
+ ],
60
+ // m, unique axis c: P11m (No. 6), p. 135
61
+ 'm#1': [
62
+ /* (2) x,y,-z */ [
63
+ [1, 0, 0],
64
+ [0, 1, 0],
65
+ [0, 0, -1],
66
+ ],
67
+ ],
68
+ // 2/m, unique axis b: P12/m1 (No. 10), p. 161
69
+ '2/m#2': [
70
+ /* (2) -x,y,-z */ [
71
+ [-1, 0, 0],
72
+ [0, 1, 0],
73
+ [0, 0, -1],
74
+ ],
75
+ /* (3) -x,-y,-z */ [
76
+ [-1, 0, 0],
77
+ [0, -1, 0],
78
+ [0, 0, -1],
79
+ ],
80
+ ],
81
+ // 2/m, unique axis c: P112/m (No. 10), p. 163
82
+ '2/m#1': [
83
+ /* (2) -x,-y,z */ [
84
+ [-1, 0, 0],
85
+ [0, -1, 0],
86
+ [0, 0, 1],
87
+ ],
88
+ /* (3) -x,-y,-z */ [
89
+ [-1, 0, 0],
90
+ [0, -1, 0],
91
+ [0, 0, -1],
92
+ ],
93
+ ],
94
+ // 222: P222 (No. 16), p. 201
95
+ '222#1': [
96
+ /* (2) -x,-y,z */ [
97
+ [-1, 0, 0],
98
+ [0, -1, 0],
99
+ [0, 0, 1],
100
+ ],
101
+ /* (3) -x,y,-z */ [
102
+ [-1, 0, 0],
103
+ [0, 1, 0],
104
+ [0, 0, -1],
105
+ ],
106
+ ],
107
+ // mm2: Pmm2 (No. 25), p. 219
108
+ 'mm2#1': [
109
+ /* (2) -x,-y,z */ [
110
+ [-1, 0, 0],
111
+ [0, -1, 0],
112
+ [0, 0, 1],
113
+ ],
114
+ /* (3) x,-y,z */ [
115
+ [1, 0, 0],
116
+ [0, -1, 0],
117
+ [0, 0, 1],
118
+ ],
119
+ ],
120
+ // mmm: Pmmm (No. 47), p. 263
121
+ 'mmm#1': [
122
+ /* (2) -x,-y,z */ [
123
+ [-1, 0, 0],
124
+ [0, -1, 0],
125
+ [0, 0, 1],
126
+ ],
127
+ /* (3) -x,y,-z */ [
128
+ [-1, 0, 0],
129
+ [0, 1, 0],
130
+ [0, 0, -1],
131
+ ],
132
+ /* (5) -x,-y,-z */ [
133
+ [-1, 0, 0],
134
+ [0, -1, 0],
135
+ [0, 0, -1],
136
+ ],
137
+ ],
138
+ // 4: P4 (No. 75), p. 332
139
+ '4#1': [
140
+ /* (2) -x,-y,z */ [
141
+ [-1, 0, 0],
142
+ [0, -1, 0],
143
+ [0, 0, 1],
144
+ ],
145
+ /* (3) -y,x,z */ [
146
+ [0, -1, 0],
147
+ [1, 0, 0],
148
+ [0, 0, 1],
149
+ ],
150
+ ],
151
+ // -4: P-4 (No. 81), p. 341
152
+ '-4#1': [
153
+ /* (2) -x,-y,z */ [
154
+ [-1, 0, 0],
155
+ [0, -1, 0],
156
+ [0, 0, 1],
157
+ ],
158
+ /* (3) y,-x,-z */ [
159
+ [0, 1, 0],
160
+ [-1, 0, 0],
161
+ [0, 0, -1],
162
+ ],
163
+ ],
164
+ // 4/m: P4/m (No. 83), p. 345
165
+ '4/m#1': [
166
+ /* (2) -x,-y,z */ [
167
+ [-1, 0, 0],
168
+ [0, -1, 0],
169
+ [0, 0, 1],
170
+ ],
171
+ /* (3) -y,x,z */ [
172
+ [0, -1, 0],
173
+ [1, 0, 0],
174
+ [0, 0, 1],
175
+ ],
176
+ /* (5) -x,-y,-z */ [
177
+ [-1, 0, 0],
178
+ [0, -1, 0],
179
+ [0, 0, -1],
180
+ ],
181
+ ],
182
+ // 422: P422 (No. 89), p. 363
183
+ '422#1': [
184
+ /* (2) -x,-y,z */ [
185
+ [-1, 0, 0],
186
+ [0, -1, 0],
187
+ [0, 0, 1],
188
+ ],
189
+ /* (3) -y,x,z */ [
190
+ [0, -1, 0],
191
+ [1, 0, 0],
192
+ [0, 0, 1],
193
+ ],
194
+ /* (5) -x,y,-z */ [
195
+ [-1, 0, 0],
196
+ [0, 1, 0],
197
+ [0, 0, -1],
198
+ ],
199
+ ],
200
+ // 4mm: P4mm (No. 99), p. 383
201
+ '4mm#1': [
202
+ /* (2) -x,-y,z */ [
203
+ [-1, 0, 0],
204
+ [0, -1, 0],
205
+ [0, 0, 1],
206
+ ],
207
+ /* (3) -y,x,z */ [
208
+ [0, -1, 0],
209
+ [1, 0, 0],
210
+ [0, 0, 1],
211
+ ],
212
+ /* (5) x,-y,z */ [
213
+ [1, 0, 0],
214
+ [0, -1, 0],
215
+ [0, 0, 1],
216
+ ],
217
+ ],
218
+ // -42m: P-42m (No. 111), p. 407
219
+ '-42m#1': [
220
+ /* (2) -x,-y,z */ [
221
+ [-1, 0, 0],
222
+ [0, -1, 0],
223
+ [0, 0, 1],
224
+ ],
225
+ /* (3) y,-x,-z */ [
226
+ [0, 1, 0],
227
+ [-1, 0, 0],
228
+ [0, 0, -1],
229
+ ],
230
+ /* (5) -x,y,-z */ [
231
+ [-1, 0, 0],
232
+ [0, 1, 0],
233
+ [0, 0, -1],
234
+ ],
235
+ ],
236
+ // -4m2: P-4m2 (No. 115), p. 415
237
+ '-42m#2': [
238
+ /* (2) -x,-y,z */ [
239
+ [-1, 0, 0],
240
+ [0, -1, 0],
241
+ [0, 0, 1],
242
+ ],
243
+ /* (3) y,-x,-z */ [
244
+ [0, 1, 0],
245
+ [-1, 0, 0],
246
+ [0, 0, -1],
247
+ ],
248
+ /* (5) x,-y,z */ [
249
+ [1, 0, 0],
250
+ [0, -1, 0],
251
+ [0, 0, 1],
252
+ ],
253
+ ],
254
+ // 4/mmm: P4/mmm (No. 123), p. 431
255
+ '4/mmm#1': [
256
+ /* (2) -x,-y,z */ [
257
+ [-1, 0, 0],
258
+ [0, -1, 0],
259
+ [0, 0, 1],
260
+ ],
261
+ /* (3) -y,x,z */ [
262
+ [0, -1, 0],
263
+ [1, 0, 0],
264
+ [0, 0, 1],
265
+ ],
266
+ /* (5) -x,y,-z */ [
267
+ [-1, 0, 0],
268
+ [0, 1, 0],
269
+ [0, 0, -1],
270
+ ],
271
+ /* (9) -x,-y,-z */ [
272
+ [-1, 0, 0],
273
+ [0, -1, 0],
274
+ [0, 0, -1],
275
+ ],
276
+ ],
277
+ // 3: P3 (No. 143), p. 491
278
+ '3#1': [
279
+ /* (2) -y,x-y,z */ [
280
+ [0, -1, 0],
281
+ [1, -1, 0],
282
+ [0, 0, 1],
283
+ ],
284
+ ],
285
+ // -3: P-3 (No. 147), p. 499
286
+ '-3#1': [
287
+ /* (2) -y,x-y,z */ [
288
+ [0, -1, 0],
289
+ [1, -1, 0],
290
+ [0, 0, 1],
291
+ ],
292
+ /* (4) -x,-y,-z */ [
293
+ [-1, 0, 0],
294
+ [0, -1, 0],
295
+ [0, 0, -1],
296
+ ],
297
+ ],
298
+ // 312: P312 (No. 149), p. 505
299
+ '32#1': [
300
+ /* (2) -y,x-y,z */ [
301
+ [0, -1, 0],
302
+ [1, -1, 0],
303
+ [0, 0, 1],
304
+ ],
305
+ /* (4) -y,-x,-z */ [
306
+ [0, -1, 0],
307
+ [-1, 0, 0],
308
+ [0, 0, -1],
309
+ ],
310
+ ],
311
+ // 321: P321 (No. 150), p. 507
312
+ '32#2': [
313
+ /* (2) -y,x-y,z */ [
314
+ [0, -1, 0],
315
+ [1, -1, 0],
316
+ [0, 0, 1],
317
+ ],
318
+ /* (4) y,x,-z */ [
319
+ [0, 1, 0],
320
+ [1, 0, 0],
321
+ [0, 0, -1],
322
+ ],
323
+ ],
324
+ // 3m1: P3m1 (No. 156), p. 521
325
+ '3m#2': [
326
+ /* (2) -y,x-y,z */ [
327
+ [0, -1, 0],
328
+ [1, -1, 0],
329
+ [0, 0, 1],
330
+ ],
331
+ /* (4) -y,-x,z */ [
332
+ [0, -1, 0],
333
+ [-1, 0, 0],
334
+ [0, 0, 1],
335
+ ],
336
+ ],
337
+ // 31m: P31m (No. 157), p. 523
338
+ '3m#1': [
339
+ /* (2) -y,x-y,z */ [
340
+ [0, -1, 0],
341
+ [1, -1, 0],
342
+ [0, 0, 1],
343
+ ],
344
+ /* (4) y,x,z */ [
345
+ [0, 1, 0],
346
+ [1, 0, 0],
347
+ [0, 0, 1],
348
+ ],
349
+ ],
350
+ // -31m: P-31m (No. 162), p. 537
351
+ '-3m#1': [
352
+ /* (2) -y,x-y,z */ [
353
+ [0, -1, 0],
354
+ [1, -1, 0],
355
+ [0, 0, 1],
356
+ ],
357
+ /* (4) -y,-x,-z */ [
358
+ [0, -1, 0],
359
+ [-1, 0, 0],
360
+ [0, 0, -1],
361
+ ],
362
+ /* (7) -x,-y,-z */ [
363
+ [-1, 0, 0],
364
+ [0, -1, 0],
365
+ [0, 0, -1],
366
+ ],
367
+ ],
368
+ // -3m1: P-3m1 (No. 164), p. 541
369
+ '-3m#2': [
370
+ /* (2) -y,x-y,z */ [
371
+ [0, -1, 0],
372
+ [1, -1, 0],
373
+ [0, 0, 1],
374
+ ],
375
+ /* (4) y,x,-z */ [
376
+ [0, 1, 0],
377
+ [1, 0, 0],
378
+ [0, 0, -1],
379
+ ],
380
+ /* (7) -x,-y,-z */ [
381
+ [-1, 0, 0],
382
+ [0, -1, 0],
383
+ [0, 0, -1],
384
+ ],
385
+ ],
386
+ // 6: P6 (No. 168), p. 553
387
+ '6#1': [
388
+ /* (2) -y,x-y,z */ [
389
+ [0, -1, 0],
390
+ [1, -1, 0],
391
+ [0, 0, 1],
392
+ ],
393
+ /* (4) -x,-y,z */ [
394
+ [-1, 0, 0],
395
+ [0, -1, 0],
396
+ [0, 0, 1],
397
+ ],
398
+ ],
399
+ // -6: P-6 (No. 174), p. 561
400
+ '-6#1': [
401
+ /* (2) -y,x-y,z */ [
402
+ [0, -1, 0],
403
+ [1, -1, 0],
404
+ [0, 0, 1],
405
+ ],
406
+ /* (4) x,y,-z */ [
407
+ [1, 0, 0],
408
+ [0, 1, 0],
409
+ [0, 0, -1],
410
+ ],
411
+ ],
412
+ // 6/m: P6/m (No. 175), p. 563
413
+ '6/m#1': [
414
+ /* (2) -y,x-y,z */ [
415
+ [0, -1, 0],
416
+ [1, -1, 0],
417
+ [0, 0, 1],
418
+ ],
419
+ /* (4) -x,-y,z */ [
420
+ [-1, 0, 0],
421
+ [0, -1, 0],
422
+ [0, 0, 1],
423
+ ],
424
+ /* (7) -x,-y,-z */ [
425
+ [-1, 0, 0],
426
+ [0, -1, 0],
427
+ [0, 0, -1],
428
+ ],
429
+ ],
430
+ // 622: P622 (No. 177), p. 567
431
+ '622#1': [
432
+ /* (2) -y,x-y,z */ [
433
+ [0, -1, 0],
434
+ [1, -1, 0],
435
+ [0, 0, 1],
436
+ ],
437
+ /* (4) -x,-y,z */ [
438
+ [-1, 0, 0],
439
+ [0, -1, 0],
440
+ [0, 0, 1],
441
+ ],
442
+ /* (7) y,x,-z */ [
443
+ [0, 1, 0],
444
+ [1, 0, 0],
445
+ [0, 0, -1],
446
+ ],
447
+ ],
448
+ // 6mm: P6mm (No. 183), p. 579
449
+ '6mm#1': [
450
+ /* (2) -y,x-y,z */ [
451
+ [0, -1, 0],
452
+ [1, -1, 0],
453
+ [0, 0, 1],
454
+ ],
455
+ /* (4) -x,-y,z */ [
456
+ [-1, 0, 0],
457
+ [0, -1, 0],
458
+ [0, 0, 1],
459
+ ],
460
+ /* (7) -y,-x,z */ [
461
+ [0, -1, 0],
462
+ [-1, 0, 0],
463
+ [0, 0, 1],
464
+ ],
465
+ ],
466
+ // -6m2: P-6m2 (No. 187), p. 587
467
+ '-6m2#2': [
468
+ /* (2) -y,x-y,z */ [
469
+ [0, -1, 0],
470
+ [1, -1, 0],
471
+ [0, 0, 1],
472
+ ],
473
+ /* (4) x,y,-z */ [
474
+ [1, 0, 0],
475
+ [0, 1, 0],
476
+ [0, 0, -1],
477
+ ],
478
+ /* (7) -y,-x,z */ [
479
+ [0, -1, 0],
480
+ [-1, 0, 0],
481
+ [0, 0, 1],
482
+ ],
483
+ ],
484
+ // -62m: P-62m (No. 189), p. 591
485
+ '-6m2#1': [
486
+ /* (2) -y,x-y,z */ [
487
+ [0, -1, 0],
488
+ [1, -1, 0],
489
+ [0, 0, 1],
490
+ ],
491
+ /* (4) x,y,-z */ [
492
+ [1, 0, 0],
493
+ [0, 1, 0],
494
+ [0, 0, -1],
495
+ ],
496
+ /* (7) y,x,-z */ [
497
+ [0, 1, 0],
498
+ [1, 0, 0],
499
+ [0, 0, -1],
500
+ ],
501
+ ],
502
+ // 6/mmm: P6/mmm (No. 191), p. 595
503
+ '6/mmm#1': [
504
+ /* (2) -y,x-y,z */ [
505
+ [0, -1, 0],
506
+ [1, -1, 0],
507
+ [0, 0, 1],
508
+ ],
509
+ /* (4) -x,-y,z */ [
510
+ [-1, 0, 0],
511
+ [0, -1, 0],
512
+ [0, 0, 1],
513
+ ],
514
+ /* (7) y,x,-z */ [
515
+ [0, 1, 0],
516
+ [1, 0, 0],
517
+ [0, 0, -1],
518
+ ],
519
+ /* (13) -x,-y,-z */ [
520
+ [-1, 0, 0],
521
+ [0, -1, 0],
522
+ [0, 0, -1],
523
+ ],
524
+ ],
525
+ // 23: P23 (No. 195), p. 603
526
+ '23#1': [
527
+ /* (2) -x,-y,z */ [
528
+ [-1, 0, 0],
529
+ [0, -1, 0],
530
+ [0, 0, 1],
531
+ ],
532
+ /* (3) -x,y,-z */ [
533
+ [-1, 0, 0],
534
+ [0, 1, 0],
535
+ [0, 0, -1],
536
+ ],
537
+ /* (5) z,x,y */ [
538
+ [0, 0, 1],
539
+ [1, 0, 0],
540
+ [0, 1, 0],
541
+ ],
542
+ ],
543
+ // m-3: Pm-3 (No. 200), p. 615
544
+ 'm-3#1': [
545
+ /* (2) -x,-y,z */ [
546
+ [-1, 0, 0],
547
+ [0, -1, 0],
548
+ [0, 0, 1],
549
+ ],
550
+ /* (3) -x,y,-z */ [
551
+ [-1, 0, 0],
552
+ [0, 1, 0],
553
+ [0, 0, -1],
554
+ ],
555
+ /* (5) z,x,y */ [
556
+ [0, 0, 1],
557
+ [1, 0, 0],
558
+ [0, 1, 0],
559
+ ],
560
+ /* (13) -x,-y,-z */ [
561
+ [-1, 0, 0],
562
+ [0, -1, 0],
563
+ [0, 0, -1],
564
+ ],
565
+ ],
566
+ // 432: P432 (No. 207), p. 635
567
+ '432#1': [
568
+ /* (2) -x,-y,z */ [
569
+ [-1, 0, 0],
570
+ [0, -1, 0],
571
+ [0, 0, 1],
572
+ ],
573
+ /* (3) -x,y,-z */ [
574
+ [-1, 0, 0],
575
+ [0, 1, 0],
576
+ [0, 0, -1],
577
+ ],
578
+ /* (5) z,x,y */ [
579
+ [0, 0, 1],
580
+ [1, 0, 0],
581
+ [0, 1, 0],
582
+ ],
583
+ /* (13) y,x,-z */ [
584
+ [0, 1, 0],
585
+ [1, 0, 0],
586
+ [0, 0, -1],
587
+ ],
588
+ ],
589
+ // -43m: P-43m (No. 215), p. 657
590
+ '-43m#1': [
591
+ /* (2) -x,-y,z */ [
592
+ [-1, 0, 0],
593
+ [0, -1, 0],
594
+ [0, 0, 1],
595
+ ],
596
+ /* (3) -x,y,-z */ [
597
+ [-1, 0, 0],
598
+ [0, 1, 0],
599
+ [0, 0, -1],
600
+ ],
601
+ /* (5) z,x,y */ [
602
+ [0, 0, 1],
603
+ [1, 0, 0],
604
+ [0, 1, 0],
605
+ ],
606
+ /* (13) y,x,z */ [
607
+ [0, 1, 0],
608
+ [1, 0, 0],
609
+ [0, 0, 1],
610
+ ],
611
+ ],
612
+ // m-3m: Pm-3m (No. 221), p. 673
613
+ 'm-3m#1': [
614
+ /* (2) -x,-y,z */ [
615
+ [-1, 0, 0],
616
+ [0, -1, 0],
617
+ [0, 0, 1],
618
+ ],
619
+ /* (3) -x,y,-z */ [
620
+ [-1, 0, 0],
621
+ [0, 1, 0],
622
+ [0, 0, -1],
623
+ ],
624
+ /* (5) z,x,y */ [
625
+ [0, 0, 1],
626
+ [1, 0, 0],
627
+ [0, 1, 0],
628
+ ],
629
+ /* (13) y,x,-z */ [
630
+ [0, 1, 0],
631
+ [1, 0, 0],
632
+ [0, 0, -1],
633
+ ],
634
+ /* (25) -x,-y,-z */ [
635
+ [-1, 0, 0],
636
+ [0, -1, 0],
637
+ [0, 0, -1],
638
+ ],
639
+ ],
640
+ };
641
+
642
+ /** ITA's selected generators of a setting as matrices in the conventional basis, or undefined if ITA does not list it. */
643
+ function itaGenerators(key: string, setting: number): readonly IntMat3[] | undefined {
644
+ return ITA_GENERATORS[`${key}#${setting}`];
645
+ }
646
+
647
+ /**
648
+ * W in the conventional basis as a Cartesian matrix B·W·B⁻¹. Monoclinic and triclinic: W itself,
649
+ * without a basis (symcrys fixes none for them): their point operations are ±1 on the diagonal,
650
+ * and the unique axis (y or z) is perpendicular to the other two axes, so W is the same in every
651
+ * Cartesian frame with that axis along y or z.
652
+ */
653
+ function cartesian(w: IntMat3, system: CrystalSystem): Mat3 {
654
+ const family = crystalFamily(system);
655
+ if (family === 'monoclinic' || family === 'triclinic') return w as unknown as Mat3;
656
+ const b = latticeBasis(family);
657
+ return multiply(multiply(b, w as unknown as Mat3), inverse(b));
658
+ }
659
+
660
+ /** ITA's selected generators of a setting as Cartesian operations, in printed order, or undefined if ITA does not list it. */
661
+ export function itaGeneratorOperations(key: string, setting: number, system: CrystalSystem): Operation[] | undefined {
662
+ return itaGenerators(key, setting)?.map((w) => operation(snap(cartesian(w, system))));
663
+ }
664
+
665
+ /**
666
+ * The operations of a setting in ITA's order, built coset by coset from ITA's generators, or
667
+ * undefined if ITA does not list the setting. `closed` (the closure of the stored generators) only
668
+ * bounds the loop; the caller checks that the result is the same set.
669
+ */
670
+ export function inItaOrder(
671
+ key: string,
672
+ setting: number,
673
+ system: CrystalSystem,
674
+ closed: readonly Operation[],
675
+ ): Operation[] | undefined {
676
+ const gens = itaGeneratorOperations(key, setting, system);
677
+ if (!gens) return undefined;
678
+ const has = (list: readonly Operation[], op: Operation) => list.some((x) => operationsEqual(x, op));
679
+ const list: Operation[] = [IDENTITY_OPERATION];
680
+ for (const g of gens) {
681
+ const h = list.slice();
682
+ for (let power = g; !has(h, power); power = compose(power, g)) {
683
+ if (list.length > closed.length) break;
684
+ for (const x of h) list.push(compose(power, x));
685
+ }
686
+ }
687
+ return list;
688
+ }