symcrys 0.9.0 → 0.10.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.
@@ -1 +1 @@
1
- {"version":3,"file":"positions.js","sourceRoot":"","sources":["../../src/spaceGroups/positions.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,OAAO,EAAuB,MAAM,aAAa,CAAC;AACrG,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACzE,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AA0C3C,SAAS,SAAS,CAAC,OAAsB;IACvC,MAAM,CAAC,GAAG,OAAO,EAAE,SAAS,IAAI,OAAO,CAAC;IACxC,wGAAwG;IACxG,IAAI,CAAC,CAAC,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,EAAE,CAAC;QACjD,MAAM,IAAI,UAAU,CAAC,iDAAiD,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IACrF,CAAC;IACD,OAAO,CAAC,CAAC;AACX,CAAC;AAED,SAAS,UAAU,CAAC,KAAwB;IAC1C,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;QACxD,MAAM,IAAI,UAAU,CAAC,wDAAwD,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACxG,CAAC;AACH,CAAC;AAED,MAAM,IAAI,GAAG,CAAC,CAAS,EAAU,EAAE;IACjC,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC5B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG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ane onto the nearest Wyckoff position of a plane group, by the distance
3
+ * of the point to the position (#85; CLAUDE.md, "Snapping onto a Wyckoff position"). Unlike the site
4
+ * symmetry (`positions.ts`), which asks whether the images of a point lie within a tolerance of it,
5
+ * this asks whether the point lies within the tolerance of the point set of a position. Internal.
6
+ */
7
+ /** A point snapped onto a Wyckoff position: the index of the printed row and the point on it, in [0, 1). */
8
+ export interface SnappedPoint {
9
+ readonly row: number;
10
+ readonly point: readonly number[];
11
+ }
12
+ /**
13
+ * Snaps a point (lattice basis) onto the most special Wyckoff position of a plane group that lies
14
+ * within `tolerance` of it (per coordinate, modulo the lattice): positions without a free parameter
15
+ * first, then lines, then the general position, which always holds the point. Among positions with
16
+ * the same number of free parameters the nearest wins. Throws a RangeError for a point that is not
17
+ * two finite numbers or a tolerance outside (0, 1/2).
18
+ */
19
+ export declare function planeSnapToWyckoffPosition(key: string, point: readonly number[], tolerance?: number): SnappedPoint;
20
+ //# sourceMappingURL=snap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"snap.d.ts","sourceRoot":"","sources":["../../src/spaceGroups/snap.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AA6EH,4GAA4G;AAC5G,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;CACnC;AAED;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CACxC,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,SAAS,GAAE,MAAgB,GAC1B,YAAY,CAqBd"}
@@ -0,0 +1,103 @@
1
+ /**
2
+ * Snapping a point of the plane onto the nearest Wyckoff position of a plane group, by the distance
3
+ * of the point to the position (#85; CLAUDE.md, "Snapping onto a Wyckoff position"). Unlike the site
4
+ * symmetry (`positions.ts`), which asks whether the images of a point lie within a tolerance of it,
5
+ * this asks whether the point lies within the tolerance of the point set of a position. Internal.
6
+ */
7
+ import { parseOperation, toPlain } from './affine.js';
8
+ import { planeGroupEntry } from './planeGroups.js';
9
+ import { EPSILON } from '../tolerances.js';
10
+ const cache = new Map();
11
+ function expression(op, shift) {
12
+ const m = op.matrix;
13
+ const columns = [0, 1].filter((k) => m[0][k] !== 0 || m[1][k] !== 0);
14
+ const det = m[0][0] * m[1][1] - m[0][1] * m[1][0];
15
+ return {
16
+ matrix: m,
17
+ translation: [op.translation[0] + shift[0], op.translation[1] + shift[1]],
18
+ freedom: columns.length === 2 && det === 0 ? 1 : columns.length,
19
+ };
20
+ }
21
+ /** Per printed Wyckoff row (index into `wyckoff`), its coordinate expressions with every centring. */
22
+ function positionsOf(symbol) {
23
+ let rows = cache.get(symbol);
24
+ if (!rows) {
25
+ const entry = planeGroupEntry(symbol);
26
+ const shifts = [[0, 0], ...entry.centring.map((t) => toPlain(parseOperation(t)).translation)];
27
+ rows = entry.wyckoff.map(([, , , coordinates], row) => ({
28
+ row,
29
+ expressions: coordinates.flatMap((c) => shifts.map((s) => expression(toPlain(parseOperation(c)), s))),
30
+ }));
31
+ cache.set(symbol, rows);
32
+ }
33
+ return rows;
34
+ }
35
+ /**
36
+ * The nearest point of the set of `e` to `p` modulo the lattice: the parameters by least squares in
37
+ * the lattice coordinates, over the lattice translations that can reach it. Returns the point and
38
+ * its distance, the larger of the two coordinate differences.
39
+ */
40
+ function nearest(e, p) {
41
+ if (e.freedom === 2)
42
+ return { point: [...p], distance: 0 };
43
+ const m = e.matrix;
44
+ const c = e.translation;
45
+ let best = { point: [0, 0], distance: Infinity };
46
+ // c lies in [0, 2) (a printed coordinate in [0, 1) plus a centring), p in [0, 1).
47
+ for (let i = -2; i <= 2; i++) {
48
+ for (let j = -2; j <= 2; j++) {
49
+ const v = [p[0] - c[0] - i, p[1] - c[1] - j];
50
+ let r;
51
+ if (e.freedom === 0) {
52
+ r = [0, 0];
53
+ }
54
+ else {
55
+ const k = m[0][0] !== 0 || m[1][0] !== 0 ? 0 : 1;
56
+ const col = [m[0][k], m[1][k]];
57
+ const t = (col[0] * v[0] + col[1] * v[1]) / (col[0] * col[0] + col[1] * col[1]);
58
+ r = [t * col[0], t * col[1]];
59
+ }
60
+ const distance = Math.max(Math.abs(r[0] - v[0]), Math.abs(r[1] - v[1]));
61
+ if (distance < best.distance)
62
+ best = { point: [r[0] + c[0] + i, r[1] + c[1] + j], distance };
63
+ }
64
+ }
65
+ return best;
66
+ }
67
+ const mod1 = (v) => {
68
+ const r = v - Math.floor(v);
69
+ return r >= 1 ? 0 : r + 0;
70
+ };
71
+ /**
72
+ * Snaps a point (lattice basis) onto the most special Wyckoff position of a plane group that lies
73
+ * within `tolerance` of it (per coordinate, modulo the lattice): positions without a free parameter
74
+ * first, then lines, then the general position, which always holds the point. Among positions with
75
+ * the same number of free parameters the nearest wins. Throws a RangeError for a point that is not
76
+ * two finite numbers or a tolerance outside (0, 1/2).
77
+ */
78
+ export function planeSnapToWyckoffPosition(key, point, tolerance = EPSILON) {
79
+ if (point.length !== 2 || !point.every(Number.isFinite)) {
80
+ throw new RangeError(`A point of the plane has two finite coordinates, not ${JSON.stringify(point)}`);
81
+ }
82
+ if (!(typeof tolerance === 'number' && tolerance > 0 && tolerance < 0.5)) {
83
+ throw new RangeError(`The tolerance must lie between 0 and 1/2, not ${String(tolerance)}`);
84
+ }
85
+ const p = point.map(mod1);
86
+ const rows = positionsOf(planeGroupEntry(key).symbol);
87
+ for (const freedom of [0, 1, 2]) {
88
+ let best;
89
+ for (const { row, expressions } of rows) {
90
+ for (const e of expressions) {
91
+ if (e.freedom !== freedom)
92
+ continue;
93
+ const n = nearest(e, p);
94
+ if (n.distance < tolerance && (!best || n.distance < best.distance))
95
+ best = { row, ...n };
96
+ }
97
+ }
98
+ if (best)
99
+ return { row: best.row, point: best.point.map(mod1) };
100
+ }
101
+ throw new Error(`The general position of ${key} does not hold ${JSON.stringify(point)}`);
102
+ }
103
+ //# sourceMappingURL=snap.js.map
@@ -0,0 +1 @@
1
+ {"version":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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.0";
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.0';
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.0",
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",
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
  }),
@@ -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) }
@@ -81,17 +81,38 @@ function sameModLattice(p: readonly number[], q: readonly number[], tol: number)
81
81
  });
82
82
  }
83
83
 
84
- const plainCache = new Map<string, PlainOperation[]>();
85
- function plainOperations(key: string): PlainOperation[] {
84
+ /**
85
+ * Per plane group, computed once: its operations as plain numbers and its group table modulo the
86
+ * lattice (`table[a][b]` is the index of the operation that equals a∘b modulo the lattice), so that
87
+ * closing a set of operations works on indices (#86).
88
+ */
89
+ interface GroupData {
90
+ readonly ops: readonly PlainOperation[];
91
+ readonly table: readonly (readonly number[])[];
92
+ }
93
+
94
+ const groupCache = new Map<string, GroupData>();
95
+ function groupData(key: string): GroupData {
86
96
  const k = planeGroupEntry(key).symbol;
87
- let ops = plainCache.get(k);
88
- if (!ops) {
89
- ops = planeGroupOperations(k).map(toPlain);
90
- plainCache.set(k, ops);
97
+ let data = groupCache.get(k);
98
+ if (!data) {
99
+ const exact = planeGroupOperations(k);
100
+ const table = exact.map((a) =>
101
+ exact.map((b) => {
102
+ const product = compose(a, b);
103
+ const i = exact.findIndex((op) => equalModLattice(op, product));
104
+ if (i < 0) throw new Error(`The operations of ${k} are not closed modulo the lattice`);
105
+ return i;
106
+ }),
107
+ );
108
+ data = { ops: exact.map(toPlain), table };
109
+ groupCache.set(k, data);
91
110
  }
92
- return ops;
111
+ return data;
93
112
  }
94
113
 
114
+ const plainOperations = (key: string): readonly PlainOperation[] => groupData(key).ops;
115
+
95
116
  /**
96
117
  * The orbit of a point under a plane group: its distinct images in the conventional cell, each in
97
118
  * [0, 1), in the order of the operations that first produce them. Coinciding images (within the
@@ -110,23 +131,21 @@ export function planeOrbit(key: string, point: readonly number[], options?: Poin
110
131
 
111
132
  /** Indices of `set` closed under products, modulo the lattice, within the operations of the group. */
112
133
  function closeWithin(key: string, set: readonly number[]): number[] {
113
- const exact = planeGroupOperations(planeGroupEntry(key).symbol);
114
- const out = new Set(set);
115
- let grew = true;
116
- while (grew) {
117
- grew = false;
118
- for (const a of [...out]) {
119
- for (const b of [...out]) {
120
- const product = compose(exact[a], exact[b]);
121
- const k = exact.findIndex((op) => equalModLattice(op, product));
122
- if (!out.has(k)) {
123
- out.add(k);
124
- grew = true;
134
+ const { table } = groupData(key);
135
+ const out = [...new Set(set)];
136
+ const member = new Set(out);
137
+ // Every product of two members is a member once each new member has been combined with all others.
138
+ for (let i = 0; i < out.length; i++) {
139
+ for (let j = 0; j <= i; j++) {
140
+ for (const k of [table[out[i]][out[j]], table[out[j]][out[i]]]) {
141
+ if (!member.has(k)) {
142
+ member.add(k);
143
+ out.push(k);
125
144
  }
126
145
  }
127
146
  }
128
147
  }
129
- return [...out].sort((a, b) => a - b);
148
+ return out.sort((a, b) => a - b);
130
149
  }
131
150
 
132
151
  /** The operations of `indices`, each shifted by the lattice translation that brings its image of `p` nearest to `p`. */
@@ -175,12 +194,23 @@ export function planeSiteSymmetry(key: string, point: readonly number[], options
175
194
  );
176
195
  }
177
196
 
197
+ /** A printed coordinate expression, parsed once. */
198
+ const expressionCache = new Map<string, PlainOperation>();
199
+ function parsed(expression: string): PlainOperation {
200
+ let op = expressionCache.get(expression);
201
+ if (!op) {
202
+ op = toPlain(parseOperation(expression));
203
+ expressionCache.set(expression, op);
204
+ }
205
+ return op;
206
+ }
207
+
178
208
  /**
179
209
  * True if some parameters x, y make the printed coordinate expression (e.g. `x,2x`, `-x+1/2,y`) give
180
210
  * the point modulo the lattice within `tol`: least squares over the nearby lattice translations.
181
211
  */
182
212
  function onExpression(expression: string, p: readonly number[], tol: number): boolean {
183
- const { matrix, translation } = toPlain(parseOperation(expression));
213
+ const { matrix, translation } = parsed(expression);
184
214
  const c = translation;
185
215
  const ex = [matrix[0][0], matrix[1][0]];
186
216
  const ey = [matrix[0][1], matrix[1][1]];
@@ -223,7 +253,7 @@ export function planeWyckoffPositionOf(
223
253
  const tol = tolerance(options);
224
254
  const site = planeSiteSymmetry(key, point, options);
225
255
  const entry = planeGroupEntry(key);
226
- const centrings = [[0, 0], ...entry.centring.map((t) => toPlain(parseOperation(t)).translation)];
256
+ const centrings = [[0, 0], ...entry.centring.map((t) => parsed(t).translation)];
227
257
  for (const [multiplicity, letter, siteSymmetry, coordinates] of entry.wyckoff) {
228
258
  if (multiplicity !== site.multiplicity) continue;
229
259
  for (const t of centrings) {