symcrys 0.9.0 → 0.10.1

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 (56) hide show
  1. package/dist/crystalClasses.d.ts +1 -1
  2. package/dist/crystalClasses.d.ts.map +1 -1
  3. package/dist/crystalClasses.js +2 -3
  4. package/dist/crystalClasses.js.map +1 -1
  5. package/dist/operations.d.ts.map +1 -1
  6. package/dist/operations.js +1 -1
  7. package/dist/operations.js.map +1 -1
  8. package/dist/plane.d.ts +37 -0
  9. package/dist/plane.d.ts.map +1 -1
  10. package/dist/plane.js +94 -13
  11. package/dist/plane.js.map +1 -1
  12. package/dist/siteSymmetry.d.ts +1 -1
  13. package/dist/siteSymmetry.d.ts.map +1 -1
  14. package/dist/siteSymmetry.js +35 -30
  15. package/dist/siteSymmetry.js.map +1 -1
  16. package/dist/spaceGroups/cell.d.ts +2 -0
  17. package/dist/spaceGroups/cell.d.ts.map +1 -1
  18. package/dist/spaceGroups/cell.js +10 -2
  19. package/dist/spaceGroups/cell.js.map +1 -1
  20. package/dist/spaceGroups/describe.d.ts +7 -0
  21. package/dist/spaceGroups/describe.d.ts.map +1 -1
  22. package/dist/spaceGroups/describe.js +10 -1
  23. package/dist/spaceGroups/describe.js.map +1 -1
  24. package/dist/spaceGroups/positions.d.ts.map +1 -1
  25. package/dist/spaceGroups/positions.js +39 -22
  26. package/dist/spaceGroups/positions.js.map +1 -1
  27. package/dist/spaceGroups/snap.d.ts +20 -0
  28. package/dist/spaceGroups/snap.d.ts.map +1 -0
  29. package/dist/spaceGroups/snap.js +103 -0
  30. package/dist/spaceGroups/snap.js.map +1 -0
  31. package/dist/tensors/propertyTable.js +3 -3
  32. package/dist/tensors/propertyTable.js.map +1 -1
  33. package/dist/tensors/rowEchelon.d.ts +12 -4
  34. package/dist/tensors/rowEchelon.d.ts.map +1 -1
  35. package/dist/tensors/rowEchelon.js +23 -10
  36. package/dist/tensors/rowEchelon.js.map +1 -1
  37. package/dist/tensors/tensorForm.d.ts.map +1 -1
  38. package/dist/tensors/tensorForm.js +4 -3
  39. package/dist/tensors/tensorForm.js.map +1 -1
  40. package/dist/version.d.ts +1 -1
  41. package/dist/version.d.ts.map +1 -1
  42. package/dist/version.js +1 -1
  43. package/dist/version.js.map +1 -1
  44. package/package.json +1 -1
  45. package/src/crystalClasses.ts +2 -3
  46. package/src/operations.ts +3 -1
  47. package/src/plane.ts +122 -15
  48. package/src/siteSymmetry.ts +35 -31
  49. package/src/spaceGroups/cell.ts +13 -2
  50. package/src/spaceGroups/describe.ts +17 -1
  51. package/src/spaceGroups/positions.ts +52 -22
  52. package/src/spaceGroups/snap.ts +121 -0
  53. package/src/tensors/propertyTable.ts +3 -3
  54. package/src/tensors/rowEchelon.ts +26 -8
  55. package/src/tensors/tensorForm.ts +4 -3
  56. package/src/version.ts +1 -1
@@ -7,13 +7,17 @@ export const PIVOT_EPSILON = 1e-7;
7
7
  /** An entry below this (absolute) is not eliminated, and is set to zero in the result. */
8
8
  export const ELIMINATION_EPSILON = 1e-12;
9
9
  /**
10
- * The reduced row echelon form of the span of `vectors` (all of length `dim`): one row per
11
- * independent direction, each with a 1 at its pivot and 0 at every other row's pivot, pivots
12
- * ascending. The rows are unique for a given span, so the pivots name the free parameters
13
- * unambiguously: each is the lowest-index component that is independent of the ones before it.
10
+ * The reduced row echelon form of the span of `vectors` (all of length `dim`), with its pivot
11
+ * columns: one row per independent direction, each with a 1 at its pivot and 0 at every other
12
+ * row's pivot, pivots ascending. The rows are unique for a given span, so the pivots name the free
13
+ * parameters unambiguously: each is the lowest-index component that is independent of the ones
14
+ * before it. For operations with float noise a row can keep entries too small to be a pivot
15
+ * (below `PIVOT_EPSILON`) before its pivot, so the pivots are returned rather than read off the
16
+ * rows (#88); entries below `ELIMINATION_EPSILON` are set to zero.
14
17
  */
15
- export function reducedRowEchelon(vectors, dim) {
18
+ export function rowEchelonWithPivots(vectors, dim) {
16
19
  const m = vectors.map((v) => Array.from(v));
20
+ const pivots = [];
17
21
  let row = 0;
18
22
  for (let c = 0; c < dim && row < m.length; c++) {
19
23
  let pivot = row;
@@ -33,14 +37,23 @@ export function reducedRowEchelon(vectors, dim) {
33
37
  for (let j = 0; j < dim; j++)
34
38
  m[r][j] -= f * m[row][j];
35
39
  }
40
+ pivots.push(c);
36
41
  row++;
37
42
  }
38
- const out = m.slice(0, row);
39
- for (const r of out)
40
- for (let j = 0; j < dim; j++)
41
- if (Math.abs(r[j]) < ELIMINATION_EPSILON)
43
+ const rows = m.slice(0, row);
44
+ rows.forEach((r, k) => {
45
+ for (let j = 0; j < dim; j++) {
46
+ if (j === pivots[k])
47
+ r[j] = 1;
48
+ else if (pivots.includes(j) || Math.abs(r[j]) < ELIMINATION_EPSILON)
42
49
  r[j] = 0;
43
- return out;
50
+ }
51
+ });
52
+ return { rows, pivots };
53
+ }
54
+ /** The reduced row echelon form of the span of `vectors`, as `rowEchelonWithPivots` gives it, without the pivots. */
55
+ export function reducedRowEchelon(vectors, dim) {
56
+ return rowEchelonWithPivots(vectors, dim).rows;
44
57
  }
45
58
  /** The number of independent vectors among `vectors` (all of length `dim`). */
46
59
  export function rank(vectors, dim) {
@@ -1 +1 @@
1
- {"version":3,"file":"rowEchelon.js","sourceRoot":"","sources":["../../src/tensors/rowEchelon.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,sGAAsG;AACtG,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,CAAC;AAElC,0FAA0F;AAC1F,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,CAAC;AAEzC;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAAuC,EAAE,GAAW;IACpF,MAAM,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5C,IAAI,GAAG,GAAG,CAAC,CAAC;IACZ,KAAK,IAAI,CAAC,GAAG,CAAC,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import { operations, settings } from '../pointGroups/pointGroups.js';
15
15
  import { specOf } from './propertyTable.js';
16
16
  import { EPSILON, SNAP_EPSILON } from '../tolerances.js';
17
- import { reducedRowEchelon } from './rowEchelon.js';
17
+ import { rowEchelonWithPivots } from './rowEchelon.js';
18
18
  const RANKS = [0, 1, 2, 3, 4];
19
19
  /** Checks a specification and returns the index permutations that generate its intrinsic symmetry. */
20
20
  function checkSpec(spec) {
@@ -117,8 +117,9 @@ function project(group, spec, perms) {
117
117
  if (averaged.some((x) => Math.abs(x) >= EPSILON))
118
118
  spanning.push(averaged);
119
119
  }
120
- const basis = reducedRowEchelon(spanning, dim).map((row) => row.map(snapEntry));
121
- const pivots = basis.map((row) => row.findIndex((x) => x !== 0));
120
+ const reduced = rowEchelonWithPivots(spanning, dim);
121
+ const basis = reduced.rows.map((row) => row.map(snapEntry));
122
+ const { pivots } = reduced;
122
123
  const relations = [];
123
124
  for (let c = 0; c < dim; c++) {
124
125
  if (pivots.includes(c))
@@ -1 +1 @@
1
- {"version":3,"file":"tensorForm.js","sourceRoot":"","sources":["../../src/tensors/tensorForm.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,GAAG,EAAa,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,UAAU,EAAkB,MAAM,kBAAkB,CAAC;AAClG,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAmD,MAAM,+BAA+B,CAAC;AACtH,OAAO,EAAE,MAAM,EAA2B,MAAM,oBAAoB,CAAC;AACrE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AA6DpD,MAAM,KAAK,GAAsB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAEjD,sGAAsG;AACtG,SAAS,SAAS,CAAC,IAAgB;IAC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AAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC7D,GAAG,IAAI,CAAC,CAAC;QACX,CAAC;QACD,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC;IACnB,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
package/dist/version.d.ts CHANGED
@@ -3,5 +3,5 @@
3
3
  *
4
4
  * @remarks Kept equal to `version` in package.json (checked by version.test.ts).
5
5
  */
6
- export declare const VERSION = "0.9.0";
6
+ export declare const VERSION = "0.10.1";
7
7
  //# sourceMappingURL=version.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,OAAO,UAAU,CAAC"}
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,OAAO,WAAW,CAAC"}
package/dist/version.js CHANGED
@@ -3,5 +3,5 @@
3
3
  *
4
4
  * @remarks Kept equal to `version` in package.json (checked by version.test.ts).
5
5
  */
6
- export const VERSION = '0.9.0';
6
+ export const VERSION = '0.10.1';
7
7
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC"}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "symcrys",
3
- "version": "0.9.0",
3
+ "version": "0.10.1",
4
4
  "description": "Crystallographic symmetry calculations: point groups (crystallographic and magnetic) and plane groups, their settings, symbols and properties, and property tensors. TypeScript library without dependencies.",
5
5
  "keywords": [
6
6
  "crystallography",
@@ -404,7 +404,7 @@ export function symmetryDirections(
404
404
  * group, `multiplicity` may not be an integer. The matrices must be Cartesian and orthogonal (not
405
405
  * those of `latticeOperations`). Throws a RangeError for a matrix that is not orthogonal (within
406
406
  * `tolerance`, at least `EPSILON`), for a zero vector, and if the closed operations fix no common
407
- * direction (a tolerance far too large, e.g. 0.5).
407
+ * direction or do not settle into a group (a tolerance far too large, e.g. 0.5).
408
408
  */
409
409
  export function siteSymmetry(
410
410
  operations: readonly OperationArgument[],
@@ -412,8 +412,7 @@ export function siteSymmetry(
412
412
  options?: site.SiteSymmetryOptions,
413
413
  ): site.SiteSymmetry {
414
414
  checkUnitary(operations);
415
- // The shared function reads the matrices only, and it keeps the products of a list by the identity
416
- // of the list, so the list of the caller is passed on as it is.
415
+ // The shared function reads the matrices only, so the list of the caller is passed on as it is.
417
416
  return site.siteSymmetry(operations as readonly MagneticOperation[], direction, options);
418
417
  }
419
418
 
package/src/operations.ts CHANGED
@@ -99,7 +99,9 @@ export function closeGroup(generators: readonly Operation[]): Operation[] {
99
99
  const add = (op: Operation): boolean => {
100
100
  if (group.some((g) => operationsEqual(g, op))) return false;
101
101
  if (group.length >= MAX_GROUP_ORDER)
102
- throw new Error('closeGroup: closure does not terminate; check the generators');
102
+ throw new RangeError(
103
+ `The operations generate no finite point group (more than ${MAX_GROUP_ORDER} elements): a rotation by an angle that is not 360°/n, or matrices too far from exact`,
104
+ );
103
105
  group.push(op);
104
106
  return true;
105
107
  };
package/src/plane.ts CHANGED
@@ -32,7 +32,8 @@ import {
32
32
  type PlanePointGroupKey,
33
33
  } from './spaceGroups/planePointGroups.js';
34
34
  import { planeOrbit, planeSiteSymmetry, planeWyckoffPositionOf } from './spaceGroups/positions.js';
35
- import { parseRational, toNumber, type Rational } from './spaceGroups/rational.js';
35
+ import { planeSnapToWyckoffPosition } from './spaceGroups/snap.js';
36
+ import { parseRational, rational, toNumber, type Rational } from './spaceGroups/rational.js';
36
37
 
37
38
  export { VERSION } from './version.js';
38
39
  export type { PlaneSystem } from './spaceGroups/planeGroupData.js';
@@ -148,6 +149,13 @@ export interface OperationDescription {
148
149
  readonly location?: readonly number[];
149
150
  /** For a mirror or glide: the direction of its line, the shortest integer vector, first non-zero component positive. */
150
151
  readonly direction?: readonly number[];
152
+ /**
153
+ * For a mirror or glide: the normal of its line in the lattice basis, its symmetry direction as in
154
+ * ITA Table 2.1.3.1: the shortest integer vector along the columns of W − I, first non-zero
155
+ * component positive. Without a metric it is not the perpendicular of `direction`: in a hexagonal
156
+ * basis the normal of a line along [1,0] is [1,2].
157
+ */
158
+ readonly normal?: readonly number[];
151
159
  /** For a glide: the glide vector (w + W·w)/2, not reduced modulo the lattice. */
152
160
  readonly glide?: readonly number[];
153
161
  }
@@ -164,6 +172,12 @@ export interface WyckoffPosition {
164
172
  readonly coordinates: readonly string[];
165
173
  }
166
174
 
175
+ /** A point snapped onto a Wyckoff position: the position, as `wyckoffPositions` gives it, and the point on it. */
176
+ export interface SnappedPosition extends WyckoffPosition {
177
+ /** The point on the position nearest to the given one, modulo the lattice, in [0, 1). */
178
+ readonly point: readonly number[];
179
+ }
180
+
167
181
  /** The site symmetry of a point under a plane group. */
168
182
  export interface SiteSymmetry {
169
183
  /** Indices into `operations` of those that map the point onto itself modulo the lattice, ascending: a subgroup. */
@@ -198,6 +212,8 @@ export interface SymmetryLine {
198
212
  readonly kind: 'mirror' | 'glide';
199
213
  /** The direction of the line, the shortest integer vector, first non-zero component positive. */
200
214
  readonly direction: readonly number[];
215
+ /** The normal of the line in the lattice basis, as in `describeOperations`. */
216
+ readonly normal: readonly number[];
201
217
  /** For a glide line its glide vector s·direction, 0 < s < 1; for a mirror line (0, 0). */
202
218
  readonly glide: readonly number[];
203
219
  /** The two ends of the segment of the line in the cell [0, 1]², in the order of `direction`. */
@@ -269,6 +285,67 @@ const plain = (op: ExactOperation): PlaneOperation => {
269
285
  });
270
286
  };
271
287
 
288
+ /** The description of an exact operation with plain numbers. */
289
+ function describe(op: ExactOperation): OperationDescription {
290
+ const d = describePlaneOperation(op);
291
+ return Object.freeze({
292
+ kind: d.kind,
293
+ order: d.order,
294
+ ...(d.sense ? { sense: d.sense } : {}),
295
+ ...(d.translation ? { translation: Object.freeze(numbers(d.translation)) } : {}),
296
+ ...(d.location ? { location: Object.freeze(numbers(d.location)) } : {}),
297
+ ...(d.direction ? { direction: Object.freeze([...d.direction]) } : {}),
298
+ ...(d.normal ? { normal: Object.freeze([...d.normal]) } : {}),
299
+ ...(d.glide ? { glide: Object.freeze(numbers(d.glide)) } : {}),
300
+ });
301
+ }
302
+
303
+ /** Tolerance for reading an integer or a fraction from a double. */
304
+ const READ_TOLERANCE = 1e-9;
305
+ /** The largest denominator of a translation that `describeOperationsOf` reads. */
306
+ const MAX_DENOMINATOR = 12;
307
+
308
+ function fractionOf(value: unknown): Rational {
309
+ if (typeof value === 'number' && Number.isFinite(value)) {
310
+ for (let d = 1; d <= MAX_DENOMINATOR; d++) {
311
+ const n = Math.round(value * d);
312
+ if (Math.abs(value * d - n) < READ_TOLERANCE * d) return rational(n, d);
313
+ }
314
+ }
315
+ throw new RangeError(
316
+ `Not within 10⁻⁹ of a translation with a denominator of at most ${MAX_DENOMINATOR}: ${shown(value)}`,
317
+ );
318
+ }
319
+
320
+ /** A value for an error message; never throws (BigInt, circular objects). */
321
+ function shown(value: unknown): string {
322
+ try {
323
+ return JSON.stringify(value) ?? String(value);
324
+ } catch {
325
+ return String(value);
326
+ }
327
+ }
328
+
329
+ /** 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 {
331
+ const o = op as Partial<PlaneOperation> | null;
332
+ const m = o?.matrix;
333
+ const t = o?.translation;
334
+ const isRow = (row: unknown): row is readonly number[] => Array.isArray(row) && row.length === 2;
335
+ if (!Array.isArray(m) || m.length !== 2 || !m.every(isRow) || !Array.isArray(t) || t.length !== 2) {
336
+ throw new RangeError(`Not an operation of the plane { matrix (2 × 2), translation (2) }: ${shown(op)}`);
337
+ }
338
+ const matrix = m.map((row) =>
339
+ row.map((v) => {
340
+ if (!(typeof v === 'number' && Math.abs(v - Math.round(v)) < READ_TOLERANCE)) {
341
+ throw new RangeError(`The matrix of a plane operation has integer entries, not ${shown(m)}`);
342
+ }
343
+ return Math.round(v) + 0;
344
+ }),
345
+ );
346
+ return { matrix, translation: t.map(fractionOf) };
347
+ }
348
+
272
349
  /** The plane group with this key (short symbol). Throws a RangeError for an unknown key. */
273
350
  export function planeGroup(key: PlaneGroupKey): PlaneGroup {
274
351
  const entry = planeGroupEntry(groupKey(key, 'planeGroup'));
@@ -342,20 +419,24 @@ export function describeOperations(
342
419
  key: PlaneGroupKey | PointGroupKey,
343
420
  options?: SettingOptions,
344
421
  ): readonly OperationDescription[] {
345
- return Object.freeze(
346
- exact(key, options, false).map((op) => {
347
- const d = describePlaneOperation(op);
348
- return Object.freeze({
349
- kind: d.kind,
350
- order: d.order,
351
- ...(d.sense ? { sense: d.sense } : {}),
352
- ...(d.translation ? { translation: Object.freeze(numbers(d.translation)) } : {}),
353
- ...(d.location ? { location: Object.freeze(numbers(d.location)) } : {}),
354
- ...(d.direction ? { direction: Object.freeze([...d.direction]) } : {}),
355
- ...(d.glide ? { glide: Object.freeze(numbers(d.glide)) } : {}),
356
- });
357
- }),
358
- );
422
+ return Object.freeze(exact(key, options, false).map(describe));
423
+ }
424
+
425
+ /**
426
+ * Any operations of the plane (lattice basis) described geometrically, index for index, as
427
+ * `describeOperations` describes those of a group: for instance a product of operations, an
428
+ * operation shifted by a lattice translation, or the operations of a site symmetry. Each operation is
429
+ * `{ matrix, translation }` as `operations` gives it. Each matrix must have integer entries (within
430
+ * 10⁻⁹) and be the linear part of a crystallographic plane point group (determinant ±1, order 1,
431
+ * 2, 3, 4 or 6); each translation must lie within 10⁻⁹ of a fraction with a denominator of at most
432
+ * 12 (1/3 as 0.333…), as the translations of `operations` and their products do. Throws a
433
+ * RangeError otherwise.
434
+ */
435
+ export function describeOperationsOf(operations: readonly PlaneOperation[]): readonly OperationDescription[] {
436
+ if (!Array.isArray(operations)) {
437
+ throw new RangeError('describeOperationsOf takes a list of operations { matrix, translation }');
438
+ }
439
+ return Object.freeze(operations.map((op) => describe(exactOf(op))));
359
440
  }
360
441
 
361
442
  /**
@@ -405,6 +486,31 @@ export function wyckoffPositionOf(
405
486
  return found;
406
487
  }
407
488
 
489
+ /**
490
+ * Snaps a point (lattice basis) onto the most special Wyckoff position of a plane group that lies
491
+ * within the tolerance of it, measured per coordinate modulo the lattice: a position without a free
492
+ * parameter (a point) before one with one (a line), before the general position, which always holds
493
+ * the point; among positions of the same kind the nearest. Returns the position, as
494
+ * `wyckoffPositions` gives it, and the nearest point on it, in [0, 1). Unlike `wyckoffPositionOf`,
495
+ * which asks whether the images of the point lie within the tolerance of it, this asks whether the
496
+ * point lies within the tolerance of the position: an application that drags a point and lets it
497
+ * snap passes a tolerance such as 10⁻². The point on a line is found by least squares in the
498
+ * lattice coordinates. Throws a RangeError as `siteSymmetry`.
499
+ */
500
+ export function snapToWyckoffPosition(
501
+ key: PlaneGroupKey,
502
+ point: readonly number[],
503
+ options?: PointOptions,
504
+ ): SnappedPosition {
505
+ const k = groupKey(key, 'snapToWyckoffPosition');
506
+ if (!Array.isArray(point)) {
507
+ throw new RangeError(`A point of the plane has two finite coordinates, not ${JSON.stringify(point)}`);
508
+ }
509
+ const snapped = planeSnapToWyckoffPosition(k, point, options?.tolerance);
510
+ const position = wyckoffPositions(k)[snapped.row];
511
+ return Object.freeze({ ...position, point: Object.freeze([...snapped.point]) });
512
+ }
513
+
408
514
  /**
409
515
  * The orbit of a point (lattice basis) under a plane group: its distinct images in the
410
516
  * conventional cell, each in [0, 1), in the order of the operations that first give them; images
@@ -446,6 +552,7 @@ export function symmetryElements(key: PlaneGroupKey): SymmetryElements {
446
552
  Object.freeze({
447
553
  kind: l.kind,
448
554
  direction: Object.freeze([...l.direction]),
555
+ normal: Object.freeze([...l.normal]),
449
556
  glide: Object.freeze(numbers(l.glide)),
450
557
  segment: Object.freeze(l.segment.map((p) => Object.freeze(numbers(p)))),
451
558
  }),
@@ -51,33 +51,33 @@ function isIdentity(op: Operation): boolean {
51
51
  return op.matrix.every((row, i) => row.every((v, j) => Math.abs(v - (i === j ? 1 : 0)) < EPSILON));
52
52
  }
53
53
 
54
- /** Products already looked up, per list of operations: `i * n + j` → index of op[i]·op[j] in the list, or -1. */
55
- const productTables = new WeakMap<readonly Operation[], Map<number, number>>();
56
-
57
- function productIndex(operations: readonly Operation[], i: number, j: number): number {
58
- let table = productTables.get(operations);
59
- if (!table) {
60
- table = new Map();
61
- productTables.set(operations, table);
62
- }
63
- const key = i * operations.length + j;
64
- let k = table.get(key);
65
- if (k === undefined) {
66
- const product = multiply(operations[i].matrix, operations[j].matrix);
67
- k = operations.findIndex((op) => matricesEqual(op.matrix, product));
68
- table.set(key, k);
69
- }
70
- return k;
54
+ /**
55
+ * The products of a list of operations, looked up as needed: `i * n + j` → index of op[i]·op[j] in
56
+ * the list, or -1. Made per call, not kept between calls: a caller may change its list in place
57
+ * (#90).
58
+ */
59
+ function productLookup(operations: readonly Operation[]): (i: number, j: number) => number {
60
+ const table = new Map<number, number>();
61
+ return (i, j) => {
62
+ const key = i * operations.length + j;
63
+ let k = table.get(key);
64
+ if (k === undefined) {
65
+ const product = multiply(operations[i].matrix, operations[j].matrix);
66
+ k = operations.findIndex((op) => matricesEqual(op.matrix, product));
67
+ table.set(key, k);
68
+ }
69
+ return k;
70
+ };
71
71
  }
72
72
 
73
73
  /** The indices plus those of every product of two of them that is itself in the list, until closed. */
74
- function closeWithin(operations: readonly Operation[], indices: readonly number[]): number[] {
74
+ function closeWithin(product: (i: number, j: number) => number, indices: readonly number[]): number[] {
75
75
  const set = [...indices];
76
76
  const inSet = new Set(set);
77
77
  // Each element is multiplied with every element before it once, in both orders, as it is added.
78
78
  for (let i = 0; i < set.length; i++) {
79
79
  for (let j = 0; j <= i; j++) {
80
- for (const k of [productIndex(operations, set[i], set[j]), productIndex(operations, set[j], set[i])]) {
80
+ for (const k of [product(set[i], set[j]), product(set[j], set[i])]) {
81
81
  if (k >= 0 && !inSet.has(k)) {
82
82
  inSet.add(k);
83
83
  set.push(k);
@@ -122,7 +122,7 @@ export function siteTolerance(options?: SiteSymmetryOptions): number {
122
122
  * not be an integer. The matrices must be Cartesian and orthogonal (not those of
123
123
  * `latticeOperations`). Throws a RangeError for a matrix that is not orthogonal (within
124
124
  * `tolerance`, at least `EPSILON`), for a zero vector, and if the closed operations fix no common
125
- * direction (a tolerance far too large, e.g. 0.5).
125
+ * direction or do not settle into a group (a tolerance far too large, e.g. 0.5).
126
126
  */
127
127
  export function siteSymmetry(
128
128
  operations: readonly Operation[],
@@ -143,24 +143,28 @@ export function siteSymmetry(
143
143
  // as fixing while its square does not). Close them under products found in the list, set v onto the
144
144
  // fixed space of the closure (the mean of its images, the projector for a group), and repeat on the
145
145
  // projected direction until the set is stable.
146
- let indices = fixing(v);
147
- let projected = v;
148
- let set = closeWithin(operations, indices);
149
- for (let pass = 0; pass < 8; pass++) {
146
+ const product = productLookup(operations);
147
+ let set = closeWithin(product, fixing(v));
148
+ let settled: { indices: number[]; projected: Vec3 } | undefined;
149
+ for (let pass = 0; pass < 8 && !settled; pass++) {
150
150
  const mean = meanImage(operations, set, v);
151
151
  if (mean === undefined) {
152
152
  throw new RangeError(
153
153
  `No common fixed direction for the operations fixing ${JSON.stringify(direction)} within ${tolerance} (tolerance too large?)`,
154
154
  );
155
155
  }
156
- const next = closeWithin(operations, fixing(mean));
157
- if (sameIndices(next, set)) {
158
- indices = set;
159
- projected = mean;
160
- break;
161
- }
162
- set = next;
156
+ const next = closeWithin(product, fixing(mean));
157
+ if (sameIndices(next, set)) settled = { indices: set, projected: mean };
158
+ else set = next;
159
+ }
160
+ if (!settled) {
161
+ // Only for a tolerance far too large; the site symmetry would be neither closed nor its direction
162
+ // projected (#91).
163
+ throw new RangeError(
164
+ `The site symmetry of ${JSON.stringify(direction)} does not settle within ${tolerance} (tolerance too large?)`,
165
+ );
163
166
  }
167
+ const { indices, projected } = settled;
164
168
  return Object.freeze({
165
169
  operations: Object.freeze(indices),
166
170
  direction: Object.freeze(projected) as Vec3,
@@ -50,6 +50,8 @@ export interface SymmetryLine {
50
50
  readonly kind: 'mirror' | 'glide';
51
51
  /** The direction of the line, the shortest integer vector, first non-zero component positive. */
52
52
  readonly direction: readonly [number, number];
53
+ /** The normal of the line in the lattice basis, as `PlaneOperationDescription.normal`. */
54
+ readonly normal: readonly [number, number];
53
55
  /** For a glide line: its glide vector s·direction with 0 < s < 1; for a mirror line (0, 0). */
54
56
  readonly glide: readonly Rational[];
55
57
  /** The ends of the segment of the line in the cell [0, 1]², in the order of `direction`. */
@@ -302,6 +304,7 @@ export function planeCellElements(key: string | number): CellElements {
302
304
  const lines: {
303
305
  kind: 'mirror' | 'glide';
304
306
  direction: [number, number];
307
+ normal: readonly [number, number];
305
308
  s: Rational;
306
309
  c: Rational;
307
310
  segment: [readonly Rational[], readonly Rational[]];
@@ -325,7 +328,7 @@ export function planeCellElements(key: string | number): CellElements {
325
328
  // The glide vector is s·dir; s modulo 1, since a lattice translation along the line changes nothing.
326
329
  const g = d.glide ?? [ZERO, ZERO];
327
330
  const s = frac(dir[0] !== 0 ? rational(g[0][0], g[0][1] * dir[0]) : rational(g[1][0], g[1][1] * dir[1]));
328
- // The line is n·x = c with the normal n = (−dir_y, dir_x).
331
+ // The line is the set of x with (−dir_y, dir_x)·x = c.
329
332
  const c = add(scale(-dir[1], p[0]), scale(dir[0], p[1]));
330
333
  if (
331
334
  lines.some(
@@ -340,7 +343,14 @@ export function planeCellElements(key: string | number): CellElements {
340
343
  }
341
344
  const segment = clip(p, dir);
342
345
  if (!segment) continue;
343
- lines.push({ kind: s[0] === 0 ? 'mirror' : 'glide', direction: [dir[0], dir[1]], s, c, segment });
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
+ });
344
354
  }
345
355
  }
346
356
  }
@@ -360,6 +370,7 @@ export function planeCellElements(key: string | number): CellElements {
360
370
  Object.freeze({
361
371
  kind: l.kind,
362
372
  direction: Object.freeze(l.direction) as readonly [number, number],
373
+ normal: Object.freeze([...l.normal]) as readonly [number, number],
363
374
  glide: Object.freeze([scale(l.direction[0], l.s), scale(l.direction[1], l.s)]),
364
375
  segment: Object.freeze(l.segment.map((p) => Object.freeze([...p]))) as unknown as SymmetryLine['segment'],
365
376
  }),
@@ -32,6 +32,13 @@ export interface PlaneOperationDescription {
32
32
  readonly location?: readonly Rational[];
33
33
  /** For a mirror or glide: the direction of its line, the shortest integer vector, first non-zero component positive. */
34
34
  readonly direction?: readonly [number, number];
35
+ /**
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
39
+ * hexagonal basis the normal of a line along [1,0] is [1,2].
40
+ */
41
+ readonly normal?: readonly [number, number];
35
42
  /**
36
43
  * For a glide: the glide vector (w + W·w)/2, not reduced modulo the lattice. An operation whose
37
44
  * glide vector is a non-zero lattice vector is a glide, as it is geometrically, although the
@@ -116,6 +123,10 @@ export function describePlaneOperation(op: ExactOperation): PlaneOperationDescri
116
123
  [w[0][0] + 1, w[0][1]],
117
124
  [w[1][0], w[1][1] + 1],
118
125
  ]);
126
+ const normal = primitiveColumn([
127
+ [w[0][0] - 1, w[0][1]],
128
+ [w[1][0], w[1][1] - 1],
129
+ ]);
119
130
  // (I − W) has rank 1; one of its non-zero rows a gives a·p = s_i. A point on y = 0 if the line meets it.
120
131
  const a = [
121
132
  [1 - w[0][0], -w[0][1]],
@@ -124,7 +135,12 @@ export function describePlaneOperation(op: ExactOperation): PlaneOperationDescri
124
135
  const i = a[0][0] !== 0 || a[0][1] !== 0 ? 0 : 1;
125
136
  const location: Rational[] =
126
137
  a[i][0] !== 0 ? [multiply(s[i], rational(1, a[i][0])), ZERO] : [ZERO, multiply(s[i], rational(1, a[i][1]))];
127
- const line = { order: 2, location: Object.freeze(location), direction: Object.freeze(direction) };
138
+ const line = {
139
+ order: 2,
140
+ location: Object.freeze(location),
141
+ direction: Object.freeze(direction),
142
+ normal: Object.freeze(normal),
143
+ };
128
144
  return Object.freeze(
129
145
  glide.some((v) => v[0] !== 0)
130
146
  ? { kind: 'glide' as const, ...line, glide: Object.freeze(glide) }