symcrys 0.1.1 → 0.3.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 (75) hide show
  1. package/README.md +28 -5
  2. package/dist/index.d.ts +9 -0
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +7 -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/pointGroups/wyckoff.d.ts +53 -0
  39. package/dist/pointGroups/wyckoff.d.ts.map +1 -0
  40. package/dist/pointGroups/wyckoff.js +189 -0
  41. package/dist/pointGroups/wyckoff.js.map +1 -0
  42. package/dist/pointGroups/wyckoffData.d.ts +24 -0
  43. package/dist/pointGroups/wyckoffData.d.ts.map +1 -0
  44. package/dist/pointGroups/wyckoffData.js +423 -0
  45. package/dist/pointGroups/wyckoffData.js.map +1 -0
  46. package/dist/siteSymmetry.d.ts +40 -0
  47. package/dist/siteSymmetry.d.ts.map +1 -0
  48. package/dist/siteSymmetry.js +57 -0
  49. package/dist/siteSymmetry.js.map +1 -0
  50. package/dist/symmetryDirections.d.ts +18 -0
  51. package/dist/symmetryDirections.d.ts.map +1 -0
  52. package/dist/symmetryDirections.js +65 -0
  53. package/dist/symmetryDirections.js.map +1 -0
  54. package/dist/tolerances.d.ts +11 -0
  55. package/dist/tolerances.d.ts.map +1 -0
  56. package/dist/tolerances.js +11 -0
  57. package/dist/tolerances.js.map +1 -0
  58. package/dist/version.d.ts +1 -1
  59. package/dist/version.js +1 -1
  60. package/package.json +6 -4
  61. package/src/index.ts +49 -0
  62. package/src/lattice.ts +59 -0
  63. package/src/linalg.ts +138 -0
  64. package/src/operations.ts +63 -0
  65. package/src/pointGroups/data.ts +294 -0
  66. package/src/pointGroups/elements.ts +264 -0
  67. package/src/pointGroups/itaOrder.ts +688 -0
  68. package/src/pointGroups/pointGroups.ts +304 -0
  69. package/src/pointGroups/properties.ts +62 -0
  70. package/src/pointGroups/wyckoff.ts +233 -0
  71. package/src/pointGroups/wyckoffData.ts +437 -0
  72. package/src/siteSymmetry.ts +89 -0
  73. package/src/symmetryDirections.ts +72 -0
  74. package/src/tolerances.ts +12 -0
  75. package/src/version.ts +1 -1
@@ -0,0 +1,437 @@
1
+ /**
2
+ * The Wyckoff positions of the crystal classes as ITA prints them (6th ed., 2016, Table 3.2.3.2,
3
+ * pp. 745–769), one entry per printed setting: letter, multiplicity, oriented site-symmetry symbol,
4
+ * the first coordinate triplet and the Miller indices of the first face. The same rows are in
5
+ * references/itc/vol-a-table-3.2.3.2-wyckoff-positions.md, which the reference test re-parses and
6
+ * compares with this file; change both only by transcription from print.
7
+ *
8
+ * Notation: a leading `-` is an overbar; components separated by commas; Bravais–Miller indices
9
+ * (four components) for hexagonal axes. The origin (letter o) has no face (`''`).
10
+ */
11
+
12
+ /** [letter, multiplicity, oriented site symmetry, coordinates, Miller indices]. */
13
+ export type WyckoffRow = readonly [string, number, string, string, string];
14
+
15
+ export interface WyckoffEntry {
16
+ /** ITC short symbol of the setting as in the headline of the entry. */
17
+ readonly symbol: string;
18
+ /** Monoclinic: the unique axis of the entry. */
19
+ readonly uniqueAxis?: 'b' | 'c';
20
+ /** Printed page. */
21
+ readonly page: number;
22
+ /** In printed order, general position first. */
23
+ readonly rows: readonly WyckoffRow[];
24
+ }
25
+
26
+ export const ITA_WYCKOFF: readonly WyckoffEntry[] = [
27
+ {
28
+ symbol: '1',
29
+ page: 745,
30
+ rows: [['a', 1, '1', 'x,y,z', 'h,k,l']],
31
+ },
32
+ {
33
+ symbol: '-1',
34
+ page: 745,
35
+ rows: [
36
+ ['a', 2, '1', 'x,y,z', 'h,k,l'],
37
+ ['o', 1, '-1', '0,0,0', ''],
38
+ ],
39
+ },
40
+ {
41
+ symbol: '2',
42
+ uniqueAxis: 'b',
43
+ page: 745,
44
+ rows: [
45
+ ['b', 2, '1', 'x,y,z', 'h,k,l'],
46
+ ['a', 1, '2', '0,y,0', '0,1,0'],
47
+ ],
48
+ },
49
+ {
50
+ symbol: '2',
51
+ uniqueAxis: 'c',
52
+ page: 745,
53
+ rows: [
54
+ ['b', 2, '1', 'x,y,z', 'h,k,l'],
55
+ ['a', 1, '2', '0,0,z', '0,0,1'],
56
+ ],
57
+ },
58
+ {
59
+ symbol: 'm',
60
+ uniqueAxis: 'b',
61
+ page: 746,
62
+ rows: [
63
+ ['b', 2, '1', 'x,y,z', 'h,k,l'],
64
+ ['a', 1, 'm', 'x,0,z', 'h,0,l'],
65
+ ],
66
+ },
67
+ {
68
+ symbol: 'm',
69
+ uniqueAxis: 'c',
70
+ page: 746,
71
+ rows: [
72
+ ['b', 2, '1', 'x,y,z', 'h,k,l'],
73
+ ['a', 1, 'm', 'x,y,0', 'h,k,0'],
74
+ ],
75
+ },
76
+ {
77
+ symbol: '2/m',
78
+ uniqueAxis: 'b',
79
+ page: 746,
80
+ rows: [
81
+ ['c', 4, '1', 'x,y,z', 'h,k,l'],
82
+ ['b', 2, 'm', 'x,0,z', 'h,0,l'],
83
+ ['a', 2, '2', '0,y,0', '0,1,0'],
84
+ ['o', 1, '2/m', '0,0,0', ''],
85
+ ],
86
+ },
87
+ {
88
+ symbol: '2/m',
89
+ uniqueAxis: 'c',
90
+ page: 747,
91
+ rows: [
92
+ ['c', 4, '1', 'x,y,z', 'h,k,l'],
93
+ ['b', 2, 'm', 'x,y,0', 'h,k,0'],
94
+ ['a', 2, '2', '0,0,z', '0,0,1'],
95
+ ['o', 1, '2/m', '0,0,0', ''],
96
+ ],
97
+ },
98
+ {
99
+ symbol: '222',
100
+ page: 747,
101
+ rows: [
102
+ ['d', 4, '1', 'x,y,z', 'h,k,l'],
103
+ ['c', 2, '..2', '0,0,z', '0,0,1'],
104
+ ['b', 2, '.2.', '0,y,0', '0,1,0'],
105
+ ['a', 2, '2..', 'x,0,0', '1,0,0'],
106
+ ['o', 1, '222', '0,0,0', ''],
107
+ ],
108
+ },
109
+ {
110
+ symbol: 'mm2',
111
+ page: 748,
112
+ rows: [
113
+ ['d', 4, '1', 'x,y,z', 'h,k,l'],
114
+ ['c', 2, 'm..', '0,y,z', '0,k,l'],
115
+ ['b', 2, '.m.', 'x,0,z', 'h,0,l'],
116
+ ['a', 1, 'mm2', '0,0,z', '0,0,1'],
117
+ ],
118
+ },
119
+ {
120
+ symbol: 'mmm',
121
+ page: 748,
122
+ rows: [
123
+ ['g', 8, '1', 'x,y,z', 'h,k,l'],
124
+ ['f', 4, '..m', 'x,y,0', 'h,k,0'],
125
+ ['e', 4, '.m.', 'x,0,z', 'h,0,l'],
126
+ ['d', 4, 'm..', '0,y,z', '0,k,l'],
127
+ ['c', 2, 'mm2', '0,0,z', '0,0,1'],
128
+ ['b', 2, 'm2m', '0,y,0', '0,1,0'],
129
+ ['a', 2, '2mm', 'x,0,0', '1,0,0'],
130
+ ['o', 1, 'mmm', '0,0,0', ''],
131
+ ],
132
+ },
133
+ {
134
+ symbol: '4',
135
+ page: 749,
136
+ rows: [
137
+ ['b', 4, '1', 'x,y,z', 'h,k,l'],
138
+ ['a', 1, '4..', '0,0,z', '0,0,1'],
139
+ ],
140
+ },
141
+ {
142
+ symbol: '-4',
143
+ page: 749,
144
+ rows: [
145
+ ['b', 4, '1', 'x,y,z', 'h,k,l'],
146
+ ['a', 2, '2..', '0,0,z', '0,0,1'],
147
+ ['o', 1, '-4..', '0,0,0', ''],
148
+ ],
149
+ },
150
+ {
151
+ symbol: '4/m',
152
+ page: 749,
153
+ rows: [
154
+ ['c', 8, '1', 'x,y,z', 'h,k,l'],
155
+ ['b', 4, 'm..', 'x,y,0', 'h,k,0'],
156
+ ['a', 2, '4..', '0,0,z', '0,0,1'],
157
+ ['o', 1, '4/m..', '0,0,0', ''],
158
+ ],
159
+ },
160
+ {
161
+ symbol: '422',
162
+ page: 750,
163
+ rows: [
164
+ ['d', 8, '1', 'x,y,z', 'h,k,l'],
165
+ ['c', 4, '.2.', 'x,0,0', '1,0,0'],
166
+ ['b', 4, '..2', 'x,x,0', '1,1,0'],
167
+ ['a', 2, '4..', '0,0,z', '0,0,1'],
168
+ ['o', 1, '422', '0,0,0', ''],
169
+ ],
170
+ },
171
+ {
172
+ symbol: '4mm',
173
+ page: 750,
174
+ rows: [
175
+ ['d', 8, '1', 'x,y,z', 'h,k,l'],
176
+ ['c', 4, '.m.', 'x,0,z', 'h,0,l'],
177
+ ['b', 4, '..m', 'x,x,z', 'h,h,l'],
178
+ ['a', 1, '4mm', '0,0,z', '0,0,1'],
179
+ ],
180
+ },
181
+ {
182
+ symbol: '-42m',
183
+ page: 751,
184
+ rows: [
185
+ ['d', 8, '1', 'x,y,z', 'h,k,l'],
186
+ ['c', 4, '..m', 'x,x,z', 'h,h,l'],
187
+ ['b', 4, '.2.', 'x,0,0', '1,0,0'],
188
+ ['a', 2, '2.mm', '0,0,z', '0,0,1'],
189
+ ['o', 1, '-42m', '0,0,0', ''],
190
+ ],
191
+ },
192
+ {
193
+ symbol: '-4m2',
194
+ page: 751,
195
+ rows: [
196
+ ['d', 8, '1', 'x,y,z', 'h,k,l'],
197
+ ['c', 4, '.m.', 'x,0,z', 'h,0,l'],
198
+ ['b', 4, '..2', 'x,x,0', '1,1,0'],
199
+ ['a', 2, '2mm.', '0,0,z', '0,0,1'],
200
+ ['o', 1, '-4m2', '0,0,0', ''],
201
+ ],
202
+ },
203
+ {
204
+ symbol: '4/mmm',
205
+ page: 752,
206
+ rows: [
207
+ ['g', 16, '1', 'x,y,z', 'h,k,l'],
208
+ ['f', 8, '.m.', 'x,0,z', 'h,0,l'],
209
+ ['e', 8, '..m', 'x,x,z', 'h,h,l'],
210
+ ['d', 8, 'm..', 'x,y,0', 'h,k,0'],
211
+ ['c', 4, 'm2m.', 'x,0,0', '1,0,0'],
212
+ ['b', 4, 'm.m2', 'x,x,0', '1,1,0'],
213
+ ['a', 2, '4mm', '0,0,z', '0,0,1'],
214
+ ['o', 1, '4/mmm', '0,0,0', ''],
215
+ ],
216
+ },
217
+ {
218
+ symbol: '3',
219
+ page: 752,
220
+ rows: [
221
+ ['b', 3, '1', 'x,y,z', 'h,k,i,l'],
222
+ ['a', 1, '3..', '0,0,z', '0,0,0,1'],
223
+ ],
224
+ },
225
+ {
226
+ symbol: '-3',
227
+ page: 753,
228
+ rows: [
229
+ ['b', 6, '1', 'x,y,z', 'h,k,i,l'],
230
+ ['a', 2, '3..', '0,0,z', '0,0,0,1'],
231
+ ['o', 1, '-3..', '0,0,0', ''],
232
+ ],
233
+ },
234
+ {
235
+ symbol: '312',
236
+ page: 754,
237
+ rows: [
238
+ ['c', 6, '1', 'x,y,z', 'h,k,i,l'],
239
+ ['b', 3, '..2', 'x,-x,0', '1,0,-1,0'],
240
+ ['a', 2, '3..', '0,0,z', '0,0,0,1'],
241
+ ['o', 1, '3.2', '0,0,0', ''],
242
+ ],
243
+ },
244
+ {
245
+ symbol: '321',
246
+ page: 754,
247
+ rows: [
248
+ ['c', 6, '1', 'x,y,z', 'h,k,i,l'],
249
+ ['b', 3, '.2.', 'x,0,0', '1,1,-2,0'],
250
+ ['a', 2, '3..', '0,0,z', '0,0,0,1'],
251
+ ['o', 1, '32.', '0,0,0', ''],
252
+ ],
253
+ },
254
+ {
255
+ symbol: '3m1',
256
+ page: 755,
257
+ rows: [
258
+ ['c', 6, '1', 'x,y,z', 'h,k,i,l'],
259
+ ['b', 3, '.m.', 'x,-x,z', 'h,0,-h,l'],
260
+ ['a', 1, '3m.', '0,0,z', '0,0,0,1'],
261
+ ],
262
+ },
263
+ {
264
+ symbol: '31m',
265
+ page: 756,
266
+ rows: [
267
+ ['c', 6, '1', 'x,y,z', 'h,k,i,l'],
268
+ ['b', 3, '..m', 'x,0,z', 'h,h,-2h,l'],
269
+ ['a', 1, '3.m', '0,0,z', '0,0,0,1'],
270
+ ],
271
+ },
272
+ {
273
+ symbol: '-31m',
274
+ page: 757,
275
+ rows: [
276
+ ['d', 12, '1', 'x,y,z', 'h,k,i,l'],
277
+ ['c', 6, '..m', 'x,0,z', 'h,h,-2h,l'],
278
+ ['b', 6, '..2', 'x,-x,0', '1,0,-1,0'],
279
+ ['a', 2, '3.m', '0,0,z', '0,0,0,1'],
280
+ ['o', 1, '-3.m', '0,0,0', ''],
281
+ ],
282
+ },
283
+ {
284
+ symbol: '-3m1',
285
+ page: 758,
286
+ rows: [
287
+ ['d', 12, '1', 'x,y,z', 'h,k,i,l'],
288
+ ['c', 6, '.m.', 'x,-x,z', 'h,0,-h,l'],
289
+ ['b', 6, '.2.', 'x,0,0', '1,1,-2,0'],
290
+ ['a', 2, '3m.', '0,0,z', '0,0,0,1'],
291
+ ['o', 1, '-3m.', '0,0,0', ''],
292
+ ],
293
+ },
294
+ {
295
+ symbol: '6',
296
+ page: 760,
297
+ rows: [
298
+ ['b', 6, '1', 'x,y,z', 'h,k,i,l'],
299
+ ['a', 1, '6..', '0,0,z', '0,0,0,1'],
300
+ ],
301
+ },
302
+ {
303
+ symbol: '-6',
304
+ page: 760,
305
+ rows: [
306
+ ['c', 6, '1', 'x,y,z', 'h,k,i,l'],
307
+ ['b', 3, 'm..', 'x,y,0', 'h,k,i,0'],
308
+ ['a', 2, '3..', '0,0,z', '0,0,0,1'],
309
+ ['o', 1, '-6..', '0,0,0', ''],
310
+ ],
311
+ },
312
+ {
313
+ symbol: '6/m',
314
+ page: 760,
315
+ rows: [
316
+ ['c', 12, '1', 'x,y,z', 'h,k,i,l'],
317
+ ['b', 6, 'm..', 'x,y,0', 'h,k,i,0'],
318
+ ['a', 2, '6..', '0,0,z', '0,0,0,1'],
319
+ ['o', 1, '6/m..', '0,0,0', ''],
320
+ ],
321
+ },
322
+ {
323
+ symbol: '622',
324
+ page: 761,
325
+ rows: [
326
+ ['d', 12, '1', 'x,y,z', 'h,k,i,l'],
327
+ ['c', 6, '..2', 'x,-x,0', '1,0,-1,0'],
328
+ ['b', 6, '.2.', 'x,0,0', '1,1,-2,0'],
329
+ ['a', 2, '6..', '0,0,z', '0,0,0,1'],
330
+ ['o', 1, '622', '0,0,0', ''],
331
+ ],
332
+ },
333
+ {
334
+ symbol: '6mm',
335
+ page: 762,
336
+ rows: [
337
+ ['d', 12, '1', 'x,y,z', 'h,k,i,l'],
338
+ ['c', 6, '.m.', 'x,-x,z', 'h,0,-h,l'],
339
+ ['b', 6, '..m', 'x,0,z', 'h,h,-2h,l'],
340
+ ['a', 1, '6mm', '0,0,z', '0,0,0,1'],
341
+ ],
342
+ },
343
+ {
344
+ symbol: '-6m2',
345
+ page: 762,
346
+ rows: [
347
+ ['e', 12, '1', 'x,y,z', 'h,k,i,l'],
348
+ ['d', 6, 'm..', 'x,y,0', 'h,k,i,0'],
349
+ ['c', 6, '.m.', 'x,-x,z', 'h,0,-h,l'],
350
+ ['b', 3, 'mm2', 'x,-x,0', '1,0,-1,0'],
351
+ ['a', 2, '3m.', '0,0,z', '0,0,0,1'],
352
+ ['o', 1, '-6m2', '0,0,0', ''],
353
+ ],
354
+ },
355
+ {
356
+ symbol: '-62m',
357
+ page: 763,
358
+ rows: [
359
+ ['e', 12, '1', 'x,y,z', 'h,k,i,l'],
360
+ ['d', 6, 'm..', 'x,y,0', 'h,k,i,0'],
361
+ ['c', 6, '..m', 'x,0,z', 'h,h,-2h,l'],
362
+ ['b', 3, 'm2m', 'x,0,0', '1,1,-2,0'],
363
+ ['a', 2, '3.m', '0,0,z', '0,0,0,1'],
364
+ ['o', 1, '-62m', '0,0,0', ''],
365
+ ],
366
+ },
367
+ {
368
+ symbol: '6/mmm',
369
+ page: 764,
370
+ rows: [
371
+ ['g', 24, '1', 'x,y,z', 'h,k,i,l'],
372
+ ['f', 12, 'm..', 'x,y,0', 'h,k,i,0'],
373
+ ['e', 12, '.m.', 'x,2x,z', 'h,0,-h,l'],
374
+ ['d', 12, '..m', 'x,0,z', 'h,h,-2h,l'],
375
+ ['c', 6, 'mm2', 'x,2x,0', '1,0,-1,0'],
376
+ ['b', 6, 'm2m', 'x,0,0', '1,1,-2,0'],
377
+ ['a', 2, '6mm', '0,0,z', '0,0,0,1'],
378
+ ['o', 1, '6mmm', '0,0,0', ''],
379
+ ],
380
+ },
381
+ {
382
+ symbol: '23',
383
+ page: 765,
384
+ rows: [
385
+ ['c', 12, '1', 'x,y,z', 'h,k,l'],
386
+ ['b', 6, '2..', 'x,0,0', '1,0,0'],
387
+ ['a', 4, '.3.', 'x,x,x', '1,1,1'],
388
+ ['o', 1, '23.', '0,0,0', ''],
389
+ ],
390
+ },
391
+ {
392
+ symbol: 'm-3',
393
+ page: 766,
394
+ rows: [
395
+ ['d', 24, '1', 'x,y,z', 'h,k,l'],
396
+ ['c', 12, 'm..', '0,y,z', '0,k,l'],
397
+ ['b', 8, '.3.', 'x,x,x', '1,1,1'],
398
+ ['a', 6, '2mm..', 'x,0,0', '1,0,0'],
399
+ ['o', 1, 'm-3.', '0,0,0', ''],
400
+ ],
401
+ },
402
+ {
403
+ symbol: '432',
404
+ page: 767,
405
+ rows: [
406
+ ['d', 24, '1', 'x,y,z', 'h,k,l'],
407
+ ['c', 12, '..2', '0,y,y', '0,1,1'],
408
+ ['b', 8, '.3.', 'x,x,x', '1,1,1'],
409
+ ['a', 6, '4..', 'x,0,0', '1,0,0'],
410
+ ['o', 1, '432', '0,0,0', ''],
411
+ ],
412
+ },
413
+ {
414
+ symbol: '-43m',
415
+ page: 768,
416
+ rows: [
417
+ ['d', 24, '1', 'x,y,z', 'h,k,l'],
418
+ ['c', 12, '..m', 'x,x,z', 'h,h,l'],
419
+ ['b', 6, '2.mm', 'x,0,0', '1,0,0'],
420
+ ['a', 4, '.3m', 'x,x,x', '1,1,1'],
421
+ ['o', 1, '-43m', '0,0,0', ''],
422
+ ],
423
+ },
424
+ {
425
+ symbol: 'm-3m',
426
+ page: 769,
427
+ rows: [
428
+ ['f', 48, '1', 'x,y,z', 'h,k,l'],
429
+ ['e', 24, '..m', 'x,x,z', 'h,h,l'],
430
+ ['d', 24, 'm..', '0,y,z', '0,k,l'],
431
+ ['c', 12, 'm.m2', '0,y,y', '0,1,1'],
432
+ ['b', 8, '.3m', 'x,x,x', '1,1,1'],
433
+ ['a', 6, '4m.m', 'x,0,0', '1,0,0'],
434
+ ['o', 1, 'm-3m', '0,0,0', ''],
435
+ ],
436
+ },
437
+ ];
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Site symmetry of a direction under any list of point operations: which operations leave it
3
+ * fixed (docs/conventions.md, "Site symmetry and Wyckoff positions").
4
+ */
5
+
6
+ import { apply, type Vec3 } from './linalg.js';
7
+ import type { Operation } from './operations.js';
8
+ import { EPSILON } from './tolerances.js';
9
+
10
+ export interface SiteSymmetryOptions {
11
+ /**
12
+ * A direction counts as fixed by an operation if the operation moves its unit vector by less
13
+ * than this (Euclidean distance). Default `EPSILON` (10⁻⁶); a caller whose directions carry
14
+ * rounding errors (e.g. read from a rounded link) passes a larger value.
15
+ */
16
+ readonly tolerance?: number;
17
+ }
18
+
19
+ /** The site symmetry of a direction. */
20
+ export interface SiteSymmetry {
21
+ /** Indices into the given operations of those that leave the direction fixed, ascending. */
22
+ readonly operations: readonly number[];
23
+ /**
24
+ * The unit vector of the direction, set onto the fixed space of its site symmetry (the mean of
25
+ * its images under the site symmetry, normalised), which removes rounding errors within the
26
+ * tolerance.
27
+ */
28
+ readonly direction: Vec3;
29
+ /** Number of operations divided by the order of the site symmetry: the number of equivalent directions. */
30
+ readonly multiplicity: number;
31
+ /** True if no operation other than the identity leaves the direction fixed (general position). */
32
+ readonly general: boolean;
33
+ }
34
+
35
+ function unit(v: Vec3): Vec3 {
36
+ const n = Math.hypot(v[0], v[1], v[2]);
37
+ if (!(n > 0) || !Number.isFinite(n)) throw new RangeError(`Not a direction: ${JSON.stringify(v)}`);
38
+ return [v[0] / n, v[1] / n, v[2] / n];
39
+ }
40
+
41
+ function fixes(op: Operation, v: Vec3, tolerance: number): boolean {
42
+ const w = apply(op.matrix, v);
43
+ return Math.hypot(w[0] - v[0], w[1] - v[1], w[2] - v[2]) < tolerance;
44
+ }
45
+
46
+ function isIdentity(op: Operation): boolean {
47
+ return op.matrix.every((row, i) => row.every((v, j) => Math.abs(v - (i === j ? 1 : 0)) < EPSILON));
48
+ }
49
+
50
+ /** The tolerance of the options, checked. */
51
+ export function siteTolerance(options?: SiteSymmetryOptions): number {
52
+ const t = options?.tolerance ?? EPSILON;
53
+ if (!(typeof t === 'number' && t > 0 && t < 1)) throw new RangeError(`Invalid tolerance: ${String(t)}`);
54
+ return t;
55
+ }
56
+
57
+ /**
58
+ * The site symmetry of `direction` (any non-zero vector, Cartesian) under `operations`, which may
59
+ * be any list of point operations (for instance those of a distorted crystal). Time reversal is
60
+ * ignored: a direction or a face normal is not changed by it. `direction` and `multiplicity` are
61
+ * meaningful when the operations form a group (then the fixing ones do too); for another list
62
+ * `multiplicity` may not be an integer. Throws a RangeError for a zero vector.
63
+ */
64
+ export function siteSymmetry(
65
+ operations: readonly Operation[],
66
+ direction: Vec3,
67
+ options?: SiteSymmetryOptions,
68
+ ): SiteSymmetry {
69
+ const tolerance = siteTolerance(options);
70
+ const v = unit(direction);
71
+ const indices: number[] = [];
72
+ operations.forEach((op, i) => {
73
+ if (fixes(op, v, tolerance)) indices.push(i);
74
+ });
75
+ const sum: [number, number, number] = [0, 0, 0];
76
+ for (const i of indices) {
77
+ const w = apply(operations[i].matrix, v);
78
+ sum[0] += w[0];
79
+ sum[1] += w[1];
80
+ sum[2] += w[2];
81
+ }
82
+ const projected = indices.length > 0 ? unit(sum) : v;
83
+ return Object.freeze({
84
+ operations: Object.freeze(indices),
85
+ direction: Object.freeze(projected) as Vec3,
86
+ multiplicity: indices.length > 0 ? operations.length / indices.length : operations.length,
87
+ general: indices.every((i) => isIdentity(operations[i])),
88
+ });
89
+ }
@@ -0,0 +1,72 @@
1
+ /**
2
+ * The symmetry directions of the crystal families: the lattice directions along which the
3
+ * symmetry elements of a crystallographic point group lie, grouped by their position in the full
4
+ * Hermann–Mauguin symbol. Data from ITA Table 2.1.3.1 (docs/conventions.md, "Symmetry
5
+ * directions and elements"); `symmetryDirections.reference.test.ts` re-reads the transcription and requires the
6
+ * same directions, in the same order and with the same signs.
7
+ */
8
+
9
+ import type { CrystalFamily } from './lattice.js';
10
+
11
+ /** A lattice direction [uvw]: integer coordinates in the conventional basis a, b, c. */
12
+ export type Uvw = readonly [number, number, number];
13
+
14
+ const frozen = (rows: [number, number, number][][]): readonly (readonly Uvw[])[] =>
15
+ Object.freeze(rows.map((dirs) => Object.freeze(dirs.map((d) => Object.freeze(d) as unknown as Uvw))));
16
+
17
+ /**
18
+ * The directions of each position of the full symbol, per family, as printed in ITA Table 2.1.3.1
19
+ * (hexagonal family: the row "Hexagonal", which also serves the trigonal classes with hexagonal
20
+ * axes). Monoclinic: the full symbol reads along a, b, c (ITA 6th ed. § 2.1.3.15, p. 171), the
21
+ * orthorhombic row. Triclinic: no symmetry direction.
22
+ */
23
+ export const LATTICE_SYMMETRY_DIRECTIONS: Readonly<Record<CrystalFamily, readonly (readonly Uvw[])[]>> = Object.freeze({
24
+ triclinic: frozen([]),
25
+ monoclinic: frozen([[[1, 0, 0]], [[0, 1, 0]], [[0, 0, 1]]]),
26
+ orthorhombic: frozen([[[1, 0, 0]], [[0, 1, 0]], [[0, 0, 1]]]),
27
+ tetragonal: frozen([
28
+ [[0, 0, 1]],
29
+ [
30
+ [1, 0, 0],
31
+ [0, 1, 0],
32
+ ],
33
+ [
34
+ [1, -1, 0],
35
+ [1, 1, 0],
36
+ ],
37
+ ]),
38
+ hexagonal: frozen([
39
+ [[0, 0, 1]],
40
+ [
41
+ [1, 0, 0],
42
+ [0, 1, 0],
43
+ [-1, -1, 0],
44
+ ],
45
+ [
46
+ [1, -1, 0],
47
+ [1, 2, 0],
48
+ [-2, -1, 0],
49
+ ],
50
+ ]),
51
+ cubic: frozen([
52
+ [
53
+ [1, 0, 0],
54
+ [0, 1, 0],
55
+ [0, 0, 1],
56
+ ],
57
+ [
58
+ [1, 1, 1],
59
+ [1, -1, -1],
60
+ [-1, 1, -1],
61
+ [-1, -1, 1],
62
+ ],
63
+ [
64
+ [1, -1, 0],
65
+ [1, 1, 0],
66
+ [0, 1, -1],
67
+ [0, 1, 1],
68
+ [-1, 0, 1],
69
+ [1, 0, 1],
70
+ ],
71
+ ]),
72
+ });
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Numeric tolerances, in one place. The values differ on purpose: each gates a different quantity.
3
+ */
4
+
5
+ /** Two matrix entries (or vector components) closer than this are equal. */
6
+ export const EPSILON = 1e-6;
7
+
8
+ /**
9
+ * During group closure, an entry closer than this to one of the exact values in `SNAP_VALUES`
10
+ * (linalg.ts) is replaced by it, so rounding errors cannot accumulate over repeated products.
11
+ */
12
+ export const SNAP_EPSILON = 1e-9;
package/src/version.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  /** Version of symcrys. Kept equal to `version` in package.json (checked by version.test.ts). */
2
- export const VERSION = '0.1.1';
2
+ export const VERSION = '0.3.0';