react-cheminfo 0.134.1 → 0.136.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 (454) hide show
  1. package/README.md +13 -0
  2. package/lib/crystal/core/bondGrid.d.ts +26 -0
  3. package/lib/crystal/core/bondGrid.d.ts.map +1 -0
  4. package/lib/crystal/core/bondGrid.js +76 -0
  5. package/lib/crystal/core/bondGrid.js.map +1 -0
  6. package/lib/crystal/core/cellAtoms.d.ts +43 -0
  7. package/lib/crystal/core/cellAtoms.d.ts.map +1 -0
  8. package/lib/crystal/core/cellAtoms.js +70 -0
  9. package/lib/crystal/core/cellAtoms.js.map +1 -0
  10. package/lib/crystal/core/cellBonds.d.ts +21 -0
  11. package/lib/crystal/core/cellBonds.d.ts.map +1 -0
  12. package/lib/crystal/core/cellBonds.js +100 -0
  13. package/lib/crystal/core/cellBonds.js.map +1 -0
  14. package/lib/crystal/core/cif/element.d.ts +9 -0
  15. package/lib/crystal/core/cif/element.d.ts.map +1 -0
  16. package/lib/crystal/core/cif/element.js +41 -0
  17. package/lib/crystal/core/cif/element.js.map +1 -0
  18. package/lib/crystal/core/cif/index.d.ts +4 -0
  19. package/lib/crystal/core/cif/index.d.ts.map +1 -0
  20. package/lib/crystal/core/cif/index.js +3 -0
  21. package/lib/crystal/core/cif/index.js.map +1 -0
  22. package/lib/crystal/core/cif/number.d.ts +27 -0
  23. package/lib/crystal/core/cif/number.d.ts.map +1 -0
  24. package/lib/crystal/core/cif/number.js +57 -0
  25. package/lib/crystal/core/cif/number.js.map +1 -0
  26. package/lib/crystal/core/cif/read.d.ts +12 -0
  27. package/lib/crystal/core/cif/read.d.ts.map +1 -0
  28. package/lib/crystal/core/cif/read.js +183 -0
  29. package/lib/crystal/core/cif/read.js.map +1 -0
  30. package/lib/crystal/core/cif/readGeometry.d.ts +17 -0
  31. package/lib/crystal/core/cif/readGeometry.d.ts.map +1 -0
  32. package/lib/crystal/core/cif/readGeometry.js +93 -0
  33. package/lib/crystal/core/cif/readGeometry.js.map +1 -0
  34. package/lib/crystal/core/cif/tags.d.ts +62 -0
  35. package/lib/crystal/core/cif/tags.d.ts.map +1 -0
  36. package/lib/crystal/core/cif/tags.js +115 -0
  37. package/lib/crystal/core/cif/tags.js.map +1 -0
  38. package/lib/crystal/core/cif/types.d.ts +158 -0
  39. package/lib/crystal/core/cif/types.d.ts.map +1 -0
  40. package/lib/crystal/core/cif/types.js +2 -0
  41. package/lib/crystal/core/cif/types.js.map +1 -0
  42. package/lib/crystal/core/components.d.ts +56 -0
  43. package/lib/crystal/core/components.d.ts.map +1 -0
  44. package/lib/crystal/core/components.js +132 -0
  45. package/lib/crystal/core/components.js.map +1 -0
  46. package/lib/crystal/core/covalentRadii.d.ts +24 -0
  47. package/lib/crystal/core/covalentRadii.d.ts.map +1 -0
  48. package/lib/crystal/core/covalentRadii.js +55 -0
  49. package/lib/crystal/core/covalentRadii.js.map +1 -0
  50. package/lib/crystal/core/disorder.d.ts +59 -0
  51. package/lib/crystal/core/disorder.d.ts.map +1 -0
  52. package/lib/crystal/core/disorder.js +168 -0
  53. package/lib/crystal/core/disorder.js.map +1 -0
  54. package/lib/crystal/core/expand.d.ts +62 -0
  55. package/lib/crystal/core/expand.d.ts.map +1 -0
  56. package/lib/crystal/core/expand.js +61 -0
  57. package/lib/crystal/core/expand.js.map +1 -0
  58. package/lib/crystal/core/index.d.ts +20 -0
  59. package/lib/crystal/core/index.d.ts.map +1 -0
  60. package/lib/crystal/core/index.js +13 -0
  61. package/lib/crystal/core/index.js.map +1 -0
  62. package/lib/crystal/core/moleculeOf.d.ts +31 -0
  63. package/lib/crystal/core/moleculeOf.d.ts.map +1 -0
  64. package/lib/crystal/core/moleculeOf.js +128 -0
  65. package/lib/crystal/core/moleculeOf.js.map +1 -0
  66. package/lib/crystal/core/moleculeTypes.d.ts +80 -0
  67. package/lib/crystal/core/moleculeTypes.d.ts.map +1 -0
  68. package/lib/crystal/core/moleculeTypes.js +2 -0
  69. package/lib/crystal/core/moleculeTypes.js.map +1 -0
  70. package/lib/crystal/core/molecules.d.ts +39 -0
  71. package/lib/crystal/core/molecules.d.ts.map +1 -0
  72. package/lib/crystal/core/molecules.js +106 -0
  73. package/lib/crystal/core/molecules.js.map +1 -0
  74. package/lib/crystal/core/operations.d.ts +19 -0
  75. package/lib/crystal/core/operations.d.ts.map +1 -0
  76. package/lib/crystal/core/operations.js +68 -0
  77. package/lib/crystal/core/operations.js.map +1 -0
  78. package/lib/crystal/core/packing.d.ts +43 -0
  79. package/lib/crystal/core/packing.d.ts.map +1 -0
  80. package/lib/crystal/core/packing.js +89 -0
  81. package/lib/crystal/core/packing.js.map +1 -0
  82. package/lib/crystal/core/periodicBonds.d.ts +57 -0
  83. package/lib/crystal/core/periodicBonds.d.ts.map +1 -0
  84. package/lib/crystal/core/periodicBonds.js +167 -0
  85. package/lib/crystal/core/periodicBonds.js.map +1 -0
  86. package/lib/crystal/core/resolve.d.ts +61 -0
  87. package/lib/crystal/core/resolve.d.ts.map +1 -0
  88. package/lib/crystal/core/resolve.js +149 -0
  89. package/lib/crystal/core/resolve.js.map +1 -0
  90. package/lib/crystal/core/spaceGroups/index.d.ts +5 -0
  91. package/lib/crystal/core/spaceGroups/index.d.ts.map +1 -0
  92. package/lib/crystal/core/spaceGroups/index.js +4 -0
  93. package/lib/crystal/core/spaceGroups/index.js.map +1 -0
  94. package/lib/crystal/core/spaceGroups/spaceGroupOperations.d.ts +14 -0
  95. package/lib/crystal/core/spaceGroups/spaceGroupOperations.d.ts.map +1 -0
  96. package/lib/crystal/core/spaceGroups/spaceGroupOperations.js +24 -0
  97. package/lib/crystal/core/spaceGroups/spaceGroupOperations.js.map +1 -0
  98. package/lib/crystal/core/spaceGroups/spaceGroupRows.d.ts +3 -0
  99. package/lib/crystal/core/spaceGroups/spaceGroupRows.d.ts.map +1 -0
  100. package/lib/crystal/core/spaceGroups/spaceGroupRows.js +536 -0
  101. package/lib/crystal/core/spaceGroups/spaceGroupRows.js.map +1 -0
  102. package/lib/crystal/core/spaceGroups/spaceGroupSymbols.d.ts +43 -0
  103. package/lib/crystal/core/spaceGroups/spaceGroupSymbols.d.ts.map +1 -0
  104. package/lib/crystal/core/spaceGroups/spaceGroupSymbols.js +169 -0
  105. package/lib/crystal/core/spaceGroups/spaceGroupSymbols.js.map +1 -0
  106. package/lib/crystal/core/spaceGroups/spaceGroups.d.ts +78 -0
  107. package/lib/crystal/core/spaceGroups/spaceGroups.d.ts.map +1 -0
  108. package/lib/crystal/core/spaceGroups/spaceGroups.js +83 -0
  109. package/lib/crystal/core/spaceGroups/spaceGroups.js.map +1 -0
  110. package/lib/crystal/core/symmetry/group.d.ts +15 -0
  111. package/lib/crystal/core/symmetry/group.d.ts.map +1 -0
  112. package/lib/crystal/core/symmetry/group.js +37 -0
  113. package/lib/crystal/core/symmetry/group.js.map +1 -0
  114. package/lib/crystal/core/symmetry/index.d.ts +8 -0
  115. package/lib/crystal/core/symmetry/index.d.ts.map +1 -0
  116. package/lib/crystal/core/symmetry/index.js +6 -0
  117. package/lib/crystal/core/symmetry/index.js.map +1 -0
  118. package/lib/crystal/core/symmetry/integerMatrix.d.ts +45 -0
  119. package/lib/crystal/core/symmetry/integerMatrix.d.ts.map +1 -0
  120. package/lib/crystal/core/symmetry/integerMatrix.js +139 -0
  121. package/lib/crystal/core/symmetry/integerMatrix.js.map +1 -0
  122. package/lib/crystal/core/symmetry/lattice.d.ts +64 -0
  123. package/lib/crystal/core/symmetry/lattice.d.ts.map +1 -0
  124. package/lib/crystal/core/symmetry/lattice.js +113 -0
  125. package/lib/crystal/core/symmetry/lattice.js.map +1 -0
  126. package/lib/crystal/core/symmetry/operation.d.ts +91 -0
  127. package/lib/crystal/core/symmetry/operation.d.ts.map +1 -0
  128. package/lib/crystal/core/symmetry/operation.js +184 -0
  129. package/lib/crystal/core/symmetry/operation.js.map +1 -0
  130. package/lib/crystal/core/symmetry/parseOperation.d.ts +18 -0
  131. package/lib/crystal/core/symmetry/parseOperation.d.ts.map +1 -0
  132. package/lib/crystal/core/symmetry/parseOperation.js +145 -0
  133. package/lib/crystal/core/symmetry/parseOperation.js.map +1 -0
  134. package/lib/crystal/core/symmetry/types.d.ts +29 -0
  135. package/lib/crystal/core/symmetry/types.d.ts.map +1 -0
  136. package/lib/crystal/core/symmetry/types.js +5 -0
  137. package/lib/crystal/core/symmetry/types.js.map +1 -0
  138. package/lib/crystal/core/symmetryClasses.d.ts +28 -0
  139. package/lib/crystal/core/symmetryClasses.d.ts.map +1 -0
  140. package/lib/crystal/core/symmetryClasses.js +93 -0
  141. package/lib/crystal/core/symmetryClasses.js.map +1 -0
  142. package/lib/crystal.d.ts +12 -0
  143. package/lib/crystal.d.ts.map +1 -0
  144. package/lib/crystal.js +12 -0
  145. package/lib/crystal.js.map +1 -0
  146. package/lib/crystal3d/core/cellClip.d.ts +46 -0
  147. package/lib/crystal3d/core/cellClip.d.ts.map +1 -0
  148. package/lib/crystal3d/core/cellClip.js +198 -0
  149. package/lib/crystal3d/core/cellClip.js.map +1 -0
  150. package/lib/crystal3d/core/cellGeometry.d.ts +63 -0
  151. package/lib/crystal3d/core/cellGeometry.d.ts.map +1 -0
  152. package/lib/crystal3d/core/cellGeometry.js +153 -0
  153. package/lib/crystal3d/core/cellGeometry.js.map +1 -0
  154. package/lib/crystal3d/core/cellStack.d.ts +51 -0
  155. package/lib/crystal3d/core/cellStack.d.ts.map +1 -0
  156. package/lib/crystal3d/core/cellStack.js +79 -0
  157. package/lib/crystal3d/core/cellStack.js.map +1 -0
  158. package/lib/crystal3d/core/crystalView.d.ts +71 -0
  159. package/lib/crystal3d/core/crystalView.d.ts.map +1 -0
  160. package/lib/crystal3d/core/crystalView.js +48 -0
  161. package/lib/crystal3d/core/crystalView.js.map +1 -0
  162. package/lib/crystal3d/core/drawingSet.d.ts +31 -0
  163. package/lib/crystal3d/core/drawingSet.d.ts.map +1 -0
  164. package/lib/crystal3d/core/drawingSet.js +63 -0
  165. package/lib/crystal3d/core/drawingSet.js.map +1 -0
  166. package/lib/crystal3d/core/elementDrawing.d.ts +50 -0
  167. package/lib/crystal3d/core/elementDrawing.d.ts.map +1 -0
  168. package/lib/crystal3d/core/elementDrawing.js +100 -0
  169. package/lib/crystal3d/core/elementDrawing.js.map +1 -0
  170. package/lib/crystal3d/core/elementExtent.d.ts +42 -0
  171. package/lib/crystal3d/core/elementExtent.d.ts.map +1 -0
  172. package/lib/crystal3d/core/elementExtent.js +56 -0
  173. package/lib/crystal3d/core/elementExtent.js.map +1 -0
  174. package/lib/crystal3d/core/elementLabels.d.ts +31 -0
  175. package/lib/crystal3d/core/elementLabels.d.ts.map +1 -0
  176. package/lib/crystal3d/core/elementLabels.js +99 -0
  177. package/lib/crystal3d/core/elementLabels.js.map +1 -0
  178. package/lib/crystal3d/core/elementShapes.d.ts +43 -0
  179. package/lib/crystal3d/core/elementShapes.d.ts.map +1 -0
  180. package/lib/crystal3d/core/elementShapes.js +115 -0
  181. package/lib/crystal3d/core/elementShapes.js.map +1 -0
  182. package/lib/crystal3d/core/frame.d.ts +36 -0
  183. package/lib/crystal3d/core/frame.d.ts.map +1 -0
  184. package/lib/crystal3d/core/frame.js +35 -0
  185. package/lib/crystal3d/core/frame.js.map +1 -0
  186. package/lib/crystal3d/core/framing.d.ts +41 -0
  187. package/lib/crystal3d/core/framing.d.ts.map +1 -0
  188. package/lib/crystal3d/core/framing.js +79 -0
  189. package/lib/crystal3d/core/framing.js.map +1 -0
  190. package/lib/crystal3d/core/index.d.ts +42 -0
  191. package/lib/crystal3d/core/index.d.ts.map +1 -0
  192. package/lib/crystal3d/core/index.js +29 -0
  193. package/lib/crystal3d/core/index.js.map +1 -0
  194. package/lib/crystal3d/core/labelText.d.ts +19 -0
  195. package/lib/crystal3d/core/labelText.d.ts.map +1 -0
  196. package/lib/crystal3d/core/labelText.js +42 -0
  197. package/lib/crystal3d/core/labelText.js.map +1 -0
  198. package/lib/crystal3d/core/latticeBasis.d.ts +49 -0
  199. package/lib/crystal3d/core/latticeBasis.d.ts.map +1 -0
  200. package/lib/crystal3d/core/latticeBasis.js +89 -0
  201. package/lib/crystal3d/core/latticeBasis.js.map +1 -0
  202. package/lib/crystal3d/core/mat3.d.ts +68 -0
  203. package/lib/crystal3d/core/mat3.d.ts.map +1 -0
  204. package/lib/crystal3d/core/mat3.js +146 -0
  205. package/lib/crystal3d/core/mat3.js.map +1 -0
  206. package/lib/crystal3d/core/operationMatrix.d.ts +44 -0
  207. package/lib/crystal3d/core/operationMatrix.d.ts.map +1 -0
  208. package/lib/crystal3d/core/operationMatrix.js +172 -0
  209. package/lib/crystal3d/core/operationMatrix.js.map +1 -0
  210. package/lib/crystal3d/core/orientation.d.ts +62 -0
  211. package/lib/crystal3d/core/orientation.d.ts.map +1 -0
  212. package/lib/crystal3d/core/orientation.js +166 -0
  213. package/lib/crystal3d/core/orientation.js.map +1 -0
  214. package/lib/crystal3d/core/palette.d.ts +24 -0
  215. package/lib/crystal3d/core/palette.d.ts.map +1 -0
  216. package/lib/crystal3d/core/palette.js +34 -0
  217. package/lib/crystal3d/core/palette.js.map +1 -0
  218. package/lib/crystal3d/core/primitives.d.ts +133 -0
  219. package/lib/crystal3d/core/primitives.d.ts.map +1 -0
  220. package/lib/crystal3d/core/primitives.js +80 -0
  221. package/lib/crystal3d/core/primitives.js.map +1 -0
  222. package/lib/crystal3d/core/structureText.d.ts +20 -0
  223. package/lib/crystal3d/core/structureText.d.ts.map +1 -0
  224. package/lib/crystal3d/core/structureText.js +37 -0
  225. package/lib/crystal3d/core/structureText.js.map +1 -0
  226. package/lib/crystal3d/core/supercell.d.ts +20 -0
  227. package/lib/crystal3d/core/supercell.d.ts.map +1 -0
  228. package/lib/crystal3d/core/supercell.js +35 -0
  229. package/lib/crystal3d/core/supercell.js.map +1 -0
  230. package/lib/crystal3d/core/types.d.ts +166 -0
  231. package/lib/crystal3d/core/types.d.ts.map +1 -0
  232. package/lib/crystal3d/core/types.js +10 -0
  233. package/lib/crystal3d/core/types.js.map +1 -0
  234. package/lib/crystal3d/core/vec3.d.ts +75 -0
  235. package/lib/crystal3d/core/vec3.d.ts.map +1 -0
  236. package/lib/crystal3d/core/vec3.js +119 -0
  237. package/lib/crystal3d/core/vec3.js.map +1 -0
  238. package/lib/crystal3d/ui/CrystalCanvas3D.d.ts +52 -0
  239. package/lib/crystal3d/ui/CrystalCanvas3D.d.ts.map +1 -0
  240. package/lib/crystal3d/ui/CrystalCanvas3D.js +242 -0
  241. package/lib/crystal3d/ui/CrystalCanvas3D.js.map +1 -0
  242. package/lib/crystal3d/ui/CrystalStructureView.d.ts +17 -0
  243. package/lib/crystal3d/ui/CrystalStructureView.d.ts.map +1 -0
  244. package/lib/crystal3d/ui/CrystalStructureView.js +76 -0
  245. package/lib/crystal3d/ui/CrystalStructureView.js.map +1 -0
  246. package/lib/crystal3d/ui/CrystalStructureViewer.d.ts +22 -0
  247. package/lib/crystal3d/ui/CrystalStructureViewer.d.ts.map +1 -0
  248. package/lib/crystal3d/ui/CrystalStructureViewer.js +29 -0
  249. package/lib/crystal3d/ui/CrystalStructureViewer.js.map +1 -0
  250. package/lib/crystal3d/ui/CrystalViewControls.d.ts +25 -0
  251. package/lib/crystal3d/ui/CrystalViewControls.d.ts.map +1 -0
  252. package/lib/crystal3d/ui/CrystalViewControls.js +22 -0
  253. package/lib/crystal3d/ui/CrystalViewControls.js.map +1 -0
  254. package/lib/crystal3d/ui/CrystalViewer3D.d.ts +72 -0
  255. package/lib/crystal3d/ui/CrystalViewer3D.d.ts.map +1 -0
  256. package/lib/crystal3d/ui/CrystalViewer3D.js +70 -0
  257. package/lib/crystal3d/ui/CrystalViewer3D.js.map +1 -0
  258. package/lib/crystal3d/ui/crystalScene.d.ts +91 -0
  259. package/lib/crystal3d/ui/crystalScene.d.ts.map +1 -0
  260. package/lib/crystal3d/ui/crystalScene.js +10 -0
  261. package/lib/crystal3d/ui/crystalScene.js.map +1 -0
  262. package/lib/crystal3d/ui/crystalStructureViewerProps.d.ts +52 -0
  263. package/lib/crystal3d/ui/crystalStructureViewerProps.d.ts.map +1 -0
  264. package/lib/crystal3d/ui/crystalStructureViewerProps.js +2 -0
  265. package/lib/crystal3d/ui/crystalStructureViewerProps.js.map +1 -0
  266. package/lib/crystal3d/ui/index.d.ts +16 -0
  267. package/lib/crystal3d/ui/index.d.ts.map +1 -0
  268. package/lib/crystal3d/ui/index.js +12 -0
  269. package/lib/crystal3d/ui/index.js.map +1 -0
  270. package/lib/crystal3d/ui/useCrystalCaption.d.ts +14 -0
  271. package/lib/crystal3d/ui/useCrystalCaption.d.ts.map +1 -0
  272. package/lib/crystal3d/ui/useCrystalCaption.js +32 -0
  273. package/lib/crystal3d/ui/useCrystalCaption.js.map +1 -0
  274. package/lib/crystal3d/viewer/animate.d.ts +49 -0
  275. package/lib/crystal3d/viewer/animate.d.ts.map +1 -0
  276. package/lib/crystal3d/viewer/animate.js +83 -0
  277. package/lib/crystal3d/viewer/animate.js.map +1 -0
  278. package/lib/crystal3d/viewer/camera.d.ts +44 -0
  279. package/lib/crystal3d/viewer/camera.d.ts.map +1 -0
  280. package/lib/crystal3d/viewer/camera.js +103 -0
  281. package/lib/crystal3d/viewer/camera.js.map +1 -0
  282. package/lib/crystal3d/viewer/index.d.ts +13 -0
  283. package/lib/crystal3d/viewer/index.d.ts.map +1 -0
  284. package/lib/crystal3d/viewer/index.js +8 -0
  285. package/lib/crystal3d/viewer/index.js.map +1 -0
  286. package/lib/crystal3d/viewer/layerRegistry.d.ts +24 -0
  287. package/lib/crystal3d/viewer/layerRegistry.d.ts.map +1 -0
  288. package/lib/crystal3d/viewer/layerRegistry.js +39 -0
  289. package/lib/crystal3d/viewer/layerRegistry.js.map +1 -0
  290. package/lib/crystal3d/viewer/meshPrimitives.d.ts +13 -0
  291. package/lib/crystal3d/viewer/meshPrimitives.d.ts.map +1 -0
  292. package/lib/crystal3d/viewer/meshPrimitives.js +76 -0
  293. package/lib/crystal3d/viewer/meshPrimitives.js.map +1 -0
  294. package/lib/crystal3d/viewer/plugin.d.ts +133 -0
  295. package/lib/crystal3d/viewer/plugin.d.ts.map +1 -0
  296. package/lib/crystal3d/viewer/plugin.js +181 -0
  297. package/lib/crystal3d/viewer/plugin.js.map +1 -0
  298. package/lib/crystal3d/viewer/renderCell.d.ts +43 -0
  299. package/lib/crystal3d/viewer/renderCell.d.ts.map +1 -0
  300. package/lib/crystal3d/viewer/renderCell.js +53 -0
  301. package/lib/crystal3d/viewer/renderCell.js.map +1 -0
  302. package/lib/crystal3d/viewer/renderElements.d.ts +54 -0
  303. package/lib/crystal3d/viewer/renderElements.d.ts.map +1 -0
  304. package/lib/crystal3d/viewer/renderElements.js +77 -0
  305. package/lib/crystal3d/viewer/renderElements.js.map +1 -0
  306. package/lib/crystal3d/viewer/renderStructure.d.ts +55 -0
  307. package/lib/crystal3d/viewer/renderStructure.d.ts.map +1 -0
  308. package/lib/crystal3d/viewer/renderStructure.js +103 -0
  309. package/lib/crystal3d/viewer/renderStructure.js.map +1 -0
  310. package/lib/crystal3d/viewer/sceneParts.d.ts +32 -0
  311. package/lib/crystal3d/viewer/sceneParts.d.ts.map +1 -0
  312. package/lib/crystal3d/viewer/sceneParts.js +77 -0
  313. package/lib/crystal3d/viewer/sceneParts.js.map +1 -0
  314. package/lib/crystal3d/viewer/shapeLayer.d.ts +41 -0
  315. package/lib/crystal3d/viewer/shapeLayer.d.ts.map +1 -0
  316. package/lib/crystal3d/viewer/shapeLayer.js +57 -0
  317. package/lib/crystal3d/viewer/shapeLayer.js.map +1 -0
  318. package/lib/crystal3d/viewer/textLayer.d.ts +21 -0
  319. package/lib/crystal3d/viewer/textLayer.d.ts.map +1 -0
  320. package/lib/crystal3d/viewer/textLayer.js +59 -0
  321. package/lib/crystal3d/viewer/textLayer.js.map +1 -0
  322. package/lib/crystal3d/viewer/viewer.d.ts +110 -0
  323. package/lib/crystal3d/viewer/viewer.d.ts.map +1 -0
  324. package/lib/crystal3d/viewer/viewer.js +157 -0
  325. package/lib/crystal3d/viewer/viewer.js.map +1 -0
  326. package/lib/crystal3d.d.ts +12 -0
  327. package/lib/crystal3d.d.ts.map +1 -0
  328. package/lib/crystal3d.js +12 -0
  329. package/lib/crystal3d.js.map +1 -0
  330. package/lib/i18n/core/chromeCatalog.d.ts +1 -1
  331. package/lib/i18n/core/chromeCatalog.d.ts.map +1 -1
  332. package/lib/locales/de.json +19 -1
  333. package/lib/locales/en.json +19 -1
  334. package/lib/locales/es.json +19 -1
  335. package/lib/locales/fr.json +19 -1
  336. package/lib/locales/it.json +19 -1
  337. package/lib/molecule3d/ui/MoleculeCanvas3D.d.ts.map +1 -1
  338. package/lib/molecule3d/ui/MoleculeCanvas3D.js +16 -27
  339. package/lib/molecule3d/ui/MoleculeCanvas3D.js.map +1 -1
  340. package/lib/molstar/bonds/bondRule.d.ts +16 -0
  341. package/lib/molstar/bonds/bondRule.d.ts.map +1 -0
  342. package/lib/molstar/bonds/bondRule.js +23 -0
  343. package/lib/molstar/bonds/bondRule.js.map +1 -0
  344. package/lib/molstar/bonds/index.d.ts +9 -0
  345. package/lib/molstar/bonds/index.d.ts.map +1 -0
  346. package/lib/molstar/bonds/index.js +9 -0
  347. package/lib/molstar/bonds/index.js.map +1 -0
  348. package/lib/molstar/ui/MolstarToolbar.d.ts +47 -0
  349. package/lib/molstar/ui/MolstarToolbar.d.ts.map +1 -0
  350. package/lib/molstar/ui/MolstarToolbar.js +28 -0
  351. package/lib/molstar/ui/MolstarToolbar.js.map +1 -0
  352. package/lib/molstar/ui/index.d.ts +10 -0
  353. package/lib/molstar/ui/index.d.ts.map +1 -0
  354. package/lib/molstar/ui/index.js +8 -0
  355. package/lib/molstar/ui/index.js.map +1 -0
  356. package/lib/molstar/ui/useMolstarTools.d.ts +63 -0
  357. package/lib/molstar/ui/useMolstarTools.d.ts.map +1 -0
  358. package/lib/molstar/ui/useMolstarTools.js +36 -0
  359. package/lib/molstar/ui/useMolstarTools.js.map +1 -0
  360. package/package.json +4 -1
  361. package/src/crystal/core/bondGrid.ts +98 -0
  362. package/src/crystal/core/cellAtoms.ts +106 -0
  363. package/src/crystal/core/cellBonds.ts +121 -0
  364. package/src/crystal/core/cif/element.ts +40 -0
  365. package/src/crystal/core/cif/index.ts +12 -0
  366. package/src/crystal/core/cif/number.ts +62 -0
  367. package/src/crystal/core/cif/read.ts +218 -0
  368. package/src/crystal/core/cif/readGeometry.ts +104 -0
  369. package/src/crystal/core/cif/tags.ts +143 -0
  370. package/src/crystal/core/cif/types.ts +164 -0
  371. package/src/crystal/core/components.ts +183 -0
  372. package/src/crystal/core/covalentRadii.ts +56 -0
  373. package/src/crystal/core/disorder.ts +190 -0
  374. package/src/crystal/core/expand.ts +105 -0
  375. package/src/crystal/core/index.ts +46 -0
  376. package/src/crystal/core/moleculeOf.ts +169 -0
  377. package/src/crystal/core/moleculeTypes.ts +85 -0
  378. package/src/crystal/core/molecules.ts +128 -0
  379. package/src/crystal/core/operations.ts +79 -0
  380. package/src/crystal/core/packing.ts +116 -0
  381. package/src/crystal/core/periodicBonds.ts +234 -0
  382. package/src/crystal/core/resolve.ts +187 -0
  383. package/src/crystal/core/spaceGroups/index.ts +16 -0
  384. package/src/crystal/core/spaceGroups/spaceGroupOperations.ts +32 -0
  385. package/src/crystal/core/spaceGroups/spaceGroupRows.ts +536 -0
  386. package/src/crystal/core/spaceGroups/spaceGroupSymbols.ts +179 -0
  387. package/src/crystal/core/spaceGroups/spaceGroups.ts +154 -0
  388. package/src/crystal/core/symmetry/group.ts +42 -0
  389. package/src/crystal/core/symmetry/index.ts +23 -0
  390. package/src/crystal/core/symmetry/integerMatrix.ts +153 -0
  391. package/src/crystal/core/symmetry/lattice.ts +152 -0
  392. package/src/crystal/core/symmetry/operation.ts +223 -0
  393. package/src/crystal/core/symmetry/parseOperation.ts +180 -0
  394. package/src/crystal/core/symmetry/types.ts +32 -0
  395. package/src/crystal/core/symmetryClasses.ts +105 -0
  396. package/src/crystal.ts +12 -0
  397. package/src/crystal3d/core/cellClip.ts +229 -0
  398. package/src/crystal3d/core/cellGeometry.ts +193 -0
  399. package/src/crystal3d/core/cellStack.ts +87 -0
  400. package/src/crystal3d/core/crystalView.ts +114 -0
  401. package/src/crystal3d/core/drawingSet.ts +71 -0
  402. package/src/crystal3d/core/elementDrawing.ts +147 -0
  403. package/src/crystal3d/core/elementExtent.ts +81 -0
  404. package/src/crystal3d/core/elementLabels.ts +130 -0
  405. package/src/crystal3d/core/elementShapes.ts +141 -0
  406. package/src/crystal3d/core/frame.ts +56 -0
  407. package/src/crystal3d/core/framing.ts +101 -0
  408. package/src/crystal3d/core/index.ts +132 -0
  409. package/src/crystal3d/core/labelText.ts +44 -0
  410. package/src/crystal3d/core/latticeBasis.ts +110 -0
  411. package/src/crystal3d/core/mat3.ts +163 -0
  412. package/src/crystal3d/core/operationMatrix.ts +255 -0
  413. package/src/crystal3d/core/orientation.ts +229 -0
  414. package/src/crystal3d/core/palette.ts +43 -0
  415. package/src/crystal3d/core/primitives.ts +183 -0
  416. package/src/crystal3d/core/structureText.ts +43 -0
  417. package/src/crystal3d/core/supercell.ts +40 -0
  418. package/src/crystal3d/core/types.ts +186 -0
  419. package/src/crystal3d/core/vec3.ts +127 -0
  420. package/src/crystal3d/ui/CrystalCanvas3D.tsx +384 -0
  421. package/src/crystal3d/ui/CrystalStructureView.tsx +148 -0
  422. package/src/crystal3d/ui/CrystalStructureViewer.tsx +39 -0
  423. package/src/crystal3d/ui/CrystalViewControls.tsx +100 -0
  424. package/src/crystal3d/ui/CrystalViewer3D.tsx +183 -0
  425. package/src/crystal3d/ui/crystalScene.ts +100 -0
  426. package/src/crystal3d/ui/crystalStructureViewerProps.ts +54 -0
  427. package/src/crystal3d/ui/index.ts +20 -0
  428. package/src/crystal3d/ui/useCrystalCaption.ts +38 -0
  429. package/src/crystal3d/viewer/animate.ts +113 -0
  430. package/src/crystal3d/viewer/camera.ts +139 -0
  431. package/src/crystal3d/viewer/index.ts +13 -0
  432. package/src/crystal3d/viewer/layerRegistry.ts +47 -0
  433. package/src/crystal3d/viewer/meshPrimitives.ts +102 -0
  434. package/src/crystal3d/viewer/plugin.ts +258 -0
  435. package/src/crystal3d/viewer/renderCell.ts +98 -0
  436. package/src/crystal3d/viewer/renderElements.ts +121 -0
  437. package/src/crystal3d/viewer/renderStructure.ts +144 -0
  438. package/src/crystal3d/viewer/sceneParts.ts +119 -0
  439. package/src/crystal3d/viewer/shapeLayer.ts +108 -0
  440. package/src/crystal3d/viewer/textLayer.ts +85 -0
  441. package/src/crystal3d/viewer/viewer.ts +207 -0
  442. package/src/crystal3d.ts +12 -0
  443. package/src/locales/de.json +19 -1
  444. package/src/locales/en.json +19 -1
  445. package/src/locales/es.json +19 -1
  446. package/src/locales/fr.json +19 -1
  447. package/src/locales/it.json +19 -1
  448. package/src/molecule3d/ui/MoleculeCanvas3D.tsx +45 -71
  449. package/src/molstar/bonds/bondRule.ts +34 -0
  450. package/src/molstar/bonds/index.ts +9 -0
  451. package/src/molstar/ui/MolstarToolbar.tsx +103 -0
  452. package/src/molstar/ui/index.ts +14 -0
  453. package/src/molstar/ui/useMolstarTools.ts +98 -0
  454. package/styles/chrome.css +90 -0
@@ -0,0 +1,179 @@
1
+ import type { SpaceGroupSetting } from './spaceGroups.ts';
2
+ import { SPACE_GROUP_SETTINGS } from './spaceGroups.ts';
3
+
4
+ /**
5
+ * Every setting a query names, the standard setting first.
6
+ *
7
+ * The query is an International Tables number, a Hermann–Mauguin symbol in any
8
+ * spelling the wild produces, or a Hall symbol. Ambiguity is not an error: a
9
+ * bare `Fd-3m` genuinely names two coordinate conventions, and both come back
10
+ * so the page can say so and let the reader pick.
11
+ *
12
+ * ```
13
+ * resolveSpaceGroups('Fm-3m') // [225/0]
14
+ * resolveSpaceGroups('F m -3 m') // the same setting
15
+ * resolveSpaceGroups('Fm3m') // and again, written without the bar
16
+ * resolveSpaceGroups('P2(1)/c') // the nine settings of 14, P 1 21/c 1 first
17
+ * resolveSpaceGroups('R-3c:R') // 167/1, the rhombohedral axes
18
+ * resolveSpaceGroups('Ccca') // 68, under its pre-2002 spelling
19
+ * ```
20
+ * @param query - A number, or a symbol with an optional `:1`, `:2`, `:H` or
21
+ * `:R` qualifier. A qualifier that matches nothing is ignored rather than
22
+ * obeyed, so a link written before a spelling changed still opens.
23
+ * @returns The matching settings, or an empty array when nothing matches.
24
+ */
25
+ export function resolveSpaceGroups(
26
+ query: string | number,
27
+ ): readonly SpaceGroupSetting[] {
28
+ if (typeof query === 'number') return settingsOfNumber(query);
29
+ const { symbol, qualifier } = splitQualifier(query.trim());
30
+ const number = /^\d+$/.test(symbol) ? Number(symbol) : null;
31
+ const candidates =
32
+ number === null
33
+ ? (index().get(normalizeSpaceGroupSymbol(symbol)) ?? [])
34
+ : settingsOfNumber(number);
35
+ return applyQualifier(candidates, qualifier);
36
+ }
37
+
38
+ /**
39
+ * The one setting a query names, or `null`. When several match, the first —
40
+ * which is the lowest variant of the lowest number, the setting the site opens
41
+ * by default. Use {@link resolveSpaceGroups} when the ambiguity matters.
42
+ * @param query - A number, or a symbol in any spelling.
43
+ * @returns The setting, or `null`.
44
+ */
45
+ export function resolveSpaceGroup(
46
+ query: string | number,
47
+ ): SpaceGroupSetting | null {
48
+ return resolveSpaceGroups(query)[0] ?? null;
49
+ }
50
+
51
+ /**
52
+ * A Hermann–Mauguin or Hall symbol reduced to the form the index is keyed on:
53
+ * upper case, no spaces, no `_`, no parentheses, `.` read as `/`, and a
54
+ * combining overbar read as a leading minus.
55
+ *
56
+ * It turns `P2(1)/c`, `P2_1/c`, `P 21/c` and `P 63.m m c`'s siblings into one
57
+ * string, which is what lets a CIF written by any program find its group.
58
+ * @param symbol - A Hermann–Mauguin or Hall symbol.
59
+ * @returns The key the catalogue is indexed on.
60
+ */
61
+ export function normalizeSpaceGroupSymbol(symbol: string): string {
62
+ return symbol
63
+ .replaceAll(/(?<digit>\d)[̄̅¯]/gu, '-$<digit>')
64
+ .replaceAll(/[\s_()]/g, '')
65
+ .replaceAll('.', '/')
66
+ .toUpperCase();
67
+ }
68
+
69
+ /**
70
+ * The settings of one International Tables number, variant 0 first.
71
+ * @param number - The International Tables number.
72
+ * @returns The settings, variant 0 first.
73
+ */
74
+ function settingsOfNumber(number: number): readonly SpaceGroupSetting[] {
75
+ const found: SpaceGroupSetting[] = [];
76
+ for (const setting of SPACE_GROUP_SETTINGS) {
77
+ if (setting.number === number) found.push(setting);
78
+ }
79
+ return found;
80
+ }
81
+
82
+ /**
83
+ * The trailing setting qualifier, in any of the spellings in use: `R-3c:H`,
84
+ * `R-3cH`, `Fd-3m:2`, `Fd-3m S`.
85
+ *
86
+ * The `S` and `Z` letters of the older literature are recognised and dropped
87
+ * rather than read as an origin: which of the two they name is a convention
88
+ * this repository has no source for, and guessing it would silently move every
89
+ * atom of a diamond-type structure by (1/8, 1/8, 1/8).
90
+ * @param query - The symbol, as the file writes it.
91
+ * @returns The symbol, and the qualifier when there is one.
92
+ */
93
+ function splitQualifier(query: string): {
94
+ symbol: string;
95
+ qualifier: string | null;
96
+ } {
97
+ const tagged = /^(?<symbol>.*?)\s*:\s*(?<tag>[12HRhr])$/.exec(query);
98
+ if (tagged !== null) {
99
+ return {
100
+ symbol: tagged.groups?.symbol ?? '',
101
+ qualifier: (tagged.groups?.tag ?? '').toUpperCase(),
102
+ };
103
+ }
104
+ const lettered = /^(?<symbol>.*\S)\s*(?<tag>[SZsz])$/.exec(query);
105
+ if (lettered !== null) {
106
+ return { symbol: lettered.groups?.symbol ?? '', qualifier: null };
107
+ }
108
+ const glued = /^(?<symbol>.*-3.*?)(?<tag>[HRhr])$/.exec(query);
109
+ if (glued !== null) {
110
+ return {
111
+ symbol: glued.groups?.symbol ?? '',
112
+ qualifier: (glued.groups?.tag ?? '').toUpperCase(),
113
+ };
114
+ }
115
+ return { symbol: query, qualifier: null };
116
+ }
117
+
118
+ function applyQualifier(
119
+ candidates: readonly SpaceGroupSetting[],
120
+ qualifier: string | null,
121
+ ): readonly SpaceGroupSetting[] {
122
+ if (qualifier === null) return candidates;
123
+ const kept = candidates.filter((setting) =>
124
+ qualifier === '1' || qualifier === '2'
125
+ ? setting.originChoice === Number(qualifier)
126
+ : setting.axes === (qualifier === 'H' ? 'hexagonal' : 'rhombohedral'),
127
+ );
128
+ return kept.length === 0 ? candidates : kept;
129
+ }
130
+
131
+ let cached: Map<string, SpaceGroupSetting[]> | null = null;
132
+
133
+ /**
134
+ * Every spelling of every setting, built once. A key is registered only when it
135
+ * is free, so a Hall symbol never displaces a Hermann–Mauguin one and the
136
+ * bar-less `P1` keeps meaning group 1 rather than `P-1`.
137
+ * @returns Normalized symbol to the settings it names.
138
+ */
139
+ function index(): ReadonlyMap<string, SpaceGroupSetting[]> {
140
+ if (cached !== null) return cached;
141
+ const built = new Map<string, SpaceGroupSetting[]>();
142
+ const add = (key: string, setting: SpaceGroupSetting) => {
143
+ if (key.length === 0) return;
144
+ const list = built.get(key);
145
+ if (list === undefined) built.set(key, [setting]);
146
+ else if (!list.includes(setting)) list.push(setting);
147
+ };
148
+ for (const pass of ['symbols', 'hall', 'barless'] as const) {
149
+ for (const setting of SPACE_GROUP_SETTINGS) {
150
+ if (pass === 'symbols') {
151
+ for (const symbol of [
152
+ setting.hmShort,
153
+ setting.hmFull,
154
+ setting.hmSetting,
155
+ setting.hmLegacy ?? '',
156
+ ]) {
157
+ add(normalizeSpaceGroupSymbol(symbol), setting);
158
+ }
159
+ } else if (pass === 'hall') {
160
+ if (setting.hall !== null) {
161
+ const key = normalizeSpaceGroupSymbol(setting.hall);
162
+ if (!built.has(key)) add(key, setting);
163
+ }
164
+ } else {
165
+ for (const symbol of [
166
+ setting.hmShort,
167
+ setting.hmFull,
168
+ setting.hmSetting,
169
+ setting.hmLegacy ?? '',
170
+ ]) {
171
+ const key = normalizeSpaceGroupSymbol(symbol).replaceAll('-', '');
172
+ if (!built.has(key)) add(key, setting);
173
+ }
174
+ }
175
+ }
176
+ }
177
+ cached = built;
178
+ return built;
179
+ }
@@ -0,0 +1,154 @@
1
+ import { SPACE_GROUP_ROWS } from './spaceGroupRows.ts';
2
+
3
+ /** The seven crystal systems, named by the point group rather than the lattice. */
4
+ export type CrystalSystem =
5
+ | 'triclinic'
6
+ | 'monoclinic'
7
+ | 'orthorhombic'
8
+ | 'tetragonal'
9
+ | 'trigonal'
10
+ | 'hexagonal'
11
+ | 'cubic';
12
+
13
+ /** The Bravais letter a Hermann–Mauguin symbol opens with. */
14
+ export type Centring = 'P' | 'A' | 'B' | 'C' | 'I' | 'F' | 'R';
15
+
16
+ /**
17
+ * One setting of one space group: a choice of axes, origin and cell for the
18
+ * same group, so the same crystal is described by the same operations written
19
+ * in a different basis.
20
+ *
21
+ * A space group is addressed by its **number**, and a setting by
22
+ * `number/variant`; no Hermann–Mauguin string is ever an identity, because the
23
+ * spellings in the wild are not stable. `variant` is dense from 0 within a
24
+ * number, and variant 0 is the setting the site opens by default.
25
+ */
26
+ export interface SpaceGroupSetting {
27
+ /** International Tables number, 1 to 230. */
28
+ readonly number: number;
29
+ /** Index of this setting within its number, dense from 0. */
30
+ readonly variant: number;
31
+ /** The standard short symbol of the number: `P 21/c`, `F m -3 m`. */
32
+ readonly hmShort: string;
33
+ /** The International Tables full symbol of the number: `P 1 21/c 1`. */
34
+ readonly hmFull: string;
35
+ /** This setting's own symbol: `P 1 1 21/a`. Equal to `hmFull` above number 74. */
36
+ readonly hmSetting: string;
37
+ /** The pre-2002 spelling of `hmShort` — `C c c a` for `C c c e`. Five numbers have one. */
38
+ readonly hmLegacy: string | null;
39
+ /** The Hall symbol, the one string that pins a setting. Absent above number 74. */
40
+ readonly hall: string | null;
41
+ readonly crystalSystem: CrystalSystem;
42
+ readonly centring: Centring;
43
+ /** Which axes an `R` group is written on. `null` for every other group. */
44
+ readonly axes: 'hexagonal' | 'rhombohedral' | null;
45
+ /** Which of the two origins this setting takes, when the group offers a choice. */
46
+ readonly originChoice: 1 | 2 | null;
47
+ /** The axis a monoclinic setting is built on. `null` for every other system. */
48
+ readonly uniqueAxis: 'a' | 'b' | 'c' | null;
49
+ /** The crystal class, in Hermann–Mauguin: `2/m`, `-42m`, `m-3m`. One of 32. */
50
+ readonly crystalClass: string;
51
+ /** The Laue class, the symmetry the diffraction pattern shows. One of 11. */
52
+ readonly laueClass: string;
53
+ /** Whether `-x,-y,-z` is an operation of the group. */
54
+ readonly centrosymmetric: boolean;
55
+ /** Whether every operation is proper, so one enantiomer can crystallise in it. */
56
+ readonly sohncke: boolean;
57
+ /** Whether some origin makes the group the semidirect product of point group and lattice. */
58
+ readonly symmorphic: boolean;
59
+ /** How many operations the cell carries — the multiplicity of a general position. */
60
+ readonly multiplicity: number;
61
+ /** The coset list as canonical triplets, centring expanded: `-x,y+1/2,-z+1/2`. */
62
+ readonly operations: readonly string[];
63
+ }
64
+
65
+ /**
66
+ * The 521 settings of the 230 space groups, in source order: ascending number,
67
+ * then ascending variant.
68
+ *
69
+ * Every field but the symbols and the Hall symbol is derived from the operation
70
+ * list rather than transcribed, by symmetry.cheminfo.org, whose tests reproduce
71
+ * the International Tables counts of 92 centrosymmetric, 65 Sohncke and 73
72
+ * symmorphic groups.
73
+ */
74
+ export const SPACE_GROUP_SETTINGS: readonly SpaceGroupSetting[] =
75
+ SPACE_GROUP_ROWS.map(decodeRow);
76
+
77
+ /** The settings of one space group number, variant 0 first. */
78
+ export const SPACE_GROUP_SETTINGS_BY_NUMBER: ReadonlyMap<
79
+ number,
80
+ readonly SpaceGroupSetting[]
81
+ > = groupByNumber(SPACE_GROUP_SETTINGS);
82
+
83
+ /**
84
+ * One setting of one space group.
85
+ *
86
+ * ```
87
+ * spaceGroup(14) // P 1 21/c 1, the standard setting
88
+ * spaceGroup(227, 1) // F d -3 m on origin choice 1
89
+ * ```
90
+ * @param number - The International Tables number, 1 to 230.
91
+ * @param variant - Which setting of it; 0 is the standard one.
92
+ * @returns The setting.
93
+ * @throws {RangeError} When the number is not one of the 230, or the setting does not exist.
94
+ */
95
+ export function spaceGroup(number: number, variant = 0): SpaceGroupSetting {
96
+ const settings = SPACE_GROUP_SETTINGS_BY_NUMBER.get(number);
97
+ if (settings === undefined) {
98
+ throw new RangeError(`${number} is not a space group number`);
99
+ }
100
+ const setting = settings[variant];
101
+ if (setting === undefined) {
102
+ throw new RangeError(
103
+ `space group ${number} has ${settings.length} settings, so there is no ${variant}`,
104
+ );
105
+ }
106
+ return setting;
107
+ }
108
+
109
+ function decodeRow(row: string): SpaceGroupSetting {
110
+ const field = row.split('|');
111
+ const flags = field[14] ?? '';
112
+ const operations = (field[15] ?? '').split(';');
113
+ return {
114
+ number: Number(field[0]),
115
+ variant: Number(field[1]),
116
+ hmShort: field[2] ?? '',
117
+ hmFull: field[3] ?? '',
118
+ hmSetting: field[4] ?? '',
119
+ hmLegacy: field[5] === '' ? null : (field[5] ?? null),
120
+ hall: field[6] === '' ? null : (field[6] ?? null),
121
+ crystalSystem: field[7] as CrystalSystem,
122
+ centring: field[8] as Centring,
123
+ axes:
124
+ field[9] === 'hexagonal' || field[9] === 'rhombohedral' ? field[9] : null,
125
+ originChoice: field[10] === '1' ? 1 : field[10] === '2' ? 2 : null,
126
+ uniqueAxis: decodeAxis(field[11]),
127
+ crystalClass: field[12] ?? '',
128
+ laueClass: field[13] ?? '',
129
+ centrosymmetric: flags.startsWith('1'),
130
+ sohncke: flags[1] === '1',
131
+ symmorphic: flags[2] === '1',
132
+ multiplicity: operations.length,
133
+ operations,
134
+ };
135
+ }
136
+
137
+ function decodeAxis(field: string | undefined): 'a' | 'b' | 'c' | null {
138
+ if (field === 'a') return 'a';
139
+ if (field === 'b') return 'b';
140
+ if (field === 'c') return 'c';
141
+ return null;
142
+ }
143
+
144
+ function groupByNumber(
145
+ settings: readonly SpaceGroupSetting[],
146
+ ): ReadonlyMap<number, readonly SpaceGroupSetting[]> {
147
+ const byNumber = new Map<number, SpaceGroupSetting[]>();
148
+ for (const setting of settings) {
149
+ const list = byNumber.get(setting.number);
150
+ if (list === undefined) byNumber.set(setting.number, [setting]);
151
+ else list.push(setting);
152
+ }
153
+ return byNumber;
154
+ }
@@ -0,0 +1,42 @@
1
+ import { compose, identityOperation, operationKey } from './operation.ts';
2
+ import type { CrystalOperation, Dimension } from './types.ts';
3
+
4
+ /**
5
+ * Every coset representative generated by `generators`, modulo the lattice
6
+ * translations: the whole group when the generators generate it.
7
+ *
8
+ * A breadth-first closure over exact integer keys, so it terminates on any input
9
+ * whose rotation parts have finite order. The identity comes first.
10
+ * @param generators - Operations of one dimension.
11
+ * @param limit - The most operations a closure may reach.
12
+ * @throws {RangeError} When the closure passes `limit` operations, which means the generators
13
+ * are not those of a crystallographic group.
14
+ * @returns The coset representatives, the identity first.
15
+ */
16
+ export function closure<D extends Dimension>(
17
+ generators: ReadonlyArray<CrystalOperation<D>>,
18
+ limit = 1536,
19
+ ): Array<CrystalOperation<D>> {
20
+ const dimension = (generators[0]?.rotation.length ?? 3) as D;
21
+ const identity = identityOperation(dimension);
22
+ const found = new Map<string, CrystalOperation<D>>([
23
+ [operationKey(identity), identity],
24
+ ]);
25
+ const queue: Array<CrystalOperation<D>> = [identity];
26
+ // The queue grows while it is read, which is what makes this a closure.
27
+ for (const current of queue) {
28
+ for (const generator of generators) {
29
+ const next = compose(generator, current);
30
+ const key = operationKey(next);
31
+ if (found.has(key)) continue;
32
+ found.set(key, next);
33
+ queue.push(next);
34
+ if (queue.length > limit) {
35
+ throw new RangeError(
36
+ `the generators do not close within ${limit} operations`,
37
+ );
38
+ }
39
+ }
40
+ }
41
+ return queue;
42
+ }
@@ -0,0 +1,23 @@
1
+ export { closure } from './group.ts';
2
+ export type { Lattice, UnitCell } from './lattice.ts';
3
+ export {
4
+ cartesianMatrix,
5
+ cartesianToFractional,
6
+ cellVolume,
7
+ createLattice,
8
+ fractionalToCartesian,
9
+ } from './lattice.ts';
10
+ export {
11
+ apply,
12
+ compose,
13
+ identityOperation,
14
+ inverse,
15
+ isIdentity,
16
+ operationKey,
17
+ orbit,
18
+ sameSite,
19
+ wrapFractional,
20
+ } from './operation.ts';
21
+ export { parseOperation } from './parseOperation.ts';
22
+ export type { CrystalOperation, Dimension, IntegerMatrix } from './types.ts';
23
+ export { TWELFTHS_PER_CELL } from './types.ts';
@@ -0,0 +1,153 @@
1
+ import type { IntegerMatrix } from './types.ts';
2
+
3
+ /**
4
+ * The product `a · b` of two square integer matrices of the same size.
5
+ * @param a - Left factor, row-major.
6
+ * @param b - Right factor, row-major.
7
+ * @returns The product, row-major.
8
+ */
9
+ export function multiplyMatrices(
10
+ a: IntegerMatrix,
11
+ b: IntegerMatrix,
12
+ ): number[][] {
13
+ const size = a.length;
14
+ const product: number[][] = [];
15
+ for (let i = 0; i < size; i++) {
16
+ const values = new Array<number>(size).fill(0);
17
+ for (let k = 0; k < size; k++) {
18
+ const factor = entry(a, i, k);
19
+ if (factor === 0) continue;
20
+ for (let j = 0; j < size; j++) {
21
+ values[j] = (values[j] ?? 0) + factor * entry(b, k, j);
22
+ }
23
+ }
24
+ product.push(values);
25
+ }
26
+ return product;
27
+ }
28
+
29
+ /**
30
+ * The product `matrix · vector`.
31
+ * @param matrix - The matrix, row-major.
32
+ * @param vector - The vector.
33
+ * @returns The image of the vector.
34
+ */
35
+ export function multiplyMatrixVector(
36
+ matrix: IntegerMatrix,
37
+ vector: readonly number[],
38
+ ): number[] {
39
+ const size = matrix.length;
40
+ const image = new Array<number>(size).fill(0);
41
+ for (let i = 0; i < size; i++) {
42
+ let sum = 0;
43
+ for (let j = 0; j < vector.length; j++) {
44
+ sum += entry(matrix, i, j) * (vector[j] ?? 0);
45
+ }
46
+ image[i] = sum;
47
+ }
48
+ return image;
49
+ }
50
+
51
+ /**
52
+ * The `size × size` identity matrix.
53
+ * @param size - 2 or 3.
54
+ * @returns The identity matrix.
55
+ */
56
+ export function identityMatrix(size: number): number[][] {
57
+ const identity: number[][] = [];
58
+ for (let i = 0; i < size; i++) {
59
+ const values = new Array<number>(size).fill(0);
60
+ values[i] = 1;
61
+ identity.push(values);
62
+ }
63
+ return identity;
64
+ }
65
+
66
+ /**
67
+ * The determinant of a 2×2 or 3×3 integer matrix.
68
+ * @param matrix - A 2×2 or 3×3 matrix.
69
+ * @throws {RangeError} When the matrix is not 2×2 or 3×3; no crystallographic operation is.
70
+ * @returns The determinant.
71
+ */
72
+ export function matrixDeterminant(matrix: IntegerMatrix): number {
73
+ if (matrix.length === 2) {
74
+ return (
75
+ entry(matrix, 0, 0) * entry(matrix, 1, 1) -
76
+ entry(matrix, 0, 1) * entry(matrix, 1, 0)
77
+ );
78
+ }
79
+ if (matrix.length !== 3) {
80
+ throw new RangeError(
81
+ `expected a 2×2 or 3×3 matrix, received ${matrix.length}×${matrix.length}`,
82
+ );
83
+ }
84
+ // The cyclic cofactor expansion: the index rotation already carries the sign,
85
+ // so there is no alternating factor to apply on top of it.
86
+ let determinant = 0;
87
+ for (let j = 0; j < 3; j++) {
88
+ determinant +=
89
+ entry(matrix, 0, j) *
90
+ (entry(matrix, 1, (j + 1) % 3) * entry(matrix, 2, (j + 2) % 3) -
91
+ entry(matrix, 1, (j + 2) % 3) * entry(matrix, 2, (j + 1) % 3));
92
+ }
93
+ return determinant;
94
+ }
95
+
96
+ /**
97
+ * The adjugate: `adjugate(m) · m = det(m) · I`, exactly, in integers.
98
+ *
99
+ * It is how this core inverts an integer matrix without ever dividing, so an
100
+ * element's position stays an exact fraction.
101
+ * @param matrix - A 2×2 or 3×3 matrix.
102
+ * @returns The adjugate.
103
+ */
104
+ export function matrixAdjugate(matrix: IntegerMatrix): number[][] {
105
+ if (matrix.length === 2) {
106
+ return [
107
+ [entry(matrix, 1, 1), -entry(matrix, 0, 1)],
108
+ [-entry(matrix, 1, 0), entry(matrix, 0, 0)],
109
+ ];
110
+ }
111
+ const adjugate: number[][] = [];
112
+ for (let i = 0; i < 3; i++) {
113
+ const values = new Array<number>(3).fill(0);
114
+ for (let j = 0; j < 3; j++) {
115
+ const rows = [(j + 1) % 3, (j + 2) % 3];
116
+ const columns = [(i + 1) % 3, (i + 2) % 3];
117
+ values[j] =
118
+ entry(matrix, rows[0] ?? 0, columns[0] ?? 0) *
119
+ entry(matrix, rows[1] ?? 0, columns[1] ?? 0) -
120
+ entry(matrix, rows[0] ?? 0, columns[1] ?? 0) *
121
+ entry(matrix, rows[1] ?? 0, columns[0] ?? 0);
122
+ }
123
+ adjugate.push(values);
124
+ }
125
+ return adjugate;
126
+ }
127
+
128
+ /**
129
+ * Whether two matrices hold the same integers.
130
+ * @param a - One matrix.
131
+ * @param b - The other.
132
+ * @returns Whether every entry is the same.
133
+ */
134
+ export function matricesEqual(a: IntegerMatrix, b: IntegerMatrix): boolean {
135
+ if (a.length !== b.length) return false;
136
+ for (let i = 0; i < a.length; i++) {
137
+ for (let j = 0; j < a.length; j++) {
138
+ if (entry(a, i, j) !== entry(b, i, j)) return false;
139
+ }
140
+ }
141
+ return true;
142
+ }
143
+
144
+ /**
145
+ * One entry, or 0 outside the matrix, so `noUncheckedIndexedAccess` costs nothing here.
146
+ * @param matrix - The matrix.
147
+ * @param row - Row index.
148
+ * @param column - Column index.
149
+ * @returns The entry.
150
+ */
151
+ function entry(matrix: IntegerMatrix, row: number, column: number): number {
152
+ return matrix[row]?.[column] ?? 0;
153
+ }