symcrys 0.1.1 → 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 +18 -5
  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
package/README.md CHANGED
@@ -4,7 +4,7 @@ Crystallographic symmetry calculations in TypeScript: point groups, both crystal
4
4
  magnetic, with their settings, symbols and properties, and the property tensors they allow. A
5
5
  library without runtime dependencies that runs unbundled in browsers and in Node.
6
6
 
7
- > **Status: pre-release.** The repository holds the scaffold only; the only export is `VERSION`.
7
+ > **Status: pre-release.** So far: the 32 crystallographic point groups with their symmetry elements.
8
8
  > The API will change without notice until 1.0.0.
9
9
 
10
10
  ## Scope
@@ -24,7 +24,7 @@ display names stay in the applications that use symcrys.
24
24
  **Conventions.** Point groups follow the _International Tables for Crystallography_ by default
25
25
  (Vol. A for the crystal classes, Vol. D Ch. 1.5 for the magnetic point groups). The convention of
26
26
  Birss, _Symmetry and Magnetism_ (1966), is available as an option. Where the two differ is
27
- documented in `docs/` as the point groups arrive.
27
+ documented in [`docs/conventions.md`](docs/conventions.md).
28
28
 
29
29
  symcrys is the computational core of the crystallography teaching apps
30
30
  ([stereography](https://github.com/manganite/stereography),
@@ -41,9 +41,18 @@ npm install symcrys
41
41
  Each release on GitHub also carries the package as `symcrys-X.Y.Z.tgz`.
42
42
 
43
43
  ```ts
44
- import { VERSION } from 'symcrys';
44
+ import { describeOperations, operations, settings, symbol, symmetryDirections } from 'symcrys';
45
+
46
+ symbol('32'); // '321': ITC short symbol of the default setting
47
+ symbol('32', { convention: 'birss' }); // '32'
48
+ settings('32'); // setting 1: 312, setting 2: 321 (the ITC default)
49
+ operations('-3m'); // 12 operations, Cartesian matrices; x ∥ a, z ∥ c
50
+ describeOperations('4')[2]; // { kind: 'rotation', order: 4, sense: '+', axis: { lattice: [0, 0, 1], … } }
51
+ symmetryDirections('4mm')[1]; // position 2: symbol 'm', directions [100] and [010], each with a mirror
45
52
  ```
46
53
 
54
+ Conventions, frames and symbols: [`docs/conventions.md`](docs/conventions.md).
55
+
47
56
  Without a build step, copy `dist/` (from the tarball, or built with `npm run build`) next to your
48
57
  code and import `dist/index.js` directly: every module in `dist/` imports only relative `.js`
49
58
  paths.
@@ -67,7 +76,9 @@ npm run check:dist # dist/ loads, imports only relative .js paths, has no te
67
76
  Audits under `audit/` compare the code bases symcrys draws on. They are run by hand, with
68
77
  [birss-app](https://github.com/manganite/birss-app) and
69
78
  [stereography](https://github.com/manganite/stereography) checked out next to this repository:
70
- `npm run audit:point-groups` writes `audit/point-groups/report.md`.
79
+ `npm run audit:point-groups` writes `audit/point-groups/report.md`, and `npm run audit:birss-app`
80
+ captures the pins of the Birss convention (`src/pointGroups/birssApp.pins.fixtures.ts`, formatted
81
+ with Prettier by the same script).
71
82
 
72
83
  CI runs these seven gates on every pull request, on Node 22 and 24. Tests sit next to their
73
84
  module (`foo.ts`, `foo.test.ts`). Working rules for contributors, human or agent: `CLAUDE.md`.
@@ -91,7 +102,9 @@ goes live only after approval with two-factor authentication (npm 11.15 or later
91
102
 
92
103
  1. `npm stage list symcrys`, then `npm stage view <stage-id>`: version and shasum must match the log
93
104
  of the `npm` job (or "Staged Packages" on npmjs.com).
94
- 2. `npm stage approve <stage-id>`.
105
+ 2. `npm stage approve <stage-id>`. npm first runs an automated review of the staged version; until
106
+ it has finished, approval fails with `E409 … automated review hasn't finished`. Then approve again
107
+ a little later (for 0.1.1 it took a few minutes).
95
108
  3. `npm view symcrys` shows the version as `latest`.
96
109
 
97
110
  If staging fails, re-run the `npm` job (a staged version cannot be staged twice, so check
package/dist/index.d.ts CHANGED
@@ -3,4 +3,11 @@
3
3
  * everything else is internal.
4
4
  */
5
5
  export { VERSION } from './version.js';
6
+ export type { Mat3, Vec3 } from './linalg.js';
7
+ export type { Operation } from './operations.js';
8
+ export { crystalFamily, latticeBasis, type CrystalFamily, type CrystalSystem, type FixedAngleFamily, } from './lattice.js';
9
+ export { POINT_GROUP_KEYS, findPointGroup, generators, isPointGroupKey, operations, pointGroup, pointGroups, settings, symbol, type Convention, type PointGroup, type PointGroupInSetting, type PointGroupKey, type PointGroupType, type Setting, type SettingOptions, type SymbolOptions, } from './pointGroups/pointGroups.js';
10
+ export { isCentrosymmetric, isChiral, isPolar, laueClass } from './pointGroups/properties.js';
11
+ export { LATTICE_SYMMETRY_DIRECTIONS, type Uvw } from './symmetryDirections.js';
12
+ export { describeOperations, symmetryDirections, type Axis, type DirectionElements, type OperationDescription, type OperationKind, type SymmetryDirection, } from './pointGroups/elements.js';
6
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,YAAY,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAC9C,YAAY,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EACL,aAAa,EACb,YAAY,EACZ,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,gBAAgB,GACtB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,UAAU,EACV,eAAe,EACf,UAAU,EACV,UAAU,EACV,WAAW,EACX,QAAQ,EACR,MAAM,EACN,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,mBAAmB,EACxB,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,OAAO,EACZ,KAAK,cAAc,EACnB,KAAK,aAAa,GACnB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAC9F,OAAO,EAAE,2BAA2B,EAAE,KAAK,GAAG,EAAE,MAAM,yBAAyB,CAAC;AAChF,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,KAAK,IAAI,EACT,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EACzB,KAAK,aAAa,EAClB,KAAK,iBAAiB,GACvB,MAAM,2BAA2B,CAAC"}
package/dist/index.js CHANGED
@@ -3,4 +3,9 @@
3
3
  * everything else is internal.
4
4
  */
5
5
  export { VERSION } from './version.js';
6
+ export { crystalFamily, latticeBasis, } from './lattice.js';
7
+ export { POINT_GROUP_KEYS, findPointGroup, generators, isPointGroupKey, operations, pointGroup, pointGroups, settings, symbol, } from './pointGroups/pointGroups.js';
8
+ export { isCentrosymmetric, isChiral, isPolar, laueClass } from './pointGroups/properties.js';
9
+ export { LATTICE_SYMMETRY_DIRECTIONS } from './symmetryDirections.js';
10
+ export { describeOperations, symmetryDirections, } from './pointGroups/elements.js';
6
11
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAIvC,OAAO,EACL,aAAa,EACb,YAAY,GAIb,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,UAAU,EACV,eAAe,EACf,UAAU,EACV,UAAU,EACV,WAAW,EACX,QAAQ,EACR,MAAM,GASP,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAC9F,OAAO,EAAE,2BAA2B,EAAY,MAAM,yBAAyB,CAAC;AAChF,OAAO,EACL,kBAAkB,EAClB,kBAAkB,GAMnB,MAAM,2BAA2B,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Crystal systems and families, and how the conventional lattice basis sits in the Cartesian frame
3
+ * of symcrys (docs/conventions.md, "Cartesian frame").
4
+ */
5
+ import type { Mat3 } from './linalg.js';
6
+ export type CrystalSystem = 'triclinic' | 'monoclinic' | 'orthorhombic' | 'tetragonal' | 'trigonal' | 'hexagonal' | 'cubic';
7
+ export type CrystalFamily = 'triclinic' | 'monoclinic' | 'orthorhombic' | 'tetragonal' | 'hexagonal' | 'cubic';
8
+ /** The crystal family of a crystal system: trigonal and hexagonal form the hexagonal family. */
9
+ export declare function crystalFamily(system: CrystalSystem): CrystalFamily;
10
+ /** The families whose cell angles are fixed, so that their lattice basis is fixed up to edge lengths. */
11
+ export type FixedAngleFamily = 'orthorhombic' | 'tetragonal' | 'hexagonal' | 'cubic';
12
+ /**
13
+ * The conventional basis vectors a, b, c as the **columns** of a Cartesian matrix, with unit edge
14
+ * lengths (a frozen array, shared between calls). Hexagonal family (hexagonal axes): x ∥ a, z ∥ c, y = z × x, so b points at 120° from a.
15
+ * Orthorhombic, tetragonal, cubic: x ∥ a, y ∥ b, z ∥ c.
16
+ *
17
+ * The edge lengths are set to 1 because the symmetry directions of these families, and so the
18
+ * point operations, do not depend on them. For a direction [uvw] that is not a symmetry direction,
19
+ * scale the columns by the real edge lengths first.
20
+ */
21
+ export declare function latticeBasis(family: FixedAngleFamily): Mat3;
22
+ //# sourceMappingURL=lattice.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lattice.d.ts","sourceRoot":"","sources":["../src/lattice.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAExC,MAAM,MAAM,aAAa,GACvB,WAAW,GAAG,YAAY,GAAG,cAAc,GAAG,YAAY,GAAG,UAAU,GAAG,WAAW,GAAG,OAAO,CAAC;AAElG,MAAM,MAAM,aAAa,GAAG,WAAW,GAAG,YAAY,GAAG,cAAc,GAAG,YAAY,GAAG,WAAW,GAAG,OAAO,CAAC;AAE/G,gGAAgG;AAChG,wBAAgB,aAAa,CAAC,MAAM,EAAE,aAAa,GAAG,aAAa,CAElE;AAED,yGAAyG;AACzG,MAAM,MAAM,gBAAgB,GAAG,cAAc,GAAG,YAAY,GAAG,WAAW,GAAG,OAAO,CAAC;AAoBrF;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,gBAAgB,GAAG,IAAI,CAW3D"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Crystal systems and families, and how the conventional lattice basis sits in the Cartesian frame
3
+ * of symcrys (docs/conventions.md, "Cartesian frame").
4
+ */
5
+ /** The crystal family of a crystal system: trigonal and hexagonal form the hexagonal family. */
6
+ export function crystalFamily(system) {
7
+ return system === 'trigonal' ? 'hexagonal' : system;
8
+ }
9
+ const S3_2 = Math.sqrt(3) / 2;
10
+ /** A deeply frozen matrix: the apps run dist/ as plain JavaScript, where `readonly` does not hold. */
11
+ const frozen = (m) => Object.freeze(m.map((row) => Object.freeze(row)));
12
+ const ORTHONORMAL = frozen([
13
+ [1, 0, 0],
14
+ [0, 1, 0],
15
+ [0, 0, 1],
16
+ ]);
17
+ const HEXAGONAL = frozen([
18
+ [1, -0.5, 0],
19
+ [0, S3_2, 0],
20
+ [0, 0, 1],
21
+ ]);
22
+ /**
23
+ * The conventional basis vectors a, b, c as the **columns** of a Cartesian matrix, with unit edge
24
+ * lengths (a frozen array, shared between calls). Hexagonal family (hexagonal axes): x ∥ a, z ∥ c, y = z × x, so b points at 120° from a.
25
+ * Orthorhombic, tetragonal, cubic: x ∥ a, y ∥ b, z ∥ c.
26
+ *
27
+ * The edge lengths are set to 1 because the symmetry directions of these families, and so the
28
+ * point operations, do not depend on them. For a direction [uvw] that is not a symmetry direction,
29
+ * scale the columns by the real edge lengths first.
30
+ */
31
+ export function latticeBasis(family) {
32
+ switch (family) {
33
+ case 'hexagonal':
34
+ return HEXAGONAL;
35
+ case 'orthorhombic':
36
+ case 'tetragonal':
37
+ case 'cubic':
38
+ return ORTHONORMAL;
39
+ default:
40
+ throw new RangeError(`latticeBasis: no fixed basis for the crystal family ${String(family)}`);
41
+ }
42
+ }
43
+ //# sourceMappingURL=lattice.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lattice.js","sourceRoot":"","sources":["../src/lattice.ts"],"names":[],"mappings":"AAAA;;;GAGG;AASH,gGAAgG;AAChG,MAAM,UAAU,aAAa,CAAC,MAAqB;IACjD,OAAO,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC;AACtD,CAAC;AAKD,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;AAE9B,sGAAsG;AACtG,MAAM,MAAM,GAAG,CAAC,CAA6B,EAAQ,EAAE,CACrD,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAoB,CAAC;AAEvE,MAAM,WAAW,GAAG,MAAM,CAAC;IACzB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IACT,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IACT,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;CACV,CAAC,CAAC;AAEH,MAAM,SAAS,GAAG,MAAM,CAAC;IACvB,CAAC,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC;IACZ,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;IACZ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;CACV,CAAC,CAAC;AAEH;;;;;;;;GAQG;AACH,MAAM,UAAU,YAAY,CAAC,MAAwB;IACnD,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,WAAW;YACd,OAAO,SAAS,CAAC;QACnB,KAAK,cAAc,CAAC;QACpB,KAAK,YAAY,CAAC;QAClB,KAAK,OAAO;YACV,OAAO,WAAW,CAAC;QACrB;YACE,MAAM,IAAI,UAAU,CAAC,uDAAuD,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAClG,CAAC;AACH,CAAC"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * 3×3 linear algebra on Cartesian vectors and matrices. Matrices are row-major: `m[i][j]` is row
3
+ * i, column j, and a matrix acts on a column vector from the left.
4
+ */
5
+ /** A Cartesian vector. */
6
+ export type Vec3 = readonly [number, number, number];
7
+ /** A Cartesian 3×3 matrix, as three rows. */
8
+ export type Mat3 = readonly [Vec3, Vec3, Vec3];
9
+ export declare const IDENTITY: Mat3;
10
+ export declare const INVERSION: Mat3;
11
+ /** The product a·b. */
12
+ export declare function multiply(a: Mat3, b: Mat3): Mat3;
13
+ /** The matrix applied to a vector, m·v. */
14
+ export declare function apply(m: Mat3, v: Vec3): Vec3;
15
+ export declare function transpose(a: Mat3): Mat3;
16
+ export declare function det(a: Mat3): number;
17
+ export declare function trace(a: Mat3): number;
18
+ /** Proper rotation by `angleDeg` degrees about the z axis (counter-clockwise seen from +z). */
19
+ export declare function rotationZ(angleDeg: number): Mat3;
20
+ /** Proper rotation by `angleDeg` degrees about the x axis. */
21
+ export declare function rotationX(angleDeg: number): Mat3;
22
+ /** Proper rotation by `angleDeg` degrees about the y axis. */
23
+ export declare function rotationY(angleDeg: number): Mat3;
24
+ /** Replaces each entry within SNAP_EPSILON of an exact value by that value (this also turns −0 into 0). */
25
+ export declare function snap(a: Mat3): Mat3;
26
+ /** True if all entries agree within EPSILON. */
27
+ export declare function matricesEqual(a: Mat3, b: Mat3): boolean;
28
+ /** The inverse of a regular matrix (by the adjugate); throws for a singular one. */
29
+ export declare function inverse(a: Mat3): Mat3;
30
+ /** The transformed matrix s·a·sᵀ, for an orthogonal s. */
31
+ export declare function conjugate(a: Mat3, s: Mat3): Mat3;
32
+ //# sourceMappingURL=linalg.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"linalg.d.ts","sourceRoot":"","sources":["../src/linalg.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,0BAA0B;AAC1B,MAAM,MAAM,IAAI,GAAG,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAErD,6CAA6C;AAC7C,MAAM,MAAM,IAAI,GAAG,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AAE/C,eAAO,MAAM,QAAQ,EAAE,IAItB,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,IAIvB,CAAC;AAWF,uBAAuB;AACvB,wBAAgB,QAAQ,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,GAAG,IAAI,CAE/C;AAED,2CAA2C;AAC3C,wBAAgB,KAAK,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,GAAG,IAAI,CAM5C;AAED,wBAAgB,SAAS,CAAC,CAAC,EAAE,IAAI,GAAG,IAAI,CAEvC;AAED,wBAAgB,GAAG,CAAC,CAAC,EAAE,IAAI,GAAG,MAAM,CAMnC;AAED,wBAAgB,KAAK,CAAC,CAAC,EAAE,IAAI,GAAG,MAAM,CAErC;AAED,+FAA+F;AAC/F,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAShD;AAED,8DAA8D;AAC9D,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAShD;AAED,8DAA8D;AAC9D,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAShD;AASD,2GAA2G;AAC3G,wBAAgB,IAAI,CAAC,CAAC,EAAE,IAAI,GAAG,IAAI,CAMlC;AAED,gDAAgD;AAChD,wBAAgB,aAAa,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,GAAG,OAAO,CAGvD;AAED,oFAAoF;AACpF,wBAAgB,OAAO,CAAC,CAAC,EAAE,IAAI,GAAG,IAAI,CASrC;AAED,0DAA0D;AAC1D,wBAAgB,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,GAAG,IAAI,CAEhD"}
package/dist/linalg.js ADDED
@@ -0,0 +1,120 @@
1
+ /**
2
+ * 3×3 linear algebra on Cartesian vectors and matrices. Matrices are row-major: `m[i][j]` is row
3
+ * i, column j, and a matrix acts on a column vector from the left.
4
+ */
5
+ import { EPSILON, SNAP_EPSILON } from './tolerances.js';
6
+ export const IDENTITY = [
7
+ [1, 0, 0],
8
+ [0, 1, 0],
9
+ [0, 0, 1],
10
+ ];
11
+ export const INVERSION = [
12
+ [-1, 0, 0],
13
+ [0, -1, 0],
14
+ [0, 0, -1],
15
+ ];
16
+ /** Builds a matrix from a row accessor. */
17
+ function build(f) {
18
+ return [
19
+ [f(0, 0), f(0, 1), f(0, 2)],
20
+ [f(1, 0), f(1, 1), f(1, 2)],
21
+ [f(2, 0), f(2, 1), f(2, 2)],
22
+ ];
23
+ }
24
+ /** The product a·b. */
25
+ export function multiply(a, b) {
26
+ return build((i, j) => a[i][0] * b[0][j] + a[i][1] * b[1][j] + a[i][2] * b[2][j]);
27
+ }
28
+ /** The matrix applied to a vector, m·v. */
29
+ export function apply(m, v) {
30
+ return [
31
+ m[0][0] * v[0] + m[0][1] * v[1] + m[0][2] * v[2],
32
+ m[1][0] * v[0] + m[1][1] * v[1] + m[1][2] * v[2],
33
+ m[2][0] * v[0] + m[2][1] * v[1] + m[2][2] * v[2],
34
+ ];
35
+ }
36
+ export function transpose(a) {
37
+ return build((i, j) => a[j][i]);
38
+ }
39
+ export function det(a) {
40
+ return (a[0][0] * (a[1][1] * a[2][2] - a[1][2] * a[2][1]) -
41
+ a[0][1] * (a[1][0] * a[2][2] - a[1][2] * a[2][0]) +
42
+ a[0][2] * (a[1][0] * a[2][1] - a[1][1] * a[2][0]));
43
+ }
44
+ export function trace(a) {
45
+ return a[0][0] + a[1][1] + a[2][2];
46
+ }
47
+ /** Proper rotation by `angleDeg` degrees about the z axis (counter-clockwise seen from +z). */
48
+ export function rotationZ(angleDeg) {
49
+ const r = (angleDeg * Math.PI) / 180;
50
+ const c = Math.cos(r);
51
+ const s = Math.sin(r);
52
+ return snap([
53
+ [c, -s, 0],
54
+ [s, c, 0],
55
+ [0, 0, 1],
56
+ ]);
57
+ }
58
+ /** Proper rotation by `angleDeg` degrees about the x axis. */
59
+ export function rotationX(angleDeg) {
60
+ const r = (angleDeg * Math.PI) / 180;
61
+ const c = Math.cos(r);
62
+ const s = Math.sin(r);
63
+ return snap([
64
+ [1, 0, 0],
65
+ [0, c, -s],
66
+ [0, s, c],
67
+ ]);
68
+ }
69
+ /** Proper rotation by `angleDeg` degrees about the y axis. */
70
+ export function rotationY(angleDeg) {
71
+ const r = (angleDeg * Math.PI) / 180;
72
+ const c = Math.cos(r);
73
+ const s = Math.sin(r);
74
+ return snap([
75
+ [c, 0, s],
76
+ [0, 1, 0],
77
+ [-s, 0, c],
78
+ ]);
79
+ }
80
+ /**
81
+ * Exact values for snapping: the entries of every point-group operation in the frames of symcrys
82
+ * (0, ±1, and ±1/2, ±√3/2 in the trigonal and hexagonal groups), and ±√2/2, the entries of the
83
+ * 45° setting frame (rotationZ(45), which is snapped as well).
84
+ */
85
+ const SNAP_VALUES = [0, 1, -1, 0.5, -0.5, Math.SQRT1_2, -Math.SQRT1_2, Math.sqrt(3) / 2, -Math.sqrt(3) / 2];
86
+ /** Replaces each entry within SNAP_EPSILON of an exact value by that value (this also turns −0 into 0). */
87
+ export function snap(a) {
88
+ return build((i, j) => {
89
+ const v = a[i][j];
90
+ for (const s of SNAP_VALUES)
91
+ if (Math.abs(v - s) < SNAP_EPSILON)
92
+ return s;
93
+ return v;
94
+ });
95
+ }
96
+ /** True if all entries agree within EPSILON. */
97
+ export function matricesEqual(a, b) {
98
+ for (let i = 0; i < 3; i++)
99
+ for (let j = 0; j < 3; j++)
100
+ if (Math.abs(a[i][j] - b[i][j]) > EPSILON)
101
+ return false;
102
+ return true;
103
+ }
104
+ /** The inverse of a regular matrix (by the adjugate); throws for a singular one. */
105
+ export function inverse(a) {
106
+ const d = det(a);
107
+ if (Math.abs(d) < EPSILON)
108
+ throw new RangeError('inverse: singular matrix');
109
+ const c = (i, j) => {
110
+ const [r0, r1] = [0, 1, 2].filter((k) => k !== i);
111
+ const [s0, s1] = [0, 1, 2].filter((k) => k !== j);
112
+ return a[r0][s0] * a[r1][s1] - a[r0][s1] * a[r1][s0];
113
+ };
114
+ return build((i, j) => ((i + j) % 2 === 0 ? 1 : -1) * (c(j, i) / d));
115
+ }
116
+ /** The transformed matrix s·a·sᵀ, for an orthogonal s. */
117
+ export function conjugate(a, s) {
118
+ return multiply(multiply(s, a), transpose(s));
119
+ }
120
+ //# sourceMappingURL=linalg.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"linalg.js","sourceRoot":"","sources":["../src/linalg.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAQxD,MAAM,CAAC,MAAM,QAAQ,GAA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CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;QAClD,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;QAClD,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;IACvD,CAAC,CAAC;IACF,OAAO,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AACvE,CAAC;AAED,0DAA0D;AAC1D,MAAM,UAAU,SAAS,CAAC,CAAO,EAAE,CAAO;IACxC,OAAO,QAAQ,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;AAChD,CAAC"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Point operations: a Cartesian matrix, optionally combined with time reversal, and the closure of
3
+ * a set of generators into a group.
4
+ */
5
+ import { type Mat3 } from './linalg.js';
6
+ /**
7
+ * A point operation: an orthogonal Cartesian matrix (rotation, rotoinversion, mirror, inversion),
8
+ * combined with time reversal if `timeReversal` is true (a primed operation).
9
+ */
10
+ export interface Operation {
11
+ readonly matrix: Mat3;
12
+ readonly timeReversal: boolean;
13
+ }
14
+ /** No point group has more than 48 operations (96 with time reversal); a closure beyond this is a data error. */
15
+ export declare const MAX_GROUP_ORDER = 200;
16
+ export declare const IDENTITY_OPERATION: Operation;
17
+ /** A unitary operation (no time reversal). */
18
+ export declare function operation(matrix: Mat3): Operation;
19
+ /** The product a·b: first b, then a. */
20
+ export declare function compose(a: Operation, b: Operation): Operation;
21
+ export declare function operationsEqual(a: Operation, b: Operation): boolean;
22
+ /** The operation expressed in a frame rotated by `s` (orthogonal): s·W·sᵀ. */
23
+ export declare function transformOperation(op: Operation, s: Mat3): Operation;
24
+ /**
25
+ * The group generated by `generators`: the identity first, then the generators, then products in
26
+ * the order they are found. The order of the result is therefore fixed by the generators.
27
+ * Throws if the closure exceeds the order of any point group (a sign of wrong input data).
28
+ */
29
+ export declare function closeGroup(generators: readonly Operation[]): Operation[];
30
+ //# sourceMappingURL=operations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operations.d.ts","sourceRoot":"","sources":["../src/operations.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAsD,KAAK,IAAI,EAAE,MAAM,aAAa,CAAC;AAE5F;;;GAGG;AACH,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC;IACtB,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;CAChC;AAED,iHAAiH;AACjH,eAAO,MAAM,eAAe,MAAM,CAAC;AAEnC,eAAO,MAAM,kBAAkB,EAAE,SAAqD,CAAC;AAEvF,8CAA8C;AAC9C,wBAAgB,SAAS,CAAC,MAAM,EAAE,IAAI,GAAG,SAAS,CAEjD;AAED,wCAAwC;AACxC,wBAAgB,OAAO,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,GAAG,SAAS,CAE7D;AAED,wBAAgB,eAAe,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,GAAG,OAAO,CAEnE;AAED,8EAA8E;AAC9E,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE,IAAI,GAAG,SAAS,CAEpE;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,UAAU,EAAE,SAAS,SAAS,EAAE,GAAG,SAAS,EAAE,CAiBxE"}
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Point operations: a Cartesian matrix, optionally combined with time reversal, and the closure of
3
+ * a set of generators into a group.
4
+ */
5
+ import { IDENTITY, conjugate, matricesEqual, multiply, snap } from './linalg.js';
6
+ /** No point group has more than 48 operations (96 with time reversal); a closure beyond this is a data error. */
7
+ export const MAX_GROUP_ORDER = 200;
8
+ export const IDENTITY_OPERATION = { matrix: IDENTITY, timeReversal: false };
9
+ /** A unitary operation (no time reversal). */
10
+ export function operation(matrix) {
11
+ return { matrix, timeReversal: false };
12
+ }
13
+ /** The product a·b: first b, then a. */
14
+ export function compose(a, b) {
15
+ return { matrix: snap(multiply(a.matrix, b.matrix)), timeReversal: a.timeReversal !== b.timeReversal };
16
+ }
17
+ export function operationsEqual(a, b) {
18
+ return a.timeReversal === b.timeReversal && matricesEqual(a.matrix, b.matrix);
19
+ }
20
+ /** The operation expressed in a frame rotated by `s` (orthogonal): s·W·sᵀ. */
21
+ export function transformOperation(op, s) {
22
+ return { matrix: snap(conjugate(op.matrix, s)), timeReversal: op.timeReversal };
23
+ }
24
+ /**
25
+ * The group generated by `generators`: the identity first, then the generators, then products in
26
+ * the order they are found. The order of the result is therefore fixed by the generators.
27
+ * Throws if the closure exceeds the order of any point group (a sign of wrong input data).
28
+ */
29
+ export function closeGroup(generators) {
30
+ const group = [IDENTITY_OPERATION];
31
+ const add = (op) => {
32
+ if (group.some((g) => operationsEqual(g, op)))
33
+ return false;
34
+ if (group.length >= MAX_GROUP_ORDER)
35
+ throw new Error('closeGroup: closure does not terminate; check the generators');
36
+ group.push(op);
37
+ return true;
38
+ };
39
+ for (const g of generators)
40
+ add({ matrix: snap(g.matrix), timeReversal: g.timeReversal });
41
+ for (let i = 0; i < group.length; i++) {
42
+ for (let j = 0; j <= i; j++) {
43
+ add(compose(group[i], group[j]));
44
+ add(compose(group[j], group[i]));
45
+ }
46
+ }
47
+ return group;
48
+ }
49
+ //# sourceMappingURL=operations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operations.js","sourceRoot":"","sources":["../src/operations.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,aAAa,EAAE,QAAQ,EAAE,IAAI,EAAa,MAAM,aAAa,CAAC;AAW5F,iHAAiH;AACjH,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,CAAC;AAEnC,MAAM,CAAC,MAAM,kBAAkB,GAAc,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC;AAEvF,8CAA8C;AAC9C,MAAM,UAAU,SAAS,CAAC,MAAY;IACpC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC;AACzC,CAAC;AAED,wCAAwC;AACxC,MAAM,UAAU,OAAO,CAAC,CAAY,EAAE,CAAY;IAChD,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC,YAAY,KAAK,CAAC,CAAC,YAAY,EAAE,CAAC;AACzG,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,CAAY,EAAE,CAAY;IACxD,OAAO,CAAC,CAAC,YAAY,KAAK,CAAC,CAAC,YAAY,IAAI,aAAa,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC;AAChF,CAAC;AAED,8EAA8E;AAC9E,MAAM,UAAU,kBAAkB,CAAC,EAAa,EAAE,CAAO;IACvD,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,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in the Birss frame (docs/conventions.md); every setting is a rotation of
5
+ * that frame, and the ITC settings are among them. The print anchors and their tests are listed in
6
+ * docs/conventions.md, "Sources"; never derive data here from symcrys output.
7
+ */
8
+ import { type Mat3 } from '../linalg.js';
9
+ import { type Operation } from '../operations.js';
10
+ import type { CrystalSystem } from '../lattice.js';
11
+ /** Keys of the 32 crystal classes: the ITC short symbol of the class (docs/conventions.md, "Keys"). */
12
+ export declare const POINT_GROUP_KEYS: readonly ["1", "-1", "2", "m", "2/m", "222", "mm2", "mmm", "4", "-4", "4/m", "422", "4mm", "-42m", "4/mmm", "3", "-3", "32", "3m", "-3m", "6", "-6", "6/m", "622", "6mm", "-6m2", "6/mmm", "23", "m-3", "432", "-43m", "m-3m"];
13
+ export type PointGroupKey = (typeof POINT_GROUP_KEYS)[number];
14
+ /** A symbol in one convention: the short symbol of the setting and the full symbol, positions separated by spaces. */
15
+ interface SymbolForms {
16
+ readonly short: string;
17
+ readonly full: string;
18
+ }
19
+ export interface SettingData {
20
+ /** Orthogonal matrix s: the setting's operations are s·W·sᵀ for the stored operations W. */
21
+ readonly frame: Mat3;
22
+ /** Monoclinic: the unique axis; orthorhombic mm2: the axis of the twofold rotation. */
23
+ readonly uniqueAxis?: 'a' | 'b' | 'c';
24
+ readonly itc: SymbolForms;
25
+ readonly birss: SymbolForms;
26
+ }
27
+ export interface PointGroupData {
28
+ readonly key: PointGroupKey;
29
+ readonly crystalSystem: CrystalSystem;
30
+ readonly schoenflies: string;
31
+ /** Generators in the stored (Birss) frame, which is setting 1. */
32
+ readonly generators: readonly Operation[];
33
+ /** Setting 1 first; its frame is the identity. */
34
+ readonly settings: readonly SettingData[];
35
+ /** The ITC default setting (1-based). The Birss default is always setting 1. */
36
+ readonly itcDefault: number;
37
+ }
38
+ export declare const POINT_GROUP_DATA: readonly PointGroupData[];
39
+ export {};
40
+ //# sourceMappingURL=data.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data.d.ts","sourceRoot":"","sources":["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