@bitbybit-dev/base 1.5.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
@@ -0,0 +1,50 @@
1
+ import { InputError } from "../kernel-calls/errors";
2
+ import { roundedTo, roundedToMillionths } from "../services/helpers/geometry/scalars";
3
+ import { ANSI_DRILL_STEP, ANSI_THREAD_SIZES, TAPPING_DEPTH_FACTOR, UNIFIED_THREADS, UNR_EXTERNAL_ROOT_FACTOR } from "./ansi-threads.constants";
4
+ import { INTERNAL_DEPTH_FACTOR, PITCH_DEPTH_FACTOR } from "./thread-profile.constants";
5
+ const DRILL_PLACES = 3;
6
+ export function checkedAnsiSize(size) {
7
+ if (!ANSI_THREAD_SIZES.includes(size)) {
8
+ throw new InputError(`\`size\` is not one of ${ANSI_THREAD_SIZES.join(", ")}.`, "size");
9
+ }
10
+ return size;
11
+ }
12
+ export function ansiThreadSizes() {
13
+ return [...ANSI_THREAD_SIZES];
14
+ }
15
+ export function ansiThread(size, series, threadsPerInch) {
16
+ var _a, _b, _c, _d;
17
+ const row = UNIFIED_THREADS[checkedAnsiSize(size)];
18
+ if (series !== "UNC" && series !== "UNF") {
19
+ throw new InputError("`series` is not one of UNC, UNF.", "series");
20
+ }
21
+ const coarsest = ((_a = row.unc) !== null && _a !== void 0 ? _a : row.unf).threadsPerInch;
22
+ let pitchRow;
23
+ let named;
24
+ if (threadsPerInch === undefined) {
25
+ pitchRow = series === "UNC" ? (_b = row.unc) !== null && _b !== void 0 ? _b : row.unf : row.unf;
26
+ named = pitchRow === row.unc ? "UNC" : "UNF";
27
+ }
28
+ else {
29
+ if (!(threadsPerInch >= coarsest) || !Number.isFinite(threadsPerInch)) {
30
+ throw new InputError(`\`threadsPerInch\` is not a finite number of at least ${String(coarsest)}, the coarsest ${size} thread.`, "threadsPerInch");
31
+ }
32
+ pitchRow = [row.unc, row.unf].find(candidate => (candidate === null || candidate === void 0 ? void 0 : candidate.threadsPerInch) === threadsPerInch);
33
+ named = pitchRow === undefined ? "UN" : pitchRow === row.unc ? "UNC" : "UNF";
34
+ }
35
+ const perInch = (_c = pitchRow === null || pitchRow === void 0 ? void 0 : pitchRow.threadsPerInch) !== null && _c !== void 0 ? _c : threadsPerInch;
36
+ const pitch = 1 / perInch;
37
+ const tapDrill = (_d = pitchRow === null || pitchRow === void 0 ? void 0 : pitchRow.tapDrill) !== null && _d !== void 0 ? _d : roundedTo(Math.round((row.diameter - TAPPING_DEPTH_FACTOR * pitch) / ANSI_DRILL_STEP) * ANSI_DRILL_STEP, DRILL_PLACES);
38
+ return {
39
+ size,
40
+ series: named,
41
+ threadsPerInch: perInch,
42
+ designation: `${size}-${String(perInch)} ${named}`,
43
+ diameter: row.diameter,
44
+ pitch: roundedToMillionths(pitch),
45
+ pitchDiameter: roundedToMillionths(row.diameter - PITCH_DEPTH_FACTOR * pitch),
46
+ minorDiameter: roundedToMillionths(row.diameter - UNR_EXTERNAL_ROOT_FACTOR * pitch),
47
+ internalMinorDiameter: roundedToMillionths(row.diameter - INTERNAL_DEPTH_FACTOR * pitch),
48
+ tapDrill,
49
+ };
50
+ }
@@ -0,0 +1,5 @@
1
+ import type { IsoThreadRow, IsoThreadSize } from "./thread-types";
2
+ export declare const ISO_THREAD_SIZES: readonly IsoThreadSize[];
3
+ export declare const COARSE_THREADS: Readonly<Record<IsoThreadSize, IsoThreadRow>>;
4
+ export declare const ISO_EXTERNAL_ROOT_FACTOR = 1.226869;
5
+ export declare const ISO_DRILL_STEP = 0.05;
@@ -0,0 +1,20 @@
1
+ import * as Inputs from "../inputs";
2
+ export const ISO_THREAD_SIZES = Object.values(Inputs.Engineering.isoThreadSizeEnum);
3
+ export const COARSE_THREADS = {
4
+ "M1.6": { diameter: 1.6, pitch: 0.35, tapDrill: 1.25 },
5
+ "M2": { diameter: 2, pitch: 0.4, tapDrill: 1.6 },
6
+ "M2.5": { diameter: 2.5, pitch: 0.45, tapDrill: 2.05 },
7
+ "M3": { diameter: 3, pitch: 0.5, tapDrill: 2.5 },
8
+ "M4": { diameter: 4, pitch: 0.7, tapDrill: 3.3 },
9
+ "M5": { diameter: 5, pitch: 0.8, tapDrill: 4.2 },
10
+ "M6": { diameter: 6, pitch: 1, tapDrill: 5 },
11
+ "M8": { diameter: 8, pitch: 1.25, tapDrill: 6.8 },
12
+ "M10": { diameter: 10, pitch: 1.5, tapDrill: 8.5 },
13
+ "M12": { diameter: 12, pitch: 1.75, tapDrill: 10.2 },
14
+ "M14": { diameter: 14, pitch: 2, tapDrill: 12 },
15
+ "M16": { diameter: 16, pitch: 2, tapDrill: 14 },
16
+ "M20": { diameter: 20, pitch: 2.5, tapDrill: 17.5 },
17
+ "M24": { diameter: 24, pitch: 3, tapDrill: 21 },
18
+ };
19
+ export const ISO_EXTERNAL_ROOT_FACTOR = 1.226869;
20
+ export const ISO_DRILL_STEP = 0.05;
@@ -0,0 +1,4 @@
1
+ import type { IsoThreadSize, IsoThreadSizes } from "./thread-types";
2
+ export declare function checkedIsoSize(size: IsoThreadSize): IsoThreadSize;
3
+ export declare function isoThreadSizes(): IsoThreadSize[];
4
+ export declare function isoThread(size: IsoThreadSize, pitch?: number): IsoThreadSizes;
@@ -0,0 +1,32 @@
1
+ import { InputError } from "../kernel-calls/errors";
2
+ import { roundedToMillionths } from "../services/helpers/geometry/scalars";
3
+ import { COARSE_THREADS, ISO_DRILL_STEP, ISO_EXTERNAL_ROOT_FACTOR, ISO_THREAD_SIZES } from "./iso-threads.constants";
4
+ import { INTERNAL_DEPTH_FACTOR, PITCH_DEPTH_FACTOR } from "./thread-profile.constants";
5
+ export function checkedIsoSize(size) {
6
+ if (!ISO_THREAD_SIZES.includes(size)) {
7
+ throw new InputError(`\`size\` is not one of ${ISO_THREAD_SIZES.join(", ")}.`, "size");
8
+ }
9
+ return size;
10
+ }
11
+ export function isoThreadSizes() {
12
+ return [...ISO_THREAD_SIZES];
13
+ }
14
+ export function isoThread(size, pitch) {
15
+ const row = COARSE_THREADS[checkedIsoSize(size)];
16
+ const given = pitch !== null && pitch !== void 0 ? pitch : row.pitch;
17
+ if (!(given > 0 && given <= row.pitch)) {
18
+ throw new InputError(`\`pitch\` is not more than 0 and at most the coarse pitch of ${size}, ${String(row.pitch)}.`, "pitch");
19
+ }
20
+ const coarse = given === row.pitch;
21
+ const tapDrill = coarse ? row.tapDrill : Math.round((row.diameter - given) / ISO_DRILL_STEP) * ISO_DRILL_STEP;
22
+ return {
23
+ size,
24
+ designation: coarse ? size : `${size}x${String(given)}`,
25
+ diameter: row.diameter,
26
+ pitch: given,
27
+ pitchDiameter: roundedToMillionths(row.diameter - PITCH_DEPTH_FACTOR * given),
28
+ minorDiameter: roundedToMillionths(row.diameter - ISO_EXTERNAL_ROOT_FACTOR * given),
29
+ internalMinorDiameter: roundedToMillionths(row.diameter - INTERNAL_DEPTH_FACTOR * given),
30
+ tapDrill: roundedToMillionths(tapDrill),
31
+ };
32
+ }
@@ -0,0 +1,3 @@
1
+ export declare const PITCH_DEPTH_FACTOR = 0.649519;
2
+ export declare const INTERNAL_DEPTH_FACTOR = 1.082532;
3
+ export declare const THREAD_LENGTHS: readonly ["diameter", "pitch", "pitchDiameter", "minorDiameter", "internalMinorDiameter", "tapDrill"];
@@ -0,0 +1,3 @@
1
+ export const PITCH_DEPTH_FACTOR = 0.649519;
2
+ export const INTERNAL_DEPTH_FACTOR = 1.082532;
3
+ export const THREAD_LENGTHS = ["diameter", "pitch", "pitchDiameter", "minorDiameter", "internalMinorDiameter", "tapDrill"];
@@ -0,0 +1,66 @@
1
+ import type * as Inputs from "../inputs";
2
+ /**
3
+ * An ISO metric thread size, from M1.6 to M24: the nominal diameter in millimetres after the M.
4
+ */
5
+ export type IsoThreadSize = `${Inputs.Engineering.isoThreadSizeEnum}`;
6
+ /**
7
+ * The sizes of a screw thread, from `threads.iso.thread` or `threads.ansi.thread`, in the unit asked
8
+ * for.
9
+ */
10
+ export interface ThreadSizes {
11
+ /** How the standard names the thread, such as M8, M8x1 or 1/4-20 UNC. */
12
+ readonly designation: string;
13
+ /** The nominal, major diameter. */
14
+ readonly diameter: number;
15
+ /** The distance from one thread crest to the next. */
16
+ readonly pitch: number;
17
+ /** The diameter at which the thread's flanks are as wide as its grooves. */
18
+ readonly pitchDiameter: number;
19
+ /** The diameter at the roots of a bolt's thread. */
20
+ readonly minorDiameter: number;
21
+ /** The diameter at the crests of a nut's thread, the hole a tapped thread leaves. */
22
+ readonly internalMinorDiameter: number;
23
+ /** The drill to bore before tapping the thread. */
24
+ readonly tapDrill: number;
25
+ }
26
+ /**
27
+ * An ISO metric thread, from `threads.iso.thread`.
28
+ */
29
+ export interface IsoThreadSizes extends ThreadSizes {
30
+ /** The thread size, such as M8. */
31
+ readonly size: IsoThreadSize;
32
+ }
33
+ export interface IsoThreadRow {
34
+ readonly diameter: number;
35
+ readonly pitch: number;
36
+ readonly tapDrill: number;
37
+ }
38
+ /**
39
+ * A Unified inch thread size, from #0 to 1 inch: a number for the small sizes, a fraction of an inch
40
+ * for the larger ones.
41
+ */
42
+ export type AnsiThreadSize = `${Inputs.Engineering.ansiThreadSizeEnum}`;
43
+ /**
44
+ * The series of a Unified inch thread: coarse (UNC), fine (UNF), or a pitch of its own (UN).
45
+ */
46
+ export type AnsiThreadSeries = "UNC" | "UNF" | "UN";
47
+ /**
48
+ * A Unified inch thread, from `threads.ansi.thread`.
49
+ */
50
+ export interface AnsiThreadSizes extends ThreadSizes {
51
+ /** The thread size, such as 1/4 or #10. */
52
+ readonly size: AnsiThreadSize;
53
+ /** The series the pitch belongs to. */
54
+ readonly series: AnsiThreadSeries;
55
+ /** How many threads there are to an inch of length; the pitch is one inch over it. */
56
+ readonly threadsPerInch: number;
57
+ }
58
+ export interface UnifiedPitchRow {
59
+ readonly threadsPerInch: number;
60
+ readonly tapDrill: number;
61
+ }
62
+ export interface AnsiThreadRow {
63
+ readonly diameter: number;
64
+ readonly unc: UnifiedPitchRow | undefined;
65
+ readonly unf: UnifiedPitchRow;
66
+ }
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bitbybit-dev/base",
3
- "version": "1.5.0",
3
+ "version": "1.6.0-rc.0",
4
4
  "description": "Bit By Bit Developers Base CAD Library to Program Geometry",
5
5
  "homepage": "https://docs.bitbybit.dev/modules/Bit",
6
6
  "main": "index.js",
@@ -1,4 +0,0 @@
1
- export * from "./validate";
2
- export * from "./surface-mesh";
3
- export * from "./sources";
4
- export type { RecipeIssue, RecipeSource, RecipeSurfaceMesh } from "./recipe-types";
@@ -1,3 +0,0 @@
1
- export * from "./validate";
2
- export * from "./surface-mesh";
3
- export * from "./sources";
@@ -1,6 +0,0 @@
1
- import type * as Inputs from "../../inputs";
2
- import type { ThreePointArc } from "./helper-types";
3
- type Point3 = Inputs.Base.Point3;
4
- export declare const arcThroughThreePoints: (start: Point3, middle: Point3, end: Point3) => ThreePointArc | undefined;
5
- export declare const pointsOnArc: (arc: ThreePointArc, start: Point3, end: Point3, segments: number) => Point3[];
6
- export {};
@@ -1,2 +0,0 @@
1
- export declare const RIGID_TOLERANCE = 1e-7;
2
- export declare const LINEAR_COLUMN_STARTS: readonly [0, 4, 8];
@@ -1,2 +0,0 @@
1
- export const RIGID_TOLERANCE = 1e-7;
2
- export const LINEAR_COLUMN_STARTS = [0, 4, 8];
@@ -1,25 +0,0 @@
1
- import type * as Inputs from "../../inputs";
2
- type Vec3 = Inputs.Base.Vector3;
3
- /** Whether a value is one column-major 4 x 4 matrix: sixteen finite numbers. */
4
- export declare const isTransformMatrix: (value: unknown) => value is Inputs.Base.TransformMatrix;
5
- /** The product of two column-major 4 x 4 matrices: `first` applied, then `second`. */
6
- export declare const followedBy: (first: readonly number[], second: readonly number[]) => Inputs.Base.TransformMatrix;
7
- /** The determinant of a column-major 4 x 4 matrix's rotation and scale part: negative when it mirrors, near zero when it flattens. */
8
- export declare const linearDeterminant: (matrix: readonly number[]) => number;
9
- /**
10
- * Whether a column-major 4 x 4 matrix only turns and moves: its rotation and scale part has columns
11
- * of length 1 and at right angles, within `tolerance` on their squared lengths and dot products, and
12
- * keeps its handedness.
13
- */
14
- export declare const isRigidMatrix: (matrix: readonly number[], tolerance?: number) => boolean;
15
- /** One column-major 4 x 4 matrix that applies a list of them first to last; the identity for an empty list. */
16
- export declare const composed: (matrices: readonly (readonly number[])[]) => Inputs.Base.TransformMatrix;
17
- /**
18
- * The eigenvalues of a symmetric 3 x 3 matrix, largest first, each with its unit eigenvector, by
19
- * cyclic Jacobi rotations; the vectors come out at right angles to each other.
20
- */
21
- export declare const symmetricEigen: (matrix: readonly (readonly number[])[]) => {
22
- value: number;
23
- vector: Vec3;
24
- }[];
25
- export {};
@@ -1,11 +0,0 @@
1
- import type { CreasedMesh } from "./helper-types";
2
- /**
3
- * Compute smooth vertex normals for a mesh that arrives without them.
4
- * Accumulates each triangle's cross product onto its three vertices, then normalizes, so a vertex
5
- * shared by several triangles ends up with their average and the mesh shades smoothly.
6
- * @param positions - Flat array of vertex positions [x,y,z,x,y,z,...]
7
- * @param indices - Triangle indices
8
- * @returns Flat array of normals [nx,ny,nz,nx,ny,nz,...]
9
- */
10
- export declare function computeVertexNormals(positions: number[], indices: number[]): number[];
11
- export declare const creasedMesh: (positions: ArrayLike<number>, indices: ArrayLike<number>, minSharpAngle: number) => CreasedMesh;
@@ -1,59 +0,0 @@
1
- import { add2, dot2, length2, scale2, subtract2 } from "./vectors";
2
- const STRAIGHT_TOLERANCE = 1e-9;
3
- const FIT_TOLERANCE = 1e-9;
4
- export const signedArea2 = (points) => {
5
- let twice = 0;
6
- for (let at = 0; at < points.length; at++) {
7
- const a = points[at];
8
- const b = points[(at + 1) % points.length];
9
- twice += a[0] * b[1] - b[0] * a[1];
10
- }
11
- return twice / 2;
12
- };
13
- export const wound2 = (points, counterClockwise) => (signedArea2(points) > 0) === counterClockwise ? [...points] : [...points].reverse();
14
- export const isInsidePolygon2 = (point, outline) => {
15
- let inside = false;
16
- for (let at = 0, previous = outline.length - 1; at < outline.length; previous = at++) {
17
- const [x1, y1] = outline[at];
18
- const [x2, y2] = outline[previous];
19
- if ((y1 > point[1]) !== (y2 > point[1]) && point[0] < ((x2 - x1) * (point[1] - y1)) / (y2 - y1) + x1) {
20
- inside = !inside;
21
- }
22
- }
23
- return inside;
24
- };
25
- export const perimeter2 = (points) => points.reduce((sum, point, at) => sum + length2(subtract2(points[(at + 1) % points.length], point)), 0);
26
- const unit2 = (vector) => scale2(vector, 1 / length2(vector));
27
- export const roundedCorners2 = (points, radii, segmentsFor) => {
28
- const rounded = [];
29
- points.forEach((corner, at) => {
30
- var _a;
31
- const radius = (_a = radii[at]) !== null && _a !== void 0 ? _a : 0;
32
- const previous = points[(at + points.length - 1) % points.length];
33
- const next = points[(at + 1) % points.length];
34
- const toPrevious = unit2(subtract2(previous, corner));
35
- const toNext = unit2(subtract2(next, corner));
36
- const half = Math.acos(Math.min(1, Math.max(-1, dot2(toPrevious, toNext)))) / 2;
37
- if (!(radius > 0) || half < STRAIGHT_TOLERANCE || half > Math.PI / 2 - STRAIGHT_TOLERANCE) {
38
- rounded.push(corner);
39
- return;
40
- }
41
- const reach = radius / Math.tan(half);
42
- const room = Math.min(length2(subtract2(previous, corner)), length2(subtract2(next, corner)));
43
- if (reach > room * (1 + FIT_TOLERANCE)) {
44
- throw new Error(`A corner radius of ${radius} does not fit the edges beside its corner`);
45
- }
46
- const center = add2(corner, scale2(unit2(add2(toPrevious, toNext)), radius / Math.sin(half)));
47
- const start = subtract2(add2(corner, scale2(toPrevious, reach)), center);
48
- const end = subtract2(add2(corner, scale2(toNext, reach)), center);
49
- const from = Math.atan2(start[1], start[0]);
50
- let sweep = Math.atan2(end[1], end[0]) - from;
51
- sweep -= Math.round(sweep / (2 * Math.PI)) * 2 * Math.PI;
52
- const segments = segmentsFor(Math.abs(sweep));
53
- for (let step = 0; step <= segments; step++) {
54
- const angle = from + (sweep * step) / segments;
55
- rounded.push([center[0] + radius * Math.cos(angle), center[1] + radius * Math.sin(angle)]);
56
- }
57
- });
58
- return rounded;
59
- };
@@ -1,17 +0,0 @@
1
- export const add2 = (a, b) => [a[0] + b[0], a[1] + b[1]];
2
- export const subtract2 = (a, b) => [a[0] - b[0], a[1] - b[1]];
3
- export const scale2 = (a, factor) => [a[0] * factor, a[1] * factor];
4
- export const dot2 = (a, b) => a[0] * b[0] + a[1] * b[1];
5
- export const cross2 = (a, b) => a[0] * b[1] - a[1] * b[0];
6
- export const length2 = (a) => Math.hypot(a[0], a[1]);
7
- export const leftOf2 = (a) => [-a[1], a[0]];
8
- export const unit2Of = (a) => {
9
- const length = length2(a);
10
- return length > 0 && length < Infinity ? [a[0] / length, a[1] / length] : undefined;
11
- };
12
- export const add3 = (a, b) => [a[0] + b[0], a[1] + b[1], a[2] + b[2]];
13
- export const subtract3 = (a, b) => [a[0] - b[0], a[1] - b[1], a[2] - b[2]];
14
- export const scale3 = (a, factor) => [a[0] * factor, a[1] * factor, a[2] * factor];
15
- export const dot3 = (a, b) => a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
16
- export const cross3 = (a, b) => [a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]];
17
- export const length3 = (a) => Math.hypot(a[0], a[1], a[2]);