@bitbybit-dev/base 1.5.0-rc.0 → 1.6.0-rc.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 (312) hide show
  1. package/lib/api/GlobalCDNProvider.js +1 -1
  2. package/lib/api/bearings/ansi-bearings.constants.d.ts +2 -0
  3. package/lib/api/bearings/ansi-bearings.constants.js +26 -0
  4. package/lib/api/bearings/ansi-bearings.d.ts +4 -0
  5. package/lib/api/bearings/ansi-bearings.js +14 -0
  6. package/lib/api/bearings/bearing-types.d.ts +25 -0
  7. package/lib/api/bearings/bearing-types.js +1 -0
  8. package/lib/api/bearings/bearings.constants.d.ts +1 -0
  9. package/lib/api/bearings/bearings.constants.js +1 -0
  10. package/lib/api/bearings/iso-bearings.constants.d.ts +2 -0
  11. package/lib/api/bearings/iso-bearings.constants.js +30 -0
  12. package/lib/api/bearings/iso-bearings.d.ts +4 -0
  13. package/lib/api/bearings/iso-bearings.js +14 -0
  14. package/lib/api/color-space.d.ts +2 -0
  15. package/lib/api/color-space.js +5 -8
  16. package/lib/api/fasteners/ansi-fasteners.constants.d.ts +16 -0
  17. package/lib/api/fasteners/ansi-fasteners.constants.js +118 -0
  18. package/lib/api/fasteners/ansi-fasteners.d.ts +8 -0
  19. package/lib/api/fasteners/ansi-fasteners.js +64 -0
  20. package/lib/api/fasteners/fastener-types.d.ts +161 -0
  21. package/lib/api/fasteners/fastener-types.js +1 -0
  22. package/lib/api/fasteners/fasteners.constants.d.ts +5 -0
  23. package/lib/api/fasteners/fasteners.constants.js +5 -0
  24. package/lib/api/fasteners/fasteners.d.ts +2 -0
  25. package/lib/api/fasteners/fasteners.js +9 -0
  26. package/lib/api/fasteners/iso-fasteners.constants.d.ts +23 -0
  27. package/lib/api/fasteners/iso-fasteners.constants.js +110 -0
  28. package/lib/api/fasteners/iso-fasteners.d.ts +9 -0
  29. package/lib/api/fasteners/iso-fasteners.js +61 -0
  30. package/lib/api/gears/bevel-gears.d.ts +6 -0
  31. package/lib/api/gears/bevel-gears.js +69 -0
  32. package/lib/api/gears/gear-checks.d.ts +8 -0
  33. package/lib/api/gears/gear-checks.js +69 -0
  34. package/lib/api/gears/gear-pairs.d.ts +4 -0
  35. package/lib/api/gears/gear-pairs.js +140 -0
  36. package/lib/api/gears/gear-types.d.ts +425 -0
  37. package/lib/api/gears/gear-types.js +1 -0
  38. package/lib/api/gears/gears.constants.d.ts +19 -0
  39. package/lib/api/gears/gears.constants.js +19 -0
  40. package/lib/api/gears/gears.d.ts +10 -0
  41. package/lib/api/gears/gears.js +156 -0
  42. package/lib/api/gears/helical-gears.d.ts +5 -0
  43. package/lib/api/gears/helical-gears.js +33 -0
  44. package/lib/api/gears/involute-flank.d.ts +26 -0
  45. package/lib/api/gears/involute-flank.js +158 -0
  46. package/lib/api/gears/racks.d.ts +3 -0
  47. package/lib/api/gears/racks.js +64 -0
  48. package/lib/api/index.d.ts +10 -1
  49. package/lib/api/index.js +0 -1
  50. package/lib/api/inputs/base-inputs.d.ts +450 -3
  51. package/lib/api/inputs/base-inputs.js +12 -0
  52. package/lib/api/inputs/color-inputs.d.ts +14 -0
  53. package/lib/api/inputs/color-inputs.js +19 -0
  54. package/lib/api/inputs/engineering-inputs.d.ts +1539 -0
  55. package/lib/api/inputs/engineering-inputs.js +2181 -0
  56. package/lib/api/inputs/index.d.ts +2 -0
  57. package/lib/api/inputs/index.js +2 -0
  58. package/lib/api/inputs/io-inputs.d.ts +8 -1
  59. package/lib/api/inputs/io-inputs.js +4 -1
  60. package/lib/api/inputs/math-inputs.d.ts +61 -0
  61. package/lib/api/inputs/math-inputs.js +85 -0
  62. package/lib/api/inputs/mesh-inputs.d.ts +170 -0
  63. package/lib/api/inputs/mesh-inputs.js +206 -0
  64. package/lib/api/inputs/point-inputs.d.ts +4 -4
  65. package/lib/api/inputs/polyline-inputs.d.ts +144 -0
  66. package/lib/api/inputs/polyline-inputs.js +151 -0
  67. package/lib/api/inputs/recipes-inputs.d.ts +76 -0
  68. package/lib/api/inputs/recipes-inputs.js +74 -0
  69. package/lib/api/inputs/transforms-inputs.d.ts +34 -0
  70. package/lib/api/inputs/transforms-inputs.js +35 -0
  71. package/lib/api/keys/ansi-keys.constants.d.ts +3 -0
  72. package/lib/api/keys/ansi-keys.constants.js +16 -0
  73. package/lib/api/keys/ansi-keys.d.ts +3 -0
  74. package/lib/api/keys/ansi-keys.js +14 -0
  75. package/lib/api/keys/din-keys.constants.d.ts +3 -0
  76. package/lib/api/keys/din-keys.constants.js +14 -0
  77. package/lib/api/keys/din-keys.d.ts +3 -0
  78. package/lib/api/keys/din-keys.js +13 -0
  79. package/lib/api/keys/key-types.d.ts +17 -0
  80. package/lib/api/keys/key-types.js +1 -0
  81. package/lib/api/keys/keys.constants.d.ts +1 -0
  82. package/lib/api/keys/keys.constants.js +1 -0
  83. package/lib/api/knurls/ansi-knurls.constants.d.ts +4 -0
  84. package/lib/api/knurls/ansi-knurls.constants.js +8 -0
  85. package/lib/api/knurls/ansi-knurls.d.ts +3 -0
  86. package/lib/api/knurls/ansi-knurls.js +20 -0
  87. package/lib/api/knurls/din-knurls.constants.d.ts +2 -0
  88. package/lib/api/knurls/din-knurls.constants.js +2 -0
  89. package/lib/api/knurls/din-knurls.d.ts +3 -0
  90. package/lib/api/knurls/din-knurls.js +19 -0
  91. package/lib/api/knurls/knurl-types.d.ts +24 -0
  92. package/lib/api/knurls/knurl-types.js +1 -0
  93. package/lib/api/knurls/knurls.constants.d.ts +1 -0
  94. package/lib/api/knurls/knurls.constants.js +1 -0
  95. package/lib/api/knurls/knurls.d.ts +2 -0
  96. package/lib/api/knurls/knurls.js +9 -0
  97. package/lib/api/recipes/checks.d.ts +15 -0
  98. package/lib/api/recipes/checks.js +85 -0
  99. package/lib/api/recipes/limits.constants.d.ts +4 -0
  100. package/lib/api/recipes/limits.constants.js +4 -0
  101. package/lib/api/recipes/sources.d.ts +0 -13
  102. package/lib/api/recipes/sources.js +3 -15
  103. package/lib/api/recipes/surface-mesh.d.ts +0 -14
  104. package/lib/api/recipes/surface-mesh.js +8 -21
  105. package/lib/api/recipes/validate-brep.d.ts +2 -0
  106. package/lib/api/recipes/validate-brep.js +330 -0
  107. package/lib/api/recipes/validate.d.ts +0 -31
  108. package/lib/api/recipes/validate.js +7 -115
  109. package/lib/api/resolved-inputs/index.d.ts +80 -0
  110. package/lib/api/retaining-rings/ansi-retaining-rings.constants.d.ts +4 -0
  111. package/lib/api/retaining-rings/ansi-retaining-rings.constants.js +93 -0
  112. package/lib/api/retaining-rings/ansi-retaining-rings.d.ts +4 -0
  113. package/lib/api/retaining-rings/ansi-retaining-rings.js +20 -0
  114. package/lib/api/retaining-rings/din-retaining-rings.constants.d.ts +3 -0
  115. package/lib/api/retaining-rings/din-retaining-rings.constants.js +115 -0
  116. package/lib/api/retaining-rings/din-retaining-rings.d.ts +4 -0
  117. package/lib/api/retaining-rings/din-retaining-rings.js +20 -0
  118. package/lib/api/retaining-rings/retaining-ring-types.d.ts +30 -0
  119. package/lib/api/retaining-rings/retaining-ring-types.js +1 -0
  120. package/lib/api/retaining-rings/retaining-rings.constants.d.ts +1 -0
  121. package/lib/api/retaining-rings/retaining-rings.constants.js +1 -0
  122. package/lib/api/retaining-rings/retaining-rings.d.ts +2 -0
  123. package/lib/api/retaining-rings/retaining-rings.js +9 -0
  124. package/lib/api/services/base-bitbybit.d.ts +42 -0
  125. package/lib/api/services/base-bitbybit.js +43 -0
  126. package/lib/api/services/color.d.ts +35 -2
  127. package/lib/api/services/color.js +48 -12
  128. package/lib/api/services/engineering/engineering.d.ts +12 -0
  129. package/lib/api/services/engineering/engineering.js +13 -0
  130. package/lib/api/services/engineering/index.d.ts +2 -0
  131. package/lib/api/services/engineering/index.js +2 -0
  132. package/lib/api/services/engineering/mechanical/bearings-ansi.d.ts +40 -0
  133. package/lib/api/services/engineering/mechanical/bearings-ansi.js +47 -0
  134. package/lib/api/services/engineering/mechanical/bearings-iso.d.ts +39 -0
  135. package/lib/api/services/engineering/mechanical/bearings-iso.js +46 -0
  136. package/lib/api/services/engineering/mechanical/bearings.d.ts +14 -0
  137. package/lib/api/services/engineering/mechanical/bearings.js +15 -0
  138. package/lib/api/services/engineering/mechanical/fasteners-ansi.d.ts +109 -0
  139. package/lib/api/services/engineering/mechanical/fasteners-ansi.js +133 -0
  140. package/lib/api/services/engineering/mechanical/fasteners-iso.d.ts +123 -0
  141. package/lib/api/services/engineering/mechanical/fasteners-iso.js +151 -0
  142. package/lib/api/services/engineering/mechanical/fasteners.d.ts +13 -0
  143. package/lib/api/services/engineering/mechanical/fasteners.js +14 -0
  144. package/lib/api/services/engineering/mechanical/gears.d.ts +267 -0
  145. package/lib/api/services/engineering/mechanical/gears.js +318 -0
  146. package/lib/api/services/engineering/mechanical/index.d.ts +24 -0
  147. package/lib/api/services/engineering/mechanical/index.js +24 -0
  148. package/lib/api/services/engineering/mechanical/keys-ansi.d.ts +27 -0
  149. package/lib/api/services/engineering/mechanical/keys-ansi.js +32 -0
  150. package/lib/api/services/engineering/mechanical/keys-din.d.ts +26 -0
  151. package/lib/api/services/engineering/mechanical/keys-din.js +31 -0
  152. package/lib/api/services/engineering/mechanical/keys.d.ts +14 -0
  153. package/lib/api/services/engineering/mechanical/keys.js +15 -0
  154. package/lib/api/services/engineering/mechanical/knurls-ansi.d.ts +26 -0
  155. package/lib/api/services/engineering/mechanical/knurls-ansi.js +31 -0
  156. package/lib/api/services/engineering/mechanical/knurls-din.d.ts +26 -0
  157. package/lib/api/services/engineering/mechanical/knurls-din.js +31 -0
  158. package/lib/api/services/engineering/mechanical/knurls.d.ts +14 -0
  159. package/lib/api/services/engineering/mechanical/knurls.js +15 -0
  160. package/lib/api/services/engineering/mechanical/mechanical.d.ts +29 -0
  161. package/lib/api/services/engineering/mechanical/mechanical.js +30 -0
  162. package/lib/api/services/engineering/mechanical/retaining-rings-ansi.d.ts +43 -0
  163. package/lib/api/services/engineering/mechanical/retaining-rings-ansi.js +51 -0
  164. package/lib/api/services/engineering/mechanical/retaining-rings-din.d.ts +43 -0
  165. package/lib/api/services/engineering/mechanical/retaining-rings-din.js +51 -0
  166. package/lib/api/services/engineering/mechanical/retaining-rings.d.ts +13 -0
  167. package/lib/api/services/engineering/mechanical/retaining-rings.js +14 -0
  168. package/lib/api/services/engineering/mechanical/splines-ansi.d.ts +27 -0
  169. package/lib/api/services/engineering/mechanical/splines-ansi.js +32 -0
  170. package/lib/api/services/engineering/mechanical/splines-din.d.ts +26 -0
  171. package/lib/api/services/engineering/mechanical/splines-din.js +31 -0
  172. package/lib/api/services/engineering/mechanical/splines.d.ts +13 -0
  173. package/lib/api/services/engineering/mechanical/splines.js +14 -0
  174. package/lib/api/services/engineering/mechanical/springs.d.ts +27 -0
  175. package/lib/api/services/engineering/mechanical/springs.js +31 -0
  176. package/lib/api/services/engineering/mechanical/threads-ansi.d.ts +40 -0
  177. package/lib/api/services/engineering/mechanical/threads-ansi.js +48 -0
  178. package/lib/api/services/engineering/mechanical/threads-iso.d.ts +40 -0
  179. package/lib/api/services/engineering/mechanical/threads-iso.js +48 -0
  180. package/lib/api/services/engineering/mechanical/threads.d.ts +13 -0
  181. package/lib/api/services/engineering/mechanical/threads.js +14 -0
  182. package/lib/api/services/frame.js +3 -3
  183. package/lib/api/services/geometry-helper.js +8 -111
  184. package/lib/api/services/helpers/color/color-space.d.ts +2 -0
  185. package/lib/api/services/helpers/color/color-space.js +12 -0
  186. package/lib/api/services/helpers/{nurbs.d.ts → curves/nurbs.d.ts} +1 -1
  187. package/lib/api/services/helpers/{surface-triangulation.d.ts → curves/surface-triangulation.d.ts} +2 -2
  188. package/lib/api/services/helpers/{surface-triangulation.js → curves/surface-triangulation.js} +14 -8
  189. package/lib/api/services/helpers/{dxf → files/dxf}/dxf-generator.d.ts +2 -1
  190. package/lib/api/services/helpers/{dxf → files/dxf}/dxf-generator.js +19 -5
  191. package/lib/api/services/helpers/files/dxf/dxf.constants.d.ts +4 -0
  192. package/lib/api/services/helpers/files/dxf/dxf.constants.js +4 -0
  193. package/lib/api/services/helpers/{dxf → files/dxf}/dxf.d.ts +1 -1
  194. package/lib/api/services/helpers/{dxf → files/dxf}/dxf.js +2 -2
  195. package/lib/api/services/helpers/files/glb.constants.d.ts +11 -0
  196. package/lib/api/services/helpers/files/glb.constants.js +11 -0
  197. package/lib/api/services/helpers/files/glb.d.ts +1 -0
  198. package/lib/api/services/helpers/files/glb.js +69 -0
  199. package/lib/api/services/helpers/files/gzip.constants.d.ts +11 -0
  200. package/lib/api/services/helpers/files/gzip.constants.js +11 -0
  201. package/lib/api/services/helpers/files/gzip.d.ts +2 -0
  202. package/lib/api/services/helpers/files/gzip.js +52 -0
  203. package/lib/api/services/helpers/{inflate.constants.d.ts → files/inflate.constants.d.ts} +1 -0
  204. package/lib/api/services/helpers/{inflate.constants.js → files/inflate.constants.js} +1 -0
  205. package/lib/api/services/helpers/{inflate.d.ts → files/inflate.d.ts} +1 -1
  206. package/lib/api/services/helpers/{inflate.js → files/inflate.js} +5 -4
  207. package/lib/api/services/helpers/{zip.d.ts → files/zip.d.ts} +1 -1
  208. package/lib/api/services/helpers/geometry/arcs.d.ts +9 -0
  209. package/lib/api/services/helpers/{arcs.js → geometry/arcs.js} +7 -0
  210. package/lib/api/services/helpers/{frame-axes.d.ts → geometry/frame-axes.d.ts} +8 -5
  211. package/lib/api/services/helpers/{frame-axes.js → geometry/frame-axes.js} +21 -9
  212. package/lib/api/services/helpers/geometry/lengths.constants.d.ts +4 -0
  213. package/lib/api/services/helpers/geometry/lengths.constants.js +3 -0
  214. package/lib/api/services/helpers/geometry/lengths.d.ts +7 -0
  215. package/lib/api/services/helpers/geometry/lengths.js +20 -0
  216. package/lib/api/services/helpers/geometry/matrices.constants.d.ts +8 -0
  217. package/lib/api/services/helpers/geometry/matrices.constants.js +7 -0
  218. package/lib/api/services/helpers/geometry/matrices.d.ts +17 -0
  219. package/lib/api/services/helpers/{matrices.js → geometry/matrices.js} +28 -17
  220. package/lib/api/services/helpers/{paths.d.ts → geometry/paths.d.ts} +2 -1
  221. package/lib/api/services/helpers/{paths.js → geometry/paths.js} +36 -30
  222. package/lib/api/services/helpers/{polygons.d.ts → geometry/polygons.d.ts} +1 -1
  223. package/lib/api/services/helpers/geometry/polygons.js +111 -0
  224. package/lib/api/services/helpers/geometry/scalars.d.ts +9 -0
  225. package/lib/api/services/helpers/geometry/scalars.js +34 -0
  226. package/lib/api/services/helpers/{triangulation.js → geometry/triangulation.js} +11 -6
  227. package/lib/api/services/helpers/geometry/vector-grid.d.ts +12 -0
  228. package/lib/api/services/helpers/geometry/vector-grid.js +149 -0
  229. package/lib/api/services/helpers/{vectors.d.ts → geometry/vectors.d.ts} +8 -1
  230. package/lib/api/services/helpers/geometry/vectors.js +43 -0
  231. package/lib/api/services/helpers/helper-types.d.ts +57 -0
  232. package/lib/api/services/helpers/mesh/mesh-normals.d.ts +21 -0
  233. package/lib/api/services/helpers/{mesh-normals.js → mesh/mesh-normals.js} +54 -65
  234. package/lib/api/services/helpers/mesh/mesh-orientation.d.ts +24 -0
  235. package/lib/api/services/helpers/mesh/mesh-orientation.js +104 -0
  236. package/lib/api/services/helpers/{mesh-primitives.d.ts → mesh/mesh-primitives.d.ts} +1 -1
  237. package/lib/api/services/helpers/{mesh-primitives.js → mesh/mesh-primitives.js} +6 -5
  238. package/lib/api/services/helpers/mesh/mesh-proximity.constants.d.ts +7 -0
  239. package/lib/api/services/helpers/mesh/mesh-proximity.constants.js +11 -0
  240. package/lib/api/services/helpers/mesh/mesh-proximity.d.ts +11 -0
  241. package/lib/api/services/helpers/mesh/mesh-proximity.js +382 -0
  242. package/lib/api/services/index.d.ts +3 -0
  243. package/lib/api/services/index.js +3 -0
  244. package/lib/api/services/io.d.ts +1 -1
  245. package/lib/api/services/io.js +1 -1
  246. package/lib/api/services/line.js +2 -3
  247. package/lib/api/services/math.d.ts +47 -0
  248. package/lib/api/services/math.js +77 -10
  249. package/lib/api/services/mesh.d.ts +174 -2
  250. package/lib/api/services/mesh.js +305 -7
  251. package/lib/api/services/point.js +4 -10
  252. package/lib/api/services/polyline-types.d.ts +6 -0
  253. package/lib/api/services/polyline-types.js +1 -0
  254. package/lib/api/services/polyline.d.ts +163 -1
  255. package/lib/api/services/polyline.js +270 -13
  256. package/lib/api/services/recipes.d.ts +80 -0
  257. package/lib/api/services/recipes.js +107 -0
  258. package/lib/api/services/transforms.d.ts +74 -2
  259. package/lib/api/services/transforms.js +100 -3
  260. package/lib/api/services/vector.d.ts +4 -3
  261. package/lib/api/services/vector.js +14 -14
  262. package/lib/api/splines/ansi-splines.constants.d.ts +9 -0
  263. package/lib/api/splines/ansi-splines.constants.js +9 -0
  264. package/lib/api/splines/ansi-splines.d.ts +3 -0
  265. package/lib/api/splines/ansi-splines.js +28 -0
  266. package/lib/api/splines/din-splines.constants.d.ts +12 -0
  267. package/lib/api/splines/din-splines.constants.js +12 -0
  268. package/lib/api/splines/din-splines.d.ts +3 -0
  269. package/lib/api/splines/din-splines.js +38 -0
  270. package/lib/api/splines/spline-types.d.ts +32 -0
  271. package/lib/api/splines/spline-types.js +1 -0
  272. package/lib/api/splines/splines.constants.d.ts +1 -0
  273. package/lib/api/splines/splines.constants.js +1 -0
  274. package/lib/api/springs/spring-types.d.ts +26 -0
  275. package/lib/api/springs/spring-types.js +1 -0
  276. package/lib/api/springs/springs.constants.d.ts +9 -0
  277. package/lib/api/springs/springs.constants.js +9 -0
  278. package/lib/api/springs/springs.d.ts +2 -0
  279. package/lib/api/springs/springs.js +50 -0
  280. package/lib/api/threads/ansi-threads.constants.d.ts +6 -0
  281. package/lib/api/threads/ansi-threads.constants.js +27 -0
  282. package/lib/api/threads/ansi-threads.d.ts +4 -0
  283. package/lib/api/threads/ansi-threads.js +50 -0
  284. package/lib/api/threads/iso-threads.constants.d.ts +5 -0
  285. package/lib/api/threads/iso-threads.constants.js +20 -0
  286. package/lib/api/threads/iso-threads.d.ts +4 -0
  287. package/lib/api/threads/iso-threads.js +32 -0
  288. package/lib/api/threads/thread-profile.constants.d.ts +3 -0
  289. package/lib/api/threads/thread-profile.constants.js +3 -0
  290. package/lib/api/threads/thread-types.d.ts +66 -0
  291. package/lib/api/threads/thread-types.js +1 -0
  292. package/package.json +1 -1
  293. package/lib/api/recipes/index.d.ts +0 -4
  294. package/lib/api/recipes/index.js +0 -3
  295. package/lib/api/services/helpers/arcs.d.ts +0 -6
  296. package/lib/api/services/helpers/matrices.constants.d.ts +0 -2
  297. package/lib/api/services/helpers/matrices.constants.js +0 -2
  298. package/lib/api/services/helpers/matrices.d.ts +0 -25
  299. package/lib/api/services/helpers/mesh-normals.d.ts +0 -11
  300. package/lib/api/services/helpers/polygons.js +0 -59
  301. package/lib/api/services/helpers/vectors.js +0 -17
  302. /package/lib/api/services/helpers/{nurbs.js → curves/nurbs.js} +0 -0
  303. /package/lib/api/services/helpers/{crc32.d.ts → files/crc32.d.ts} +0 -0
  304. /package/lib/api/services/helpers/{crc32.js → files/crc32.js} +0 -0
  305. /package/lib/api/services/helpers/{zip.constants.d.ts → files/zip.constants.d.ts} +0 -0
  306. /package/lib/api/services/helpers/{zip.constants.js → files/zip.constants.js} +0 -0
  307. /package/lib/api/services/helpers/{zip.js → files/zip.js} +0 -0
  308. /package/lib/api/services/helpers/{triangulation.d.ts → geometry/triangulation.d.ts} +0 -0
  309. /package/lib/api/services/helpers/{mesh-measures.d.ts → mesh/mesh-measures.d.ts} +0 -0
  310. /package/lib/api/services/helpers/{mesh-measures.js → mesh/mesh-measures.js} +0 -0
  311. /package/lib/api/services/helpers/{mesh-primitives.constants.d.ts → mesh/mesh-primitives.constants.d.ts} +0 -0
  312. /package/lib/api/services/helpers/{mesh-primitives.constants.js → mesh/mesh-primitives.constants.js} +0 -0
@@ -6,13 +6,84 @@ import type { Vector } from "./vector";
6
6
  * Builds transformation matrices for moving, rotating, scaling and stretching geometry. A
7
7
  * transformation is a 4x4 matrix as 16 numbers in column-major order; most methods return a short
8
8
  * list of them that is applied in order, so a rotation about a point is a move to the origin, the
9
- * rotation, and the move back. Angles are in degrees. Apply the result with the transform methods
10
- * of `point`, `polyline`, `line` and the kernels.
9
+ * rotation, and the move back. Angles are in degrees. Such a list can also be combined into one
10
+ * matrix, undone, and read for whether it keeps shapes rigid. Apply the result with the transform
11
+ * methods of `point`, `polyline`, `line` and the kernels.
11
12
  */
12
13
  export declare class Transforms {
13
14
  private readonly vector;
14
15
  private readonly math;
15
16
  constructor(vector: Vector, math: MathBitByBit);
17
+ /**
18
+ * Folds a transformation into the one matrix that does all its steps in order.
19
+ *
20
+ * The lists `rotationCenterAxis` and the other builders return become a single matrix, which is
21
+ * what a renderer or a placement often wants. An empty list gives the identity.
22
+ * Example: a move by [1,0,0] followed by a move by [0,2,0] -> one move by [1,2,0]
23
+ * @param inputs - The transformation: a matrix, or a list applied in order
24
+ * @returns A list holding the one combined matrix
25
+ * @group combine
26
+ * @shortname combine
27
+ * @drawable false
28
+ * @example
29
+ * ```typescript
30
+ * const turn = bitbybit.transforms.rotationCenterAxis({ center: [5, 0, 0], axis: [0, 1, 0], angle: 90 });
31
+ * const single = bitbybit.transforms.combine({ transformation: turn });
32
+ * ```
33
+ */
34
+ combine(inputs: Inputs.Transforms.TransformationDto): Base.TransformMatrixes;
35
+ /**
36
+ * Builds the transformation that undoes one that only moves and turns.
37
+ *
38
+ * The transformation is combined first. One that scales, stretches or mirrors is refused, since
39
+ * undoing it exactly takes a general inverse; `isRigid` tells the two apart.
40
+ * Example: a quarter turn about Z, then a move by [10,0,0] -> the move back, then the turn back
41
+ * @param inputs - The transformation: a matrix, or a list applied in order
42
+ * @returns A list holding the one matrix that undoes it
43
+ * @group combine
44
+ * @shortname rigid inverse
45
+ * @drawable false
46
+ * @example
47
+ * ```typescript
48
+ * const placement = bitbybit.transforms.rotationCenterAxis({ center: [0, 0, 0], axis: [0, 0, 1], angle: 90 });
49
+ * const back = bitbybit.transforms.rigidInverse({ transformation: placement });
50
+ * ```
51
+ */
52
+ rigidInverse(inputs: Inputs.Transforms.TransformationDto): Base.TransformMatrixes;
53
+ /**
54
+ * Measures how a transformation scales volumes, and whether it mirrors.
55
+ *
56
+ * It is the determinant of the combined matrix's turn-and-scale part: 1 for a move and turn, the
57
+ * volume factor for a scale, negative when the transformation mirrors.
58
+ * Example: a uniform scale by 2 -> 8
59
+ * @param inputs - The transformation: a matrix, or a list applied in order
60
+ * @returns The determinant
61
+ * @group combine
62
+ * @shortname determinant
63
+ * @drawable false
64
+ * @example
65
+ * ```typescript
66
+ * const factor = bitbybit.transforms.determinant({ transformation: bitbybit.transforms.uniformScale({ scale: 2 }) });
67
+ * ```
68
+ */
69
+ determinant(inputs: Inputs.Transforms.TransformationDto): number;
70
+ /**
71
+ * Tells whether a transformation only moves and turns, without scaling, stretching or mirroring.
72
+ *
73
+ * The transformation is combined first; each of its axes must have length 1 and stand square to
74
+ * the others within `tolerance`.
75
+ * Example: a rotation -> true, a scale by 2 -> false
76
+ * @param inputs - The transformation and the tolerance
77
+ * @returns True when it is a rigid motion
78
+ * @group combine
79
+ * @shortname is rigid
80
+ * @drawable false
81
+ * @example
82
+ * ```typescript
83
+ * const rigid = bitbybit.transforms.isRigid({ transformation: bitbybit.transforms.rotationCenterX({ center: [0, 0, 0], angle: 30 }) });
84
+ * ```
85
+ */
86
+ isRigid(inputs: Inputs.Transforms.TransformationToleranceDto): boolean;
16
87
  /**
17
88
  * Builds a rotation about an axis that passes through a center point.
18
89
  *
@@ -239,4 +310,5 @@ export declare class Transforms {
239
310
  private rotationYawPitchRoll;
240
311
  private rotationMatrixFromQuat;
241
312
  private stretchDirection;
313
+ private matricesOf;
242
314
  }
@@ -1,17 +1,105 @@
1
1
  import * as Inputs from "../inputs";
2
- import { resolveDto } from "../kernel-calls";
2
+ import { InputError, resolveDto } from "../kernel-calls";
3
+ import { composed, isRigidMatrix, isTransformMatrix, linearDeterminant, rigidInverse } from "./helpers/geometry/matrices";
3
4
  /**
4
5
  * Builds transformation matrices for moving, rotating, scaling and stretching geometry. A
5
6
  * transformation is a 4x4 matrix as 16 numbers in column-major order; most methods return a short
6
7
  * list of them that is applied in order, so a rotation about a point is a move to the origin, the
7
- * rotation, and the move back. Angles are in degrees. Apply the result with the transform methods
8
- * of `point`, `polyline`, `line` and the kernels.
8
+ * rotation, and the move back. Angles are in degrees. Such a list can also be combined into one
9
+ * matrix, undone, and read for whether it keeps shapes rigid. Apply the result with the transform
10
+ * methods of `point`, `polyline`, `line` and the kernels.
9
11
  */
10
12
  export class Transforms {
11
13
  constructor(vector, math) {
12
14
  this.vector = vector;
13
15
  this.math = math;
14
16
  }
17
+ /**
18
+ * Folds a transformation into the one matrix that does all its steps in order.
19
+ *
20
+ * The lists `rotationCenterAxis` and the other builders return become a single matrix, which is
21
+ * what a renderer or a placement often wants. An empty list gives the identity.
22
+ * Example: a move by [1,0,0] followed by a move by [0,2,0] -> one move by [1,2,0]
23
+ * @param inputs - The transformation: a matrix, or a list applied in order
24
+ * @returns A list holding the one combined matrix
25
+ * @group combine
26
+ * @shortname combine
27
+ * @drawable false
28
+ * @example
29
+ * ```typescript
30
+ * const turn = bitbybit.transforms.rotationCenterAxis({ center: [5, 0, 0], axis: [0, 1, 0], angle: 90 });
31
+ * const single = bitbybit.transforms.combine({ transformation: turn });
32
+ * ```
33
+ */
34
+ combine(inputs) {
35
+ return [composed(this.matricesOf(inputs.transformation))];
36
+ }
37
+ /**
38
+ * Builds the transformation that undoes one that only moves and turns.
39
+ *
40
+ * The transformation is combined first. One that scales, stretches or mirrors is refused, since
41
+ * undoing it exactly takes a general inverse; `isRigid` tells the two apart.
42
+ * Example: a quarter turn about Z, then a move by [10,0,0] -> the move back, then the turn back
43
+ * @param inputs - The transformation: a matrix, or a list applied in order
44
+ * @returns A list holding the one matrix that undoes it
45
+ * @group combine
46
+ * @shortname rigid inverse
47
+ * @drawable false
48
+ * @example
49
+ * ```typescript
50
+ * const placement = bitbybit.transforms.rotationCenterAxis({ center: [0, 0, 0], axis: [0, 0, 1], angle: 90 });
51
+ * const back = bitbybit.transforms.rigidInverse({ transformation: placement });
52
+ * ```
53
+ */
54
+ rigidInverse(inputs) {
55
+ const matrix = composed(this.matricesOf(inputs.transformation));
56
+ if (!isRigidMatrix(matrix)) {
57
+ throw new InputError("`transformation` scales, stretches or mirrors; only one that moves and turns is undone here.", "transformation");
58
+ }
59
+ return [rigidInverse(matrix)];
60
+ }
61
+ /**
62
+ * Measures how a transformation scales volumes, and whether it mirrors.
63
+ *
64
+ * It is the determinant of the combined matrix's turn-and-scale part: 1 for a move and turn, the
65
+ * volume factor for a scale, negative when the transformation mirrors.
66
+ * Example: a uniform scale by 2 -> 8
67
+ * @param inputs - The transformation: a matrix, or a list applied in order
68
+ * @returns The determinant
69
+ * @group combine
70
+ * @shortname determinant
71
+ * @drawable false
72
+ * @example
73
+ * ```typescript
74
+ * const factor = bitbybit.transforms.determinant({ transformation: bitbybit.transforms.uniformScale({ scale: 2 }) });
75
+ * ```
76
+ */
77
+ determinant(inputs) {
78
+ return linearDeterminant(composed(this.matricesOf(inputs.transformation)));
79
+ }
80
+ /**
81
+ * Tells whether a transformation only moves and turns, without scaling, stretching or mirroring.
82
+ *
83
+ * The transformation is combined first; each of its axes must have length 1 and stand square to
84
+ * the others within `tolerance`.
85
+ * Example: a rotation -> true, a scale by 2 -> false
86
+ * @param inputs - The transformation and the tolerance
87
+ * @returns True when it is a rigid motion
88
+ * @group combine
89
+ * @shortname is rigid
90
+ * @drawable false
91
+ * @example
92
+ * ```typescript
93
+ * const rigid = bitbybit.transforms.isRigid({ transformation: bitbybit.transforms.rotationCenterX({ center: [0, 0, 0], angle: 30 }) });
94
+ * ```
95
+ */
96
+ isRigid(inputs) {
97
+ const resolved = resolveDto(Inputs.Transforms.TransformationToleranceDto, inputs);
98
+ if (!(resolved.tolerance >= 0)) {
99
+ throw new InputError("`tolerance` is not a number of 0 or more.", "tolerance");
100
+ }
101
+ return isRigidMatrix(composed(this.matricesOf(resolved.transformation)), resolved.tolerance);
102
+ }
15
103
  /**
16
104
  * Builds a rotation about an axis that passes through a center point.
17
105
  *
@@ -418,4 +506,13 @@ export class Transforms {
418
506
  ];
419
507
  return m;
420
508
  }
509
+ matricesOf(transformation) {
510
+ const given = isTransformMatrix(transformation) ? [transformation] : transformation;
511
+ const nested = Array.isArray(given) && given.length > 0 && given.every(entry => Array.isArray(entry) && !isTransformMatrix(entry));
512
+ const list = nested ? given.flat() : given;
513
+ if (!Array.isArray(list) || !list.every(isTransformMatrix)) {
514
+ throw new InputError("`transformation` is not a matrix of 16 finite numbers, or a list of them.", "transformation");
515
+ }
516
+ return list;
517
+ }
421
518
  }
@@ -396,11 +396,12 @@ export declare class Vector {
396
396
  */
397
397
  norm(inputs: Inputs.Vector.VectorDto): number;
398
398
  /**
399
- * Scales a 3D vector to length 1 while keeping its direction.
399
+ * Scales a vector to length 1 while keeping its direction.
400
400
  *
401
- * A vector shorter than 1e-8 has no direction to keep, so the result is undefined.
401
+ * A vector shorter than 1e-8, or with a component that is not finite, has no direction to keep,
402
+ * so the result is undefined; a very long vector is scaled without overflowing.
402
403
  * Example: [3,4,0] -> [0.6,0.8,0]
403
- * @param inputs - The 3D vector to normalize
404
+ * @param inputs - The vector to normalize
404
405
  * @returns The unit vector, or undefined for a zero-length input
405
406
  * @group base
406
407
  * @shortname normalized
@@ -1,6 +1,9 @@
1
1
  import * as Inputs from "../inputs";
2
2
  import { resolveDto } from "../kernel-calls";
3
- import { cross3 } from "./helpers/vectors";
3
+ import { cross3, dot3, length3, unitVectorOf } from "./helpers/geometry/vectors";
4
+ import { uniqueVectors } from "./helpers/geometry/vector-grid";
5
+ import { angleOfCosine } from "./helpers/geometry/scalars";
6
+ const SHORTEST_DIRECTION = 1e-8;
4
7
  /**
5
8
  * Vector maths on plain number arrays. A vector is an array of numbers; in 3D it is `[x, y, z]`
6
9
  * with Y pointing up, the same shape as a point, so the two can be passed to each other's methods.
@@ -31,7 +34,7 @@ export class Vector {
31
34
  */
32
35
  removeAllDuplicateVectors(inputs) {
33
36
  const resolved = resolveDto(Inputs.Vector.RemoveAllDuplicateVectorsDto, inputs);
34
- return this.geometryHelper.removeAllDuplicateVectors(resolved.vectors, resolved.tolerance);
37
+ return uniqueVectors(resolved.vectors, resolved.tolerance).kept;
35
38
  }
36
39
  /**
37
40
  * Removes a vector when it repeats the one right before it; the same vector further away is
@@ -94,7 +97,7 @@ export class Vector {
94
97
  */
95
98
  angleBetween(inputs) {
96
99
  return this.math.radToDeg({
97
- number: Math.acos(this.dot({ first: inputs.first, second: inputs.second }) / (this.norm({ vector: inputs.first }) * this.norm({ vector: inputs.second })))
100
+ number: angleOfCosine(this.dot({ first: inputs.first, second: inputs.second }) / (this.norm({ vector: inputs.first }) * this.norm({ vector: inputs.second })))
98
101
  });
99
102
  }
100
103
  /**
@@ -493,11 +496,12 @@ export class Vector {
493
496
  return norm2 !== 0.0 ? Math.sqrt(norm2) : norm2;
494
497
  }
495
498
  /**
496
- * Scales a 3D vector to length 1 while keeping its direction.
499
+ * Scales a vector to length 1 while keeping its direction.
497
500
  *
498
- * A vector shorter than 1e-8 has no direction to keep, so the result is undefined.
501
+ * A vector shorter than 1e-8, or with a component that is not finite, has no direction to keep,
502
+ * so the result is undefined; a very long vector is scaled without overflowing.
499
503
  * Example: [3,4,0] -> [0.6,0.8,0]
500
- * @param inputs - The 3D vector to normalize
504
+ * @param inputs - The vector to normalize
501
505
  * @returns The unit vector, or undefined for a zero-length input
502
506
  * @group base
503
507
  * @shortname normalized
@@ -508,11 +512,8 @@ export class Vector {
508
512
  * ```
509
513
  */
510
514
  normalized(inputs) {
511
- const len = this.length({ vector: inputs.vector });
512
- if (len <= 1e-8) {
513
- return undefined;
514
- }
515
- return this.div({ scalar: this.norm(inputs), vector: inputs.vector });
515
+ const unit = unitVectorOf(inputs.vector);
516
+ return unit === undefined || !(this.norm(inputs) > SHORTEST_DIRECTION) ? undefined : unit;
516
517
  }
517
518
  /**
518
519
  * Finds the point at a given distance from a start point along a direction.
@@ -751,8 +752,7 @@ export class Vector {
751
752
  * ```
752
753
  */
753
754
  lengthSq(inputs) {
754
- const v = inputs.vector;
755
- return v[0] * v[0] + v[1] * v[1] + v[2] * v[2];
755
+ return dot3(inputs.vector, inputs.vector);
756
756
  }
757
757
  /**
758
758
  * Computes the length of a 3D vector.
@@ -769,7 +769,7 @@ export class Vector {
769
769
  * ```
770
770
  */
771
771
  length(inputs) {
772
- return Math.sqrt(this.lengthSq(inputs));
772
+ return length3(inputs.vector);
773
773
  }
774
774
  /**
775
775
  * Turns a list of number strings into numbers.
@@ -0,0 +1,9 @@
1
+ import type { AnsiSplinePitch } from "./spline-types";
2
+ export declare const ANSI_SPLINE_PITCHES: readonly AnsiSplinePitch[];
3
+ export declare const ANSI_SPLINE_PRESSURE_ANGLE = 30;
4
+ export declare const ANSI_SPLINE_ROOT_FILLET = 0.1;
5
+ export declare const ANSI_SPLINE_MAJOR_SHARE = 1;
6
+ export declare const ANSI_SPLINE_MINOR_SHARE = 1;
7
+ export declare const ANSI_SPLINE_FLAT_ROOT_SHARE = 1.35;
8
+ export declare const ANSI_SPLINE_LEAST_TEETH = 6;
9
+ export declare const ANSI_SPLINE_MOST_TEETH = 60;
@@ -0,0 +1,9 @@
1
+ import * as Inputs from "../inputs";
2
+ export const ANSI_SPLINE_PITCHES = Object.values(Inputs.Engineering.ansiSplinePitchEnum);
3
+ export const ANSI_SPLINE_PRESSURE_ANGLE = 30;
4
+ export const ANSI_SPLINE_ROOT_FILLET = 0.1;
5
+ export const ANSI_SPLINE_MAJOR_SHARE = 1;
6
+ export const ANSI_SPLINE_MINOR_SHARE = 1;
7
+ export const ANSI_SPLINE_FLAT_ROOT_SHARE = 1.35;
8
+ export const ANSI_SPLINE_LEAST_TEETH = 6;
9
+ export const ANSI_SPLINE_MOST_TEETH = 60;
@@ -0,0 +1,3 @@
1
+ import type { Base } from "../inputs/base-inputs";
2
+ import type { AnsiSplinePitch, InvoluteSplineSizes } from "./spline-types";
3
+ export declare function ansiInvoluteSplineSizes(teeth: number, pitch: AnsiSplinePitch, unit: `${Base.unitOfLengthEnum}`): InvoluteSplineSizes;
@@ -0,0 +1,28 @@
1
+ import { InputError } from "../kernel-calls/errors";
2
+ import { roundedToMillionths } from "../services/helpers/geometry/scalars";
3
+ import { lengthsConverted } from "../services/helpers/geometry/lengths";
4
+ import { ANSI_SPLINE_FLAT_ROOT_SHARE, ANSI_SPLINE_LEAST_TEETH, ANSI_SPLINE_MAJOR_SHARE, ANSI_SPLINE_MINOR_SHARE, ANSI_SPLINE_MOST_TEETH, ANSI_SPLINE_PITCHES, ANSI_SPLINE_PRESSURE_ANGLE, ANSI_SPLINE_ROOT_FILLET, } from "./ansi-splines.constants";
5
+ import { SPLINE_LENGTHS } from "./splines.constants";
6
+ export function ansiInvoluteSplineSizes(teeth, pitch, unit) {
7
+ if (!ANSI_SPLINE_PITCHES.includes(pitch)) {
8
+ throw new InputError(`\`pitch\` is ${String(pitch)}, not one ANSI B92.1 gives its 30 degree flat root side fit: ${ANSI_SPLINE_PITCHES.join(", ")}.`, "pitch");
9
+ }
10
+ if (!Number.isInteger(teeth) || teeth < ANSI_SPLINE_LEAST_TEETH || teeth > ANSI_SPLINE_MOST_TEETH) {
11
+ throw new InputError(`\`teeth\` is ${String(teeth)}, and a 30 degree ANSI B92.1 spline has a whole number from ${String(ANSI_SPLINE_LEAST_TEETH)} to ${String(ANSI_SPLINE_MOST_TEETH)}.`, "teeth");
12
+ }
13
+ const diametral = Number(pitch.split("/")[0]);
14
+ const across = (share) => roundedToMillionths((teeth + share) / diametral);
15
+ const sizes = {
16
+ referenceDiameter: across(0),
17
+ module: roundedToMillionths(1 / diametral),
18
+ teeth,
19
+ pressureAngle: ANSI_SPLINE_PRESSURE_ANGLE,
20
+ profileShift: 0,
21
+ rootFillet: ANSI_SPLINE_ROOT_FILLET,
22
+ shaftTipDiameter: across(ANSI_SPLINE_MAJOR_SHARE),
23
+ shaftRootDiameter: across(-ANSI_SPLINE_FLAT_ROOT_SHARE),
24
+ hubTipDiameter: across(-ANSI_SPLINE_MINOR_SHARE),
25
+ hubRootDiameter: across(ANSI_SPLINE_FLAT_ROOT_SHARE),
26
+ };
27
+ return lengthsConverted(sizes, SPLINE_LENGTHS, "in", unit);
28
+ }
@@ -0,0 +1,12 @@
1
+ export declare const SPLINE_PRESSURE_ANGLE = 30;
2
+ export declare const SPLINE_ROOT_FILLET = 0.16;
3
+ export declare const SPLINE_TIP_SHARE = 0.2;
4
+ export declare const SPLINE_HUB_TIP_SHARE = 2;
5
+ export declare const SPLINE_BASE_SHARE = 1.1;
6
+ export declare const SPLINE_DEDENDUM_SHARE = 0.55;
7
+ export declare const SPLINE_LEAST_SHIFT = -0.05;
8
+ export declare const SPLINE_MOST_SHIFT = 0.45;
9
+ export declare const SPLINE_MODULES: readonly number[];
10
+ export declare const SPLINE_LEAST_TEETH = 6;
11
+ export declare const SPLINE_MOST_TEETH = 82;
12
+ export declare const SHIFT_TOLERANCE = 1e-9;
@@ -0,0 +1,12 @@
1
+ export const SPLINE_PRESSURE_ANGLE = 30;
2
+ export const SPLINE_ROOT_FILLET = 0.16;
3
+ export const SPLINE_TIP_SHARE = 0.2;
4
+ export const SPLINE_HUB_TIP_SHARE = 2;
5
+ export const SPLINE_BASE_SHARE = 1.1;
6
+ export const SPLINE_DEDENDUM_SHARE = 0.55;
7
+ export const SPLINE_LEAST_SHIFT = -0.05;
8
+ export const SPLINE_MOST_SHIFT = 0.45;
9
+ export const SPLINE_MODULES = [0.5, 0.6, 0.75, 0.8, 1, 1.25, 1.5, 1.75, 2, 2.5, 3, 4, 5, 6, 8, 10];
10
+ export const SPLINE_LEAST_TEETH = 6;
11
+ export const SPLINE_MOST_TEETH = 82;
12
+ export const SHIFT_TOLERANCE = 1e-9;
@@ -0,0 +1,3 @@
1
+ import type { Base } from "../inputs/base-inputs";
2
+ import type { InvoluteSplineSizes } from "./spline-types";
3
+ export declare function dinInvoluteSplineSizes(referenceDiameter: number, module: number, unit: `${Base.unitOfLengthEnum}`): InvoluteSplineSizes;
@@ -0,0 +1,38 @@
1
+ import { InputError } from "../kernel-calls/errors";
2
+ import { roundedToMillionths } from "../services/helpers/geometry/scalars";
3
+ import { lengthsConverted } from "../services/helpers/geometry/lengths";
4
+ import { SHIFT_TOLERANCE, SPLINE_BASE_SHARE, SPLINE_DEDENDUM_SHARE, SPLINE_HUB_TIP_SHARE, SPLINE_LEAST_SHIFT, SPLINE_LEAST_TEETH, SPLINE_MODULES, SPLINE_MOST_SHIFT, SPLINE_MOST_TEETH, SPLINE_PRESSURE_ANGLE, SPLINE_ROOT_FILLET, SPLINE_TIP_SHARE, } from "./din-splines.constants";
5
+ import { SPLINE_LENGTHS } from "./splines.constants";
6
+ const shiftOf = (diameter, module, teeth) => (diameter - module * teeth - SPLINE_BASE_SHARE * module) / (2 * module);
7
+ export function dinInvoluteSplineSizes(referenceDiameter, module, unit) {
8
+ var _a;
9
+ if (!SPLINE_MODULES.includes(module)) {
10
+ throw new InputError(`\`module\` is ${String(module)}, not one of DIN 5480's: ${SPLINE_MODULES.join(", ")}.`, "module");
11
+ }
12
+ if (!(referenceDiameter > 0)) {
13
+ throw new InputError("`referenceDiameter` is not more than 0.", "referenceDiameter");
14
+ }
15
+ const ratio = referenceDiameter / module;
16
+ const fits = [Math.floor(ratio - 2), Math.floor(ratio - 2) + 1, Math.floor(ratio - 2) + 2].filter(teeth => {
17
+ const shift = shiftOf(referenceDiameter, module, teeth);
18
+ return shift >= SPLINE_LEAST_SHIFT - SHIFT_TOLERANCE && shift <= SPLINE_MOST_SHIFT + SHIFT_TOLERANCE;
19
+ });
20
+ const teeth = (_a = fits.find(count => count % 2 === 0)) !== null && _a !== void 0 ? _a : fits[0];
21
+ if (teeth === undefined || teeth < SPLINE_LEAST_TEETH || teeth > SPLINE_MOST_TEETH) {
22
+ throw new InputError(`A ${String(referenceDiameter)} spline of module ${String(module)} has no tooth count DIN 5480 allows: pick another module.`, "module");
23
+ }
24
+ const dedendum = SPLINE_DEDENDUM_SHARE * module;
25
+ const sizes = {
26
+ referenceDiameter,
27
+ module,
28
+ teeth,
29
+ pressureAngle: SPLINE_PRESSURE_ANGLE,
30
+ profileShift: roundedToMillionths(shiftOf(referenceDiameter, module, teeth)),
31
+ rootFillet: SPLINE_ROOT_FILLET,
32
+ shaftTipDiameter: roundedToMillionths(referenceDiameter - SPLINE_TIP_SHARE * module),
33
+ shaftRootDiameter: roundedToMillionths(referenceDiameter - SPLINE_BASE_SHARE * module - 2 * dedendum),
34
+ hubTipDiameter: roundedToMillionths(referenceDiameter - SPLINE_HUB_TIP_SHARE * module),
35
+ hubRootDiameter: roundedToMillionths(referenceDiameter - SPLINE_BASE_SHARE * module + 2 * dedendum),
36
+ };
37
+ return lengthsConverted(sizes, SPLINE_LENGTHS, "mm", unit);
38
+ }
@@ -0,0 +1,32 @@
1
+ import type * as Inputs from "../inputs";
2
+ /**
3
+ * An involute spline, from `splines.din.involuteSplineSizes` or `splines.ansi.involuteSplineSizes`:
4
+ * its teeth and the diameters of the shaft and the hub, in the unit asked for.
5
+ */
6
+ export interface InvoluteSplineSizes {
7
+ /** The diameter the spline is named by: DIN 5480's reference diameter, or ANSI B92.1's pitch diameter. */
8
+ readonly referenceDiameter: number;
9
+ /** The size of the teeth: the pitch circle's diameter divided by the number of teeth. */
10
+ readonly module: number;
11
+ /** How many teeth it has. */
12
+ readonly teeth: number;
13
+ /** The pressure angle, in degrees. */
14
+ readonly pressureAngle: number;
15
+ /** The shaft's profile shift, as a share of the module; the hub's is its negative. */
16
+ readonly profileShift: number;
17
+ /** The radius that rounds the bottom of the shaft's gaps, as a share of the module. */
18
+ readonly rootFillet: number;
19
+ /** The shaft's tip diameter. */
20
+ readonly shaftTipDiameter: number;
21
+ /** The shaft's root diameter. */
22
+ readonly shaftRootDiameter: number;
23
+ /** The hub's tip diameter, the smallest across its teeth. */
24
+ readonly hubTipDiameter: number;
25
+ /** The hub's root diameter, the largest across its gaps. */
26
+ readonly hubRootDiameter: number;
27
+ }
28
+ /**
29
+ * The diametral pitch of an ANSI B92.1 involute spline as the standard writes it, the pitch over the
30
+ * stub pitch, such as 16/32.
31
+ */
32
+ export type AnsiSplinePitch = `${Inputs.Engineering.ansiSplinePitchEnum}`;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export declare const SPLINE_LENGTHS: readonly ["referenceDiameter", "module", "shaftTipDiameter", "shaftRootDiameter", "hubTipDiameter", "hubRootDiameter"];
@@ -0,0 +1 @@
1
+ export const SPLINE_LENGTHS = ["referenceDiameter", "module", "shaftTipDiameter", "shaftRootDiameter", "hubTipDiameter", "hubRootDiameter"];
@@ -0,0 +1,26 @@
1
+ import type * as Inputs from "../inputs";
2
+ /**
3
+ * A compression spring with closed and ground ends, every value given: the shape
4
+ * `compressionSpringPath` reads.
5
+ */
6
+ export interface CompressionSpringSpec {
7
+ /** The diameter of the wire. */
8
+ readonly wireDiameter: number;
9
+ /** The outside diameter of the coils. */
10
+ readonly diameter: number;
11
+ /** How many coils spring, besides the closed coil at each end. */
12
+ readonly activeCoils: number;
13
+ /** The spring's length as it stands, from one ground end to the other. */
14
+ readonly length: number;
15
+ }
16
+ /**
17
+ * The centreline a compression spring's wire follows, from `compressionSpringPath`.
18
+ */
19
+ export interface CompressionSpringPath {
20
+ /** Points along the centreline, from below the bottom end to above the top, to interpolate through. */
21
+ readonly points: Inputs.Base.Point3[];
22
+ /** The rise of one active coil. */
23
+ readonly pitch: number;
24
+ /** The length the spring has when every coil closes onto the next. */
25
+ readonly solidLength: number;
26
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,9 @@
1
+ export declare const SPRING_POINTS_PER_COIL = 24;
2
+ export declare const MOST_ACTIVE_COILS = 1000;
3
+ export declare const SPRING_END_COILS = 1;
4
+ export declare const SPRING_EASE = 0.25;
5
+ export declare const SMALLEST_SPRING_INDEX = 3;
6
+ export declare const MIDPOINT = 0.5;
7
+ export declare const SPRING_CLOSED_RISE = 1.05;
8
+ export declare const SPRING_GRIND_OVERRUN = 0.75;
9
+ export declare const SPRING_ROUNDING_PLACES = 9;
@@ -0,0 +1,9 @@
1
+ export const SPRING_POINTS_PER_COIL = 24;
2
+ export const MOST_ACTIVE_COILS = 1000;
3
+ export const SPRING_END_COILS = 1;
4
+ export const SPRING_EASE = 0.25;
5
+ export const SMALLEST_SPRING_INDEX = 3;
6
+ export const MIDPOINT = 0.5;
7
+ export const SPRING_CLOSED_RISE = 1.05;
8
+ export const SPRING_GRIND_OVERRUN = 0.75;
9
+ export const SPRING_ROUNDING_PLACES = 9;
@@ -0,0 +1,2 @@
1
+ import type { CompressionSpringPath, CompressionSpringSpec } from "./spring-types";
2
+ export declare function compressionSpringPath(spec: CompressionSpringSpec): CompressionSpringPath;
@@ -0,0 +1,50 @@
1
+ import { InputError } from "../kernel-calls/errors";
2
+ import { roundedTo, smoothstep } from "../services/helpers/geometry/scalars";
3
+ import { polar2 } from "../services/helpers/geometry/vectors";
4
+ import { MIDPOINT, MOST_ACTIVE_COILS, SMALLEST_SPRING_INDEX, SPRING_CLOSED_RISE, SPRING_EASE, SPRING_END_COILS, SPRING_GRIND_OVERRUN, SPRING_POINTS_PER_COIL, SPRING_ROUNDING_PLACES } from "./springs.constants";
5
+ export function compressionSpringPath(spec) {
6
+ const { wireDiameter, diameter, activeCoils, length } = spec;
7
+ const infinite = Object.entries({ wireDiameter, diameter, activeCoils, length }).find(([, value]) => !Number.isFinite(value));
8
+ if (infinite !== undefined) {
9
+ throw new InputError(`\`${infinite[0]}\` is ${String(infinite[1])}; a spring is made of finite numbers.`, infinite[0]);
10
+ }
11
+ if (!(wireDiameter > 0)) {
12
+ throw new InputError("`wireDiameter` is not more than 0.", "wireDiameter");
13
+ }
14
+ if (!(diameter > SMALLEST_SPRING_INDEX * wireDiameter)) {
15
+ throw new InputError("`diameter`, the outside diameter of the coils, is not more than three times `wireDiameter`.", "diameter");
16
+ }
17
+ if (!(activeCoils > 0)) {
18
+ throw new InputError("`activeCoils` is not more than 0.", "activeCoils");
19
+ }
20
+ if (!(activeCoils <= MOST_ACTIVE_COILS)) {
21
+ throw new InputError(`\`activeCoils\` is more than ${String(MOST_ACTIVE_COILS)}, the most a spring path is drawn for.`, "activeCoils");
22
+ }
23
+ const coils = activeCoils + 2 * SPRING_END_COILS;
24
+ const closedRise = wireDiameter * SPRING_CLOSED_RISE;
25
+ const solidLength = roundedTo(closedRise * coils, SPRING_ROUNDING_PLACES);
26
+ if (!(length >= Math.min(solidLength, closedRise * coils))) {
27
+ throw new InputError(`\`length\` is shorter than the spring's solid length, ${String(solidLength)}, where every coil touches the next.`, "length");
28
+ }
29
+ const pitch = (length - 2 * SPRING_END_COILS * closedRise) / activeCoils;
30
+ const rise = (turn) => {
31
+ const leaving = smoothstep((turn - SPRING_END_COILS + SPRING_EASE) / (2 * SPRING_EASE));
32
+ const arriving = smoothstep((turn - (coils - SPRING_END_COILS) + SPRING_EASE) / (2 * SPRING_EASE));
33
+ return closedRise + (pitch - closedRise) * (leaving - arriving);
34
+ };
35
+ const count = Math.ceil(coils * SPRING_POINTS_PER_COIL);
36
+ const step = coils / count;
37
+ const heights = [0];
38
+ for (let index = 1; index <= count; index++) {
39
+ const middle = (index - MIDPOINT) * step;
40
+ heights.push(heights[index - 1] + rise(middle) * step);
41
+ }
42
+ const scale = length / heights[count];
43
+ const radius = (diameter - wireDiameter) / 2;
44
+ const overrun = Math.ceil(SPRING_GRIND_OVERRUN / step);
45
+ const pointAt = (turn, height) => [...polar2(radius, 2 * Math.PI * turn), height];
46
+ const before = Array.from({ length: overrun }, (_, index) => pointAt((index - overrun) * step, (index - overrun) * step * closedRise));
47
+ const after = Array.from({ length: overrun }, (_, index) => pointAt(coils + (index + 1) * step, length + (index + 1) * step * closedRise));
48
+ const points = [...before, ...heights.map((height, index) => pointAt(index * step, height * scale)), ...after];
49
+ return { points, pitch, solidLength };
50
+ }
@@ -0,0 +1,6 @@
1
+ import type { AnsiThreadRow, AnsiThreadSize } from "./thread-types";
2
+ export declare const ANSI_THREAD_SIZES: readonly AnsiThreadSize[];
3
+ export declare const UNIFIED_THREADS: Readonly<Record<AnsiThreadSize, AnsiThreadRow>>;
4
+ export declare const UNR_EXTERNAL_ROOT_FACTOR = 1.19078;
5
+ export declare const TAPPING_DEPTH_FACTOR = 0.974279;
6
+ export declare const ANSI_DRILL_STEP = 0.001;
@@ -0,0 +1,27 @@
1
+ import * as Inputs from "../inputs";
2
+ export const ANSI_THREAD_SIZES = Object.values(Inputs.Engineering.ansiThreadSizeEnum);
3
+ export const UNIFIED_THREADS = {
4
+ "#0": { diameter: 0.06, unc: undefined, unf: { threadsPerInch: 80, tapDrill: 0.046875 } },
5
+ "#1": { diameter: 0.073, unc: { threadsPerInch: 64, tapDrill: 0.0595 }, unf: { threadsPerInch: 72, tapDrill: 0.0595 } },
6
+ "#2": { diameter: 0.086, unc: { threadsPerInch: 56, tapDrill: 0.07 }, unf: { threadsPerInch: 64, tapDrill: 0.07 } },
7
+ "#3": { diameter: 0.099, unc: { threadsPerInch: 48, tapDrill: 0.0785 }, unf: { threadsPerInch: 56, tapDrill: 0.082 } },
8
+ "#4": { diameter: 0.112, unc: { threadsPerInch: 40, tapDrill: 0.089 }, unf: { threadsPerInch: 48, tapDrill: 0.0935 } },
9
+ "#5": { diameter: 0.125, unc: { threadsPerInch: 40, tapDrill: 0.1015 }, unf: { threadsPerInch: 44, tapDrill: 0.104 } },
10
+ "#6": { diameter: 0.138, unc: { threadsPerInch: 32, tapDrill: 0.1065 }, unf: { threadsPerInch: 40, tapDrill: 0.113 } },
11
+ "#8": { diameter: 0.164, unc: { threadsPerInch: 32, tapDrill: 0.136 }, unf: { threadsPerInch: 36, tapDrill: 0.136 } },
12
+ "#10": { diameter: 0.19, unc: { threadsPerInch: 24, tapDrill: 0.1495 }, unf: { threadsPerInch: 32, tapDrill: 0.159 } },
13
+ "#12": { diameter: 0.216, unc: { threadsPerInch: 24, tapDrill: 0.177 }, unf: { threadsPerInch: 28, tapDrill: 0.182 } },
14
+ "1/4": { diameter: 0.25, unc: { threadsPerInch: 20, tapDrill: 0.201 }, unf: { threadsPerInch: 28, tapDrill: 0.213 } },
15
+ "5/16": { diameter: 0.3125, unc: { threadsPerInch: 18, tapDrill: 0.257 }, unf: { threadsPerInch: 24, tapDrill: 0.272 } },
16
+ "3/8": { diameter: 0.375, unc: { threadsPerInch: 16, tapDrill: 0.3125 }, unf: { threadsPerInch: 24, tapDrill: 0.332 } },
17
+ "7/16": { diameter: 0.4375, unc: { threadsPerInch: 14, tapDrill: 0.368 }, unf: { threadsPerInch: 20, tapDrill: 0.390625 } },
18
+ "1/2": { diameter: 0.5, unc: { threadsPerInch: 13, tapDrill: 0.421875 }, unf: { threadsPerInch: 20, tapDrill: 0.453125 } },
19
+ "9/16": { diameter: 0.5625, unc: { threadsPerInch: 12, tapDrill: 0.484375 }, unf: { threadsPerInch: 18, tapDrill: 0.515625 } },
20
+ "5/8": { diameter: 0.625, unc: { threadsPerInch: 11, tapDrill: 0.53125 }, unf: { threadsPerInch: 18, tapDrill: 0.578125 } },
21
+ "3/4": { diameter: 0.75, unc: { threadsPerInch: 10, tapDrill: 0.65625 }, unf: { threadsPerInch: 16, tapDrill: 0.6875 } },
22
+ "7/8": { diameter: 0.875, unc: { threadsPerInch: 9, tapDrill: 0.765625 }, unf: { threadsPerInch: 14, tapDrill: 0.8125 } },
23
+ "1": { diameter: 1, unc: { threadsPerInch: 8, tapDrill: 0.875 }, unf: { threadsPerInch: 12, tapDrill: 0.921875 } },
24
+ };
25
+ export const UNR_EXTERNAL_ROOT_FACTOR = 1.19078;
26
+ export const TAPPING_DEPTH_FACTOR = 0.974279;
27
+ export const ANSI_DRILL_STEP = 0.001;
@@ -0,0 +1,4 @@
1
+ import type { AnsiThreadSize, AnsiThreadSizes } from "./thread-types";
2
+ export declare function checkedAnsiSize(size: AnsiThreadSize): AnsiThreadSize;
3
+ export declare function ansiThreadSizes(): AnsiThreadSize[];
4
+ export declare function ansiThread(size: AnsiThreadSize, series: "UNC" | "UNF", threadsPerInch?: number): AnsiThreadSizes;