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,132 @@
1
+ /**
2
+ * The half of the crystal viewer that has never heard of molstar.
3
+ *
4
+ * A page that only *builds* a scene — repeats a cell, works out which symmetry
5
+ * elements to draw, frames what it has — imports this and pays nothing: the
6
+ * molstar chunk hangs off `viewer/`, which is reached through the lazy canvas
7
+ * and nowhere else.
8
+ */
9
+
10
+ export type { CellSegment } from './cellClip.ts';
11
+ export { cellSection, clipLineToCell } from './cellClip.ts';
12
+ export type { CellEdge } from './cellGeometry.ts';
13
+ export {
14
+ cellAxes,
15
+ cellAxisLabelPoints,
16
+ cellEdges,
17
+ cellPoint,
18
+ clampRepeat,
19
+ latticeShifts,
20
+ } from './cellGeometry.ts';
21
+ export { mergeDrawings, sameDrawings, withoutDrawings } from './drawingSet.ts';
22
+ export type { ElementGroup } from './elementDrawing.ts';
23
+ export { drawingPrimitives, elementGroups } from './elementDrawing.ts';
24
+ export { drawingLabels } from './elementLabels.ts';
25
+ export { plainName } from './labelText.ts';
26
+ export type { PlaneFrame } from './frame.ts';
27
+ export { perpendicularTo, planeFrame } from './frame.ts';
28
+ export type { SceneSphere } from './framing.ts';
29
+ export { boundingSphereOf, primitivesExtent, unionSpheres } from './framing.ts';
30
+ export type { OrientedScene, ViewOrientation } from './orientation.ts';
31
+ export {
32
+ principalAxisOf,
33
+ sceneOrientation,
34
+ threeQuarterView,
35
+ } from './orientation.ts';
36
+ export type { Matrix4 } from './operationMatrix.ts';
37
+ export {
38
+ IDENTITY_MATRIX4,
39
+ ROTATION_PHASE,
40
+ operationAt,
41
+ operationIsRigid,
42
+ operationMatrix,
43
+ } from './operationMatrix.ts';
44
+ export {
45
+ CELL_COLOUR,
46
+ ELEMENT_COLOURS,
47
+ LABEL_COLOUR,
48
+ drawingColour,
49
+ } from './palette.ts';
50
+ export type {
51
+ ElementStyle,
52
+ MeshPrimitive,
53
+ ResolvedElementStyle,
54
+ TextItem,
55
+ } from './primitives.ts';
56
+ export {
57
+ DEFAULT_ELEMENT_STYLE,
58
+ primitivePoints,
59
+ resolveElementStyle,
60
+ } from './primitives.ts';
61
+ export { toXyzText } from './structureText.ts';
62
+ export { supercellAtoms } from './supercell.ts';
63
+ export type {
64
+ CellRepeat,
65
+ DrawingBase,
66
+ GlideDrawing,
67
+ InversionDrawing,
68
+ MirrorDrawing,
69
+ Point3,
70
+ RotationDrawing,
71
+ RotoinversionDrawing,
72
+ ScrewDrawing,
73
+ SymmetryDrawing,
74
+ SymmetryDrawingKind,
75
+ UnitCell,
76
+ ViewerAtom,
77
+ ViewerOperation,
78
+ } from './types.ts';
79
+
80
+ export type { Mat3 } from './mat3.ts';
81
+ export {
82
+ IDENTITY_MATRIX,
83
+ INVERSION_MATRIX,
84
+ applyMatrix,
85
+ matrixDeterminant,
86
+ matrixDistance,
87
+ matrixTrace,
88
+ multiplyMatrices,
89
+ reflectionMatrix,
90
+ rotationMatrix,
91
+ scaleMatrix,
92
+ transposeMatrix,
93
+ } from './mat3.ts';
94
+ export type { Vec3 } from './vec3.ts';
95
+ export {
96
+ addVectors,
97
+ collinear,
98
+ crossProduct,
99
+ dotProduct,
100
+ normalizeVector,
101
+ sameAxis,
102
+ scaleVector,
103
+ subtractVectors,
104
+ vectorDistance,
105
+ vectorNorm,
106
+ } from './vec3.ts';
107
+ export {
108
+ normalToCartesian,
109
+ normalToFractional,
110
+ toCartesian,
111
+ toFractional,
112
+ } from './latticeBasis.ts';
113
+ export { axisRod, faceOf } from './elementExtent.ts';
114
+ export type { AxisRod } from './elementExtent.ts';
115
+ export {
116
+ SUPERCELL_ATOM_CAP,
117
+ largestRepeatThatFits,
118
+ repeatCell,
119
+ repeatedAtomCount,
120
+ } from './cellStack.ts';
121
+ export type {
122
+ CrystalPacking,
123
+ CrystalView,
124
+ CrystalViewOptions,
125
+ CrystalViewSettings,
126
+ } from './crystalView.ts';
127
+ export {
128
+ CELL_COUNT_RANGE,
129
+ CRYSTAL_PACKINGS,
130
+ DEFAULT_CRYSTAL_VIEW_SETTINGS,
131
+ crystalView,
132
+ } from './crystalView.ts';
@@ -0,0 +1,44 @@
1
+ /**
2
+ * An operation's name as a canvas can draw it.
3
+ *
4
+ * The site holds a raised part behind a caret — `C3^2`, `σv^′`, `C2^″(1)` —
5
+ * because the panels beside the view typeset what follows it above the line.
6
+ * A molstar label is plain text and typesets nothing, so the caret is drawn as
7
+ * itself: benzene's two-folds read `C2^′(1)` on the canvas while the list next
8
+ * to them reads C₂′(1). Raising the characters here is what makes the two
9
+ * agree, and it is the last step before the name leaves for the scene — the
10
+ * names the rest of the site matches on are untouched.
11
+ */
12
+
13
+ /**
14
+ * Raise what a caret marks, and drop the caret.
15
+ * @param label - The name as the site holds it.
16
+ * @returns The same name with each raised run set above the line: `C3²`,
17
+ * `σv′`, `C2″(1)`.
18
+ */
19
+ export function plainName(label: string): string {
20
+ return label.replaceAll(RAISED, (_match, raised: string) => raise(raised));
21
+ }
22
+
23
+ /** A caret and the run it raises: digits, and the primes already drawn high. */
24
+ const RAISED = /\^(?<raised>[\d′″]+)/gu;
25
+
26
+ /** The digits, above the line. A prime is already a raised glyph. */
27
+ const ABOVE: Record<string, string> = {
28
+ 0: '⁰',
29
+ 1: '¹',
30
+ 2: '²',
31
+ 3: '³',
32
+ 4: '⁴',
33
+ 5: '⁵',
34
+ 6: '⁶',
35
+ 7: '⁷',
36
+ 8: '⁸',
37
+ 9: '⁹',
38
+ };
39
+
40
+ function raise(run: string): string {
41
+ let raised = '';
42
+ for (const character of run) raised += ABOVE[character] ?? character;
43
+ return raised;
44
+ }
@@ -0,0 +1,110 @@
1
+ /**
2
+ * How a vector crosses between the crystal basis and Cartesian ångström.
3
+ *
4
+ * There are four ways across and they are not interchangeable. A direction
5
+ * `[uvw]` is a direct-space vector and goes through `M`; a normal `(hkl)` is a
6
+ * reciprocal-space one and goes through `(M⁻¹)ᵀ`. The two agree in an
7
+ * orthogonal cell, so swapping them is only ever caught on a monoclinic or
8
+ * triclinic structure, with the mirror drawn at the wrong tilt.
9
+ *
10
+ * Naming them all together, once, is what stops the third caller writing a
11
+ * fifth matrix loop and picking the wrong transpose in it.
12
+ */
13
+
14
+ import type { Lattice } from '../../crystal/core/symmetry/lattice.ts';
15
+
16
+ import type { Vec3 } from './vec3.ts';
17
+
18
+ /**
19
+ * A fractional point or direction, in Cartesian ångström — `M v`.
20
+ * @param lattice - The cell it is read in.
21
+ * @param point - Its fractional coordinates.
22
+ * @returns The same point, Cartesian ångström.
23
+ */
24
+ export function toCartesian(lattice: Lattice, point: readonly number[]): Vec3 {
25
+ return applyMatrix(lattice.cartesian, point);
26
+ }
27
+
28
+ /**
29
+ * A Cartesian point or direction, in cell fractions — `M⁻¹ v`.
30
+ * @param lattice - The cell it is read in.
31
+ * @param point - Its Cartesian coordinates, ångström.
32
+ * @returns The same point, in fractions of the cell edges.
33
+ */
34
+ export function toFractional(lattice: Lattice, point: readonly number[]): Vec3 {
35
+ return applyMatrix(lattice.fractional, point);
36
+ }
37
+
38
+ /**
39
+ * A normal `(hkl)` written in the crystal basis, as a Cartesian direction —
40
+ * `(M⁻¹)ᵀ v`.
41
+ * @param lattice - The cell it is read in.
42
+ * @param normal - The reciprocal-space normal `(hkl)`.
43
+ * @returns A Cartesian vector at right angles to the plane itself.
44
+ */
45
+ export function normalToCartesian(
46
+ lattice: Lattice,
47
+ normal: readonly number[],
48
+ ): Vec3 {
49
+ return applyTransposed(lattice.fractional, normal);
50
+ }
51
+
52
+ /**
53
+ * A Cartesian normal, as the covector that measures heights above the plane in
54
+ * cell fractions — `Mᵀ v`.
55
+ *
56
+ * `n · (x − p)` in ångström is that covector against `x − p` in fractions, so a
57
+ * height can be taken without leaving fractional coordinates. It is the inverse
58
+ * transpose of {@link normalToCartesian}, not its inverse.
59
+ * @param lattice - The cell it is read in.
60
+ * @param normal - A Cartesian plane normal.
61
+ * @returns The covector to dot fractional offsets against.
62
+ */
63
+ export function normalToFractional(
64
+ lattice: Lattice,
65
+ normal: readonly number[],
66
+ ): Vec3 {
67
+ return applyTransposed(lattice.cartesian, normal);
68
+ }
69
+
70
+ /**
71
+ * `A v`.
72
+ * @param matrix - The 3×3 matrix, as its rows.
73
+ * @param point - The vector it is applied to.
74
+ * @returns The image.
75
+ */
76
+ function applyMatrix(
77
+ matrix: ReadonlyArray<readonly number[]>,
78
+ point: readonly number[],
79
+ ): Vec3 {
80
+ const image: number[] = [0, 0, 0];
81
+ for (let i = 0; i < 3; i++) {
82
+ let sum = 0;
83
+ for (let j = 0; j < 3; j++) {
84
+ sum += (matrix[i]?.[j] ?? 0) * (point[j] ?? 0);
85
+ }
86
+ image[i] = sum;
87
+ }
88
+ return [image[0] ?? 0, image[1] ?? 0, image[2] ?? 0];
89
+ }
90
+
91
+ /**
92
+ * `Aᵀ v`, which is `A v` with the two indices swapped.
93
+ * @param matrix - The 3×3 matrix, as its rows.
94
+ * @param point - The vector its transpose is applied to.
95
+ * @returns The image.
96
+ */
97
+ function applyTransposed(
98
+ matrix: ReadonlyArray<readonly number[]>,
99
+ point: readonly number[],
100
+ ): Vec3 {
101
+ const image: number[] = [0, 0, 0];
102
+ for (let i = 0; i < 3; i++) {
103
+ let sum = 0;
104
+ for (let j = 0; j < 3; j++) {
105
+ sum += (matrix[j]?.[i] ?? 0) * (point[j] ?? 0);
106
+ }
107
+ image[i] = sum;
108
+ }
109
+ return [image[0] ?? 0, image[1] ?? 0, image[2] ?? 0];
110
+ }
@@ -0,0 +1,163 @@
1
+ import type { Vec3 } from './vec3.ts';
2
+
3
+ /** A 3×3 Cartesian matrix, as its three rows. */
4
+ export type Mat3 = readonly [Vec3, Vec3, Vec3];
5
+
6
+ /** The identity. */
7
+ export const IDENTITY_MATRIX: Mat3 = [
8
+ [1, 0, 0],
9
+ [0, 1, 0],
10
+ [0, 0, 1],
11
+ ];
12
+
13
+ /** The inversion, −I. */
14
+ export const INVERSION_MATRIX: Mat3 = [
15
+ [-1, 0, 0],
16
+ [0, -1, 0],
17
+ [0, 0, -1],
18
+ ];
19
+
20
+ /**
21
+ * a · b, so that `applyMatrix(multiplyMatrices(a, b), v)` is a applied after b.
22
+ * @param a - The matrix applied last.
23
+ * @param b - The matrix applied first.
24
+ * @returns The product.
25
+ */
26
+ export function multiplyMatrices(a: Mat3, b: Mat3): Mat3 {
27
+ return [multiplyRow(a[0], b), multiplyRow(a[1], b), multiplyRow(a[2], b)];
28
+ }
29
+
30
+ /**
31
+ * M · v.
32
+ * @param matrix - The matrix.
33
+ * @param vector - The vector it is applied to.
34
+ * @returns The transformed vector.
35
+ */
36
+ export function applyMatrix(matrix: Mat3, vector: Vec3): Vec3 {
37
+ return [
38
+ matrix[0][0] * vector[0] +
39
+ matrix[0][1] * vector[1] +
40
+ matrix[0][2] * vector[2],
41
+ matrix[1][0] * vector[0] +
42
+ matrix[1][1] * vector[1] +
43
+ matrix[1][2] * vector[2],
44
+ matrix[2][0] * vector[0] +
45
+ matrix[2][1] * vector[1] +
46
+ matrix[2][2] * vector[2],
47
+ ];
48
+ }
49
+
50
+ /**
51
+ * Mᵀ, which is M⁻¹ for the orthogonal matrix of any symmetry operation.
52
+ * @param matrix - The matrix.
53
+ * @returns Its transpose.
54
+ */
55
+ export function transposeMatrix(matrix: Mat3): Mat3 {
56
+ return [
57
+ [matrix[0][0], matrix[1][0], matrix[2][0]],
58
+ [matrix[0][1], matrix[1][1], matrix[2][1]],
59
+ [matrix[0][2], matrix[1][2], matrix[2][2]],
60
+ ];
61
+ }
62
+
63
+ /**
64
+ * det M: +1 for a proper operation, −1 for an improper one.
65
+ * @param matrix - The matrix.
66
+ * @returns Its determinant.
67
+ */
68
+ export function matrixDeterminant(matrix: Mat3): number {
69
+ return (
70
+ matrix[0][0] * (matrix[1][1] * matrix[2][2] - matrix[1][2] * matrix[2][1]) -
71
+ matrix[0][1] * (matrix[1][0] * matrix[2][2] - matrix[1][2] * matrix[2][0]) +
72
+ matrix[0][2] * (matrix[1][0] * matrix[2][1] - matrix[1][1] * matrix[2][0])
73
+ );
74
+ }
75
+
76
+ /**
77
+ * tr M, which is `±1 + 2cos θ` for a symmetry operation.
78
+ * @param matrix - The matrix.
79
+ * @returns Its trace.
80
+ */
81
+ export function matrixTrace(matrix: Mat3): number {
82
+ return matrix[0][0] + matrix[1][1] + matrix[2][2];
83
+ }
84
+
85
+ /**
86
+ * M · factor.
87
+ * @param matrix - The matrix.
88
+ * @param factor - The scalar every entry is multiplied by.
89
+ * @returns The scaled matrix.
90
+ */
91
+ export function scaleMatrix(matrix: Mat3, factor: number): Mat3 {
92
+ return [
93
+ [matrix[0][0] * factor, matrix[0][1] * factor, matrix[0][2] * factor],
94
+ [matrix[1][0] * factor, matrix[1][1] * factor, matrix[1][2] * factor],
95
+ [matrix[2][0] * factor, matrix[2][1] * factor, matrix[2][2] * factor],
96
+ ];
97
+ }
98
+
99
+ /**
100
+ * ‖a − b‖_F, the distance two operation matrices are compared with.
101
+ * @param a - The first matrix.
102
+ * @param b - The second matrix.
103
+ * @returns The Frobenius norm of their difference.
104
+ */
105
+ export function matrixDistance(a: Mat3, b: Mat3): number {
106
+ let sum = 0;
107
+ for (let i = 0; i < 3; i++) {
108
+ const rowA = a[i] as Vec3;
109
+ const rowB = b[i] as Vec3;
110
+ for (let j = 0; j < 3; j++) {
111
+ const difference = (rowA[j] as number) - (rowB[j] as number);
112
+ sum += difference * difference;
113
+ }
114
+ }
115
+ return Math.sqrt(sum);
116
+ }
117
+
118
+ /**
119
+ * The rotation by `angle` radians about the unit vector `axis`, right-handed,
120
+ * from Rodrigues' formula `R = cos θ I + sin θ [n̂]ₓ + (1 − cos θ) n̂ n̂ᵀ`.
121
+ * @param axis - The unit vector rotated about.
122
+ * @param angle - The angle, in radians.
123
+ * @returns The rotation matrix.
124
+ */
125
+ export function rotationMatrix(axis: Vec3, angle: number): Mat3 {
126
+ const [x, y, z] = axis;
127
+ const c = Math.cos(angle);
128
+ const s = Math.sin(angle);
129
+ const t = 1 - c;
130
+ return [
131
+ [t * x * x + c, t * x * y - s * z, t * x * z + s * y],
132
+ [t * x * y + s * z, t * y * y + c, t * y * z - s * x],
133
+ [t * x * z - s * y, t * y * z + s * x, t * z * z + c],
134
+ ];
135
+ }
136
+
137
+ /**
138
+ * The reflection `I − 2 n̂ n̂ᵀ` in the plane through the origin with unit normal `normal`.
139
+ * @param normal - The unit normal of the mirror plane.
140
+ * @returns The reflection matrix.
141
+ */
142
+ export function reflectionMatrix(normal: Vec3): Mat3 {
143
+ const [x, y, z] = normal;
144
+ return [
145
+ [1 - 2 * x * x, -2 * x * y, -2 * x * z],
146
+ [-2 * x * y, 1 - 2 * y * y, -2 * y * z],
147
+ [-2 * x * z, -2 * y * z, 1 - 2 * z * z],
148
+ ];
149
+ }
150
+
151
+ /**
152
+ * One row of a · b.
153
+ * @param row - The row of a.
154
+ * @param b - The right-hand matrix.
155
+ * @returns That row of the product.
156
+ */
157
+ function multiplyRow(row: Vec3, b: Mat3): Vec3 {
158
+ return [
159
+ row[0] * b[0][0] + row[1] * b[1][0] + row[2] * b[2][0],
160
+ row[0] * b[0][1] + row[1] * b[1][1] + row[2] * b[2][1],
161
+ row[0] * b[0][2] + row[1] * b[1][2] + row[2] * b[2][2],
162
+ ];
163
+ }
@@ -0,0 +1,255 @@
1
+ /**
2
+ * An operation as a matrix, and as the path the structure takes to get there.
3
+ *
4
+ * A proper rotation and a screw have a rigid path from the identity, so they
5
+ * are turned through it and the molecule visibly lands back on itself. The
6
+ * improper ones have none: no continuous rigid motion carries a body onto its
7
+ * mirror image. Pretending otherwise would teach the wrong thing, so instead the
8
+ * structure passes *through* the plane or the centre — flat at the halfway
9
+ * point, which is exactly where the operation's fixed set is.
10
+ */
11
+
12
+ import type { Mat3 } from './mat3.ts';
13
+ import {
14
+ IDENTITY_MATRIX,
15
+ INVERSION_MATRIX,
16
+ applyMatrix,
17
+ multiplyMatrices,
18
+ reflectionMatrix,
19
+ rotationMatrix,
20
+ } from './mat3.ts';
21
+ import type { Point3, ViewerOperation } from './types.ts';
22
+ import type { Vec3 } from './vec3.ts';
23
+ import {
24
+ addVectors,
25
+ normalizeVector,
26
+ scaleVector,
27
+ subtractVectors,
28
+ } from './vec3.ts';
29
+
30
+ /** A 4×4 affine matrix, sixteen numbers in **column-major** order. */
31
+ export type Matrix4 = readonly number[];
32
+
33
+ /** The matrix that moves nothing. */
34
+ export const IDENTITY_MATRIX4: Matrix4 = affineMatrix(
35
+ IDENTITY_MATRIX,
36
+ [0, 0, 0],
37
+ );
38
+
39
+ /**
40
+ * The operation itself, as one matrix.
41
+ * @param operation - What to apply.
42
+ * @returns The 4×4 matrix, column-major.
43
+ */
44
+ export function operationMatrix(operation: ViewerOperation): Matrix4 {
45
+ return operationAt(operation, 1);
46
+ }
47
+
48
+ /**
49
+ * The operation part-way through, so a caller can drive it with a clock.
50
+ * @param operation - What to apply.
51
+ * @param fraction - How far through, from 0 (the identity) to 1 (the operation
52
+ * itself). Anything outside that is clamped.
53
+ * @returns The 4×4 matrix, column-major.
54
+ */
55
+ export function operationAt(
56
+ operation: ViewerOperation,
57
+ fraction: number,
58
+ ): Matrix4 {
59
+ const t = Math.min(1, Math.max(0, fraction));
60
+ switch (operation.kind) {
61
+ case 'rotation': {
62
+ return aboutPoint(turn(operation, t), operation.origin, [0, 0, 0]);
63
+ }
64
+ case 'screw': {
65
+ return aboutPoint(
66
+ turn(operation, t),
67
+ operation.origin,
68
+ scaleVector(operation.translation, t),
69
+ );
70
+ }
71
+ case 'mirror': {
72
+ return aboutPoint(
73
+ blend(IDENTITY_MATRIX, mirrorOf(operation.normal), t),
74
+ operation.point,
75
+ [0, 0, 0],
76
+ );
77
+ }
78
+ case 'glide': {
79
+ return aboutPoint(
80
+ blend(IDENTITY_MATRIX, mirrorOf(operation.normal), t),
81
+ operation.point,
82
+ scaleVector(operation.translation, t),
83
+ );
84
+ }
85
+ case 'inversion': {
86
+ return aboutPoint(
87
+ blend(IDENTITY_MATRIX, INVERSION_MATRIX, t),
88
+ operation.centre,
89
+ [0, 0, 0],
90
+ );
91
+ }
92
+ case 'improperRotation': {
93
+ return twoPhase(operation, t, mirrorOf(operation.axis));
94
+ }
95
+ case 'rotoinversion': {
96
+ return twoPhase(operation, t, INVERSION_MATRIX);
97
+ }
98
+ // no default
99
+ }
100
+ }
101
+
102
+ /**
103
+ * Whether the path from the identity is a rigid motion all the way.
104
+ *
105
+ * A page says so in one line under the button: a proper rotation turns, and an
106
+ * improper one has to pass through its own mirror.
107
+ * @param operation - What is about to be applied.
108
+ * @returns Whether every frame of it is a rotation.
109
+ */
110
+ export function operationIsRigid(operation: ViewerOperation): boolean {
111
+ return operation.kind === 'rotation' || operation.kind === 'screw';
112
+ }
113
+
114
+ /**
115
+ * The fraction of an improper animation spent turning, before the reflection or
116
+ * the inversion begins.
117
+ */
118
+ export const ROTATION_PHASE = 0.6;
119
+
120
+ /**
121
+ * Rotate rigidly, then pass through the plane or the centre.
122
+ * @param operation - The improper rotation or rotoinversion.
123
+ * @param t - How far through, from 0 to 1.
124
+ * @param improper - The reflection or inversion that follows the turn.
125
+ * @returns The 4×4 matrix, column-major.
126
+ */
127
+ function twoPhase(
128
+ operation: Extract<
129
+ ViewerOperation,
130
+ { kind: 'improperRotation' | 'rotoinversion' }
131
+ >,
132
+ t: number,
133
+ improper: Mat3,
134
+ ): Matrix4 {
135
+ if (t <= ROTATION_PHASE) {
136
+ return aboutPoint(
137
+ turn(operation, t / ROTATION_PHASE),
138
+ operation.origin,
139
+ [0, 0, 0],
140
+ );
141
+ }
142
+ const second = (t - ROTATION_PHASE) / (1 - ROTATION_PHASE);
143
+ const rotated = rotationMatrix(
144
+ normalizeVector(operation.axis),
145
+ angleOf(operation),
146
+ );
147
+ return aboutPoint(
148
+ multiplyMatrices(blend(IDENTITY_MATRIX, improper, second), rotated),
149
+ operation.origin,
150
+ [0, 0, 0],
151
+ );
152
+ }
153
+
154
+ /**
155
+ * The rotation of `operation` carried `t` of the way round.
156
+ * @param operation - An operation with an axis.
157
+ * @param t - How far round, from 0 to 1.
158
+ * @returns The rotation matrix.
159
+ */
160
+ function turn(
161
+ operation: Extract<
162
+ ViewerOperation,
163
+ { kind: 'rotation' | 'screw' | 'improperRotation' | 'rotoinversion' }
164
+ >,
165
+ t: number,
166
+ ): Mat3 {
167
+ return rotationMatrix(
168
+ normalizeVector(operation.axis),
169
+ angleOf(operation) * t,
170
+ );
171
+ }
172
+
173
+ /**
174
+ * `2πk/n`, the angle one application turns through.
175
+ * @param operation - An operation with an axis.
176
+ * @param operation.order - n, the order of the axis.
177
+ * @param operation.power - k, how many times it is applied; 1 by default.
178
+ * @returns The angle, in radians.
179
+ */
180
+ function angleOf(operation: { order: number; power?: number }): number {
181
+ return (2 * Math.PI * (operation.power ?? 1)) / operation.order;
182
+ }
183
+
184
+ /**
185
+ * `I − 2 n̂ n̂ᵀ`, from a normal the caller need not have normalised.
186
+ * @param normal - The mirror's normal, Cartesian.
187
+ * @returns The reflection matrix.
188
+ */
189
+ function mirrorOf(normal: Point3): Mat3 {
190
+ return reflectionMatrix(normalizeVector(normal));
191
+ }
192
+
193
+ /**
194
+ * `(1 − t) a + t b`, component by component.
195
+ * @param a - The matrix at t = 0.
196
+ * @param b - The matrix at t = 1.
197
+ * @param t - How far from a towards b.
198
+ * @returns The blended matrix.
199
+ */
200
+ function blend(a: Mat3, b: Mat3, t: number): Mat3 {
201
+ return [
202
+ blendRow(a[0], b[0], t),
203
+ blendRow(a[1], b[1], t),
204
+ blendRow(a[2], b[2], t),
205
+ ];
206
+ }
207
+
208
+ function blendRow(a: Vec3, b: Vec3, t: number): Vec3 {
209
+ return [
210
+ a[0] * (1 - t) + b[0] * t,
211
+ a[1] * (1 - t) + b[1] * t,
212
+ a[2] * (1 - t) + b[2] * t,
213
+ ];
214
+ }
215
+
216
+ /**
217
+ * `x ↦ L(x − p) + p + w`, written as one affine matrix.
218
+ * @param linear - L, the linear part.
219
+ * @param fixed - p, the point L keeps in place.
220
+ * @param shift - w, the translation added after.
221
+ * @returns The 4×4 matrix, column-major.
222
+ */
223
+ function aboutPoint(linear: Mat3, fixed: Point3, shift: Point3): Matrix4 {
224
+ return affineMatrix(
225
+ linear,
226
+ addVectors(subtractVectors(fixed, applyMatrix(linear, fixed)), shift),
227
+ );
228
+ }
229
+
230
+ /**
231
+ * The 3×3 and the translation, laid out the way a GPU reads them.
232
+ * @param linear - The linear part.
233
+ * @param translation - The translation, ångström.
234
+ * @returns The 4×4 matrix, column-major.
235
+ */
236
+ function affineMatrix(linear: Mat3, translation: Point3): Matrix4 {
237
+ return [
238
+ linear[0][0],
239
+ linear[1][0],
240
+ linear[2][0],
241
+ 0,
242
+ linear[0][1],
243
+ linear[1][1],
244
+ linear[2][1],
245
+ 0,
246
+ linear[0][2],
247
+ linear[1][2],
248
+ linear[2][2],
249
+ 0,
250
+ translation[0],
251
+ translation[1],
252
+ translation[2],
253
+ 1,
254
+ ];
255
+ }