designix 0.5.3

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 (237) hide show
  1. package/.eslintignore +17 -0
  2. package/.eslintrc.cjs +24 -0
  3. package/.prettierignore +15 -0
  4. package/.prettierrc +8 -0
  5. package/README.md +27 -0
  6. package/export_svg/base.svg +1 -0
  7. package/export_svg/base_cut.svg +1 -0
  8. package/export_svg/base_hollow.svg +1 -0
  9. package/export_svg/base_top.svg +1 -0
  10. package/export_svg/calculation_of_initAngle2.svg +1 -0
  11. package/export_svg/circles.svg +1 -0
  12. package/export_svg/circles_amplitude-offset.svg +1 -0
  13. package/export_svg/circles_amplitude-scale.svg +1 -0
  14. package/export_svg/circles_angle.svg +1 -0
  15. package/export_svg/default_param_blank.svg +1 -0
  16. package/export_svg/dummy_pole_static.svg +1 -0
  17. package/export_svg/dummy_pole_static_face.svg +1 -0
  18. package/export_svg/gear_addendeum_dedendum_sizes.svg +9 -0
  19. package/export_svg/gear_addendum_and_dedendum.svg +1 -0
  20. package/export_svg/gear_adherence_replaced_by_teeth.svg +1 -0
  21. package/export_svg/gear_base_circle_for_involute.svg +2 -0
  22. package/export_svg/gear_base_left_circle_for_involute.svg +2 -0
  23. package/export_svg/gear_base_right_circle_for_involute.svg +2 -0
  24. package/export_svg/gear_inter_axis_maximum_distance.svg +1 -0
  25. package/export_svg/gear_inter_axis_minimum_distance.svg +1 -0
  26. package/export_svg/gear_large_base_radius.svg +5 -0
  27. package/export_svg/gear_module_and_tooth_thickness.svg +3 -0
  28. package/export_svg/gear_optimum_base_radius.svg +5 -0
  29. package/export_svg/gear_optimum_base_radius_with_longer_inter_axis.svg +5 -0
  30. package/export_svg/gear_right_left_base_circles.svg +1 -0
  31. package/export_svg/gear_small_base_radius.svg +5 -0
  32. package/export_svg/gear_wheel_circles.svg +2 -0
  33. package/export_svg/gears.svg +71 -0
  34. package/export_svg/gears_motion_transmission_via_adherence.svg +1 -0
  35. package/export_svg/heliostat.svg +1 -0
  36. package/export_svg/heliostat2_face_sizing.svg +1 -0
  37. package/export_svg/heliostat2_side_sizing.svg +1 -0
  38. package/export_svg/heliostat_face_sizing.svg +1 -0
  39. package/export_svg/heliostat_overview.svg +1 -0
  40. package/export_svg/heliostat_side.svg +1 -0
  41. package/export_svg/heliostat_side_sizing.svg +1 -0
  42. package/export_svg/involute_of_circle.svg +19 -0
  43. package/export_svg/involute_of_circle_R0.svg +1 -0
  44. package/export_svg/involute_of_circle_Ri1_u0.svg +1 -0
  45. package/export_svg/involute_of_circle_Ri2_u2.svg +1 -0
  46. package/export_svg/left_side_angle_kitchen.svg +1 -0
  47. package/export_svg/negative_involute_of_circle_R0.svg +1 -0
  48. package/export_svg/point_c_position_and_speed_negative.svg +1 -0
  49. package/export_svg/point_c_position_and_speed_positive.svg +1 -0
  50. package/export_svg/pole_rotor.svg +1 -0
  51. package/export_svg/pole_rotor_cut.svg +1 -0
  52. package/export_svg/pole_rotor_ends.svg +1 -0
  53. package/export_svg/pole_stator.svg +3 -0
  54. package/export_svg/pole_stator_E2.svg +3 -0
  55. package/export_svg/pole_stator_bottom.svg +1 -0
  56. package/export_svg/pole_stator_cut.svg +1 -0
  57. package/export_svg/pole_stator_face.svg +1 -0
  58. package/export_svg/pole_stator_right.svg +1 -0
  59. package/export_svg/rake.svg +1 -0
  60. package/export_svg/rake_door.svg +1 -0
  61. package/export_svg/rake_face.svg +1 -0
  62. package/export_svg/rake_side.svg +1 -0
  63. package/export_svg/rake_side_stopper.svg +1 -0
  64. package/export_svg/rake_top.svg +1 -0
  65. package/export_svg/rake_top_stopper.svg +1 -0
  66. package/export_svg/rectangle.svg +1 -0
  67. package/export_svg/rectangle_height.svg +1 -0
  68. package/export_svg/rectangle_width.svg +1 -0
  69. package/export_svg/right_side_angle_kitchen.svg +1 -0
  70. package/export_svg/rod.svg +1 -0
  71. package/export_svg/rod_cut.svg +1 -0
  72. package/export_svg/rod_plate.svg +1 -0
  73. package/export_svg/rod_top.svg +1 -0
  74. package/export_svg/spider.svg +1 -0
  75. package/export_svg/spider_lateral.svg +1 -0
  76. package/export_svg/spider_profile.svg +1 -0
  77. package/export_svg/surface.svg +3 -0
  78. package/export_svg/surface_crenel.svg +1 -0
  79. package/export_svg/surface_extremities.svg +2 -0
  80. package/export_svg/surface_lz.svg +1 -0
  81. package/export_svg/surface_main.svg +1 -0
  82. package/export_svg/surface_power.svg +2 -0
  83. package/export_svg/surface_space_evolution.svg +1 -0
  84. package/export_svg/surface_space_shape.svg +1 -0
  85. package/export_svg/swing.svg +1 -0
  86. package/export_svg/swing_face.svg +1 -0
  87. package/export_svg/swing_side.svg +1 -0
  88. package/export_svg/swing_top.svg +1 -0
  89. package/export_svg/swing_with_rod.svg +1 -0
  90. package/export_svg/trapeze.svg +1 -0
  91. package/export_svg/trapeze_rod.svg +1 -0
  92. package/export_svg/trapeze_side.svg +1 -0
  93. package/export_svg/trapeze_top.svg +1 -0
  94. package/export_svg/verify_contour_1.svg +1 -0
  95. package/export_svg/verify_contour_1_l1.svg +1 -0
  96. package/export_svg/verify_contour_1_r1.svg +1 -0
  97. package/export_svg/verify_line.svg +1 -0
  98. package/export_svg/verify_line_2_l1cx.svg +1 -0
  99. package/export_svg/verify_line_p1x.svg +1 -0
  100. package/export_svg/verify_point.svg +1 -0
  101. package/export_svg/verify_point_p1x.svg +1 -0
  102. package/export_svg/verify_vector_p1x.svg +1 -0
  103. package/package.json +76 -0
  104. package/src/dummy/circles.ts +65 -0
  105. package/src/dummy/pole_static.ts +86 -0
  106. package/src/dummy/rectangle.ts +55 -0
  107. package/src/dummy/svg/circles.svg +288 -0
  108. package/src/dummy/svg/circles_amplitude-offset.svg +109 -0
  109. package/src/dummy/svg/circles_amplitude-scale.svg +122 -0
  110. package/src/dummy/svg/circles_angle.svg +110 -0
  111. package/src/dummy/svg/dummy_pole_static.svg +192 -0
  112. package/src/dummy/svg/dummy_pole_static_face.svg +176 -0
  113. package/src/dummy/svg/rectangle.svg +131 -0
  114. package/src/dummy/svg/rectangle_height.svg +82 -0
  115. package/src/dummy/svg/rectangle_width.svg +81 -0
  116. package/src/gears/gearWheelProfile.test.ts +25 -0
  117. package/src/gears/gearWheelProfile.ts +753 -0
  118. package/src/gears/gear_wheel_wheel.ts +335 -0
  119. package/src/gears/involute.test.ts +21 -0
  120. package/src/gears/involute.ts +113 -0
  121. package/src/gears/simplified_gear_wheel.ts +242 -0
  122. package/src/gears/svg/calculation_of_initAngle2.svg +376 -0
  123. package/src/gears/svg/gear_addendeum_dedendum_sizes.svg +471 -0
  124. package/src/gears/svg/gear_addendum_and_dedendum.svg +269 -0
  125. package/src/gears/svg/gear_adherence_replaced_by_teeth.svg +168 -0
  126. package/src/gears/svg/gear_base_circle_for_involute.svg +376 -0
  127. package/src/gears/svg/gear_base_left_circle_for_involute.svg +556 -0
  128. package/src/gears/svg/gear_base_right_circle_for_involute.svg +516 -0
  129. package/src/gears/svg/gear_inter_axis_maximum_distance.svg +218 -0
  130. package/src/gears/svg/gear_inter_axis_minimum_distance.svg +218 -0
  131. package/src/gears/svg/gear_large_base_radius.svg +199 -0
  132. package/src/gears/svg/gear_module_and_tooth_thickness.svg +319 -0
  133. package/src/gears/svg/gear_optimum_base_radius.svg +232 -0
  134. package/src/gears/svg/gear_optimum_base_radius_with_longer_inter_axis.svg +344 -0
  135. package/src/gears/svg/gear_right_left_base_circles.svg +295 -0
  136. package/src/gears/svg/gear_small_base_radius.svg +163 -0
  137. package/src/gears/svg/gear_wheel_circles.svg +348 -0
  138. package/src/gears/svg/gears.svg +4726 -0
  139. package/src/gears/svg/gears_motion_transmission_via_adherence.svg +178 -0
  140. package/src/gears/svg/involute_of_circle.svg +2745 -0
  141. package/src/gears/svg/involute_of_circle_R0.svg +334 -0
  142. package/src/gears/svg/involute_of_circle_Ri1_u0.svg +297 -0
  143. package/src/gears/svg/involute_of_circle_Ri2_u2.svg +386 -0
  144. package/src/gears/svg/left_side_angle_kitchen.svg +207 -0
  145. package/src/gears/svg/negative_involute_of_circle_R0.svg +381 -0
  146. package/src/gears/svg/point_c_position_and_speed_negative.svg +343 -0
  147. package/src/gears/svg/point_c_position_and_speed_positive.svg +339 -0
  148. package/src/gears/svg/right_side_angle_kitchen.svg +201 -0
  149. package/src/gears/wheelElements.test.ts +13 -0
  150. package/src/gears/wheelElements.ts +176 -0
  151. package/src/geometrix_verification/svg/verify_contour_1.svg +320 -0
  152. package/src/geometrix_verification/svg/verify_contour_1_l1.svg +102 -0
  153. package/src/geometrix_verification/svg/verify_contour_1_r1.svg +170 -0
  154. package/src/geometrix_verification/svg/verify_line.svg +845 -0
  155. package/src/geometrix_verification/svg/verify_line_2_l1cx.svg +274 -0
  156. package/src/geometrix_verification/svg/verify_line_p1x.svg +261 -0
  157. package/src/geometrix_verification/svg/verify_point.svg +350 -0
  158. package/src/geometrix_verification/svg/verify_point_p1x.svg +258 -0
  159. package/src/geometrix_verification/svg/verify_vector_p1x.svg +282 -0
  160. package/src/geometrix_verification/verify_contour_1.ts +94 -0
  161. package/src/geometrix_verification/verify_contour_2.ts +267 -0
  162. package/src/geometrix_verification/verify_contour_3.ts +409 -0
  163. package/src/geometrix_verification/verify_contour_4.ts +91 -0
  164. package/src/geometrix_verification/verify_exports_1.ts +95 -0
  165. package/src/geometrix_verification/verify_line.ts +76 -0
  166. package/src/geometrix_verification/verify_line_2.ts +76 -0
  167. package/src/geometrix_verification/verify_line_3.ts +64 -0
  168. package/src/geometrix_verification/verify_point.ts +62 -0
  169. package/src/geometrix_verification/verify_point_2.ts +66 -0
  170. package/src/geometrix_verification/verify_vector.ts +70 -0
  171. package/src/heliostat/base.ts +254 -0
  172. package/src/heliostat/heliostat.ts +317 -0
  173. package/src/heliostat/heliostat_2.ts +284 -0
  174. package/src/heliostat/pole_rotor.ts +165 -0
  175. package/src/heliostat/pole_static.ts +275 -0
  176. package/src/heliostat/rake.ts +486 -0
  177. package/src/heliostat/rake_stopper.ts +409 -0
  178. package/src/heliostat/rod.ts +200 -0
  179. package/src/heliostat/spider.ts +238 -0
  180. package/src/heliostat/surface.ts +320 -0
  181. package/src/heliostat/svg/base.svg +1367 -0
  182. package/src/heliostat/svg/base_cut.svg +459 -0
  183. package/src/heliostat/svg/base_hollow.svg +469 -0
  184. package/src/heliostat/svg/base_top.svg +338 -0
  185. package/src/heliostat/svg/heliostat.svg +8013 -0
  186. package/src/heliostat/svg/heliostat2_face_sizing.svg +1386 -0
  187. package/src/heliostat/svg/heliostat2_side_sizing.svg +984 -0
  188. package/src/heliostat/svg/heliostat_face_sizing.svg +1448 -0
  189. package/src/heliostat/svg/heliostat_overview.svg +1552 -0
  190. package/src/heliostat/svg/heliostat_side.svg +1470 -0
  191. package/src/heliostat/svg/heliostat_side_sizing.svg +1128 -0
  192. package/src/heliostat/svg/pole_rotor.svg +592 -0
  193. package/src/heliostat/svg/pole_rotor_cut.svg +287 -0
  194. package/src/heliostat/svg/pole_rotor_ends.svg +336 -0
  195. package/src/heliostat/svg/pole_stator.svg +1945 -0
  196. package/src/heliostat/svg/pole_stator_E2.svg +410 -0
  197. package/src/heliostat/svg/pole_stator_bottom.svg +330 -0
  198. package/src/heliostat/svg/pole_stator_cut.svg +465 -0
  199. package/src/heliostat/svg/pole_stator_face.svg +457 -0
  200. package/src/heliostat/svg/pole_stator_right.svg +357 -0
  201. package/src/heliostat/svg/rake.svg +4691 -0
  202. package/src/heliostat/svg/rake_door.svg +617 -0
  203. package/src/heliostat/svg/rake_face.svg +1211 -0
  204. package/src/heliostat/svg/rake_side.svg +809 -0
  205. package/src/heliostat/svg/rake_side_stopper.svg +596 -0
  206. package/src/heliostat/svg/rake_top.svg +514 -0
  207. package/src/heliostat/svg/rake_top_stopper.svg +565 -0
  208. package/src/heliostat/svg/rod.svg +1314 -0
  209. package/src/heliostat/svg/rod_cut.svg +265 -0
  210. package/src/heliostat/svg/rod_plate.svg +409 -0
  211. package/src/heliostat/svg/rod_top.svg +577 -0
  212. package/src/heliostat/svg/spider.svg +693 -0
  213. package/src/heliostat/svg/spider_lateral.svg +222 -0
  214. package/src/heliostat/svg/spider_profile.svg +429 -0
  215. package/src/heliostat/svg/surface.svg +3577 -0
  216. package/src/heliostat/svg/surface_crenel.svg +1335 -0
  217. package/src/heliostat/svg/surface_extremities.svg +510 -0
  218. package/src/heliostat/svg/surface_lz.svg +182 -0
  219. package/src/heliostat/svg/surface_main.svg +366 -0
  220. package/src/heliostat/svg/surface_power.svg +331 -0
  221. package/src/heliostat/svg/surface_space_evolution.svg +210 -0
  222. package/src/heliostat/svg/surface_space_shape.svg +98 -0
  223. package/src/heliostat/svg/swing.svg +3310 -0
  224. package/src/heliostat/svg/swing_face.svg +902 -0
  225. package/src/heliostat/svg/swing_side.svg +574 -0
  226. package/src/heliostat/svg/swing_top.svg +923 -0
  227. package/src/heliostat/svg/swing_with_rod.svg +547 -0
  228. package/src/heliostat/svg/trapeze.svg +1711 -0
  229. package/src/heliostat/svg/trapeze_rod.svg +122 -0
  230. package/src/heliostat/svg/trapeze_side.svg +361 -0
  231. package/src/heliostat/svg/trapeze_top.svg +1057 -0
  232. package/src/heliostat/swing.ts +246 -0
  233. package/src/heliostat/trapeze.ts +510 -0
  234. package/src/index.ts +33 -0
  235. package/src/svg/default_param_blank.svg +40 -0
  236. package/tsconfig.json +13 -0
  237. package/vitest.config.ts +7 -0
@@ -0,0 +1,510 @@
1
+ // trapeze.ts
2
+
3
+ import type {
4
+ tContour,
5
+ tParamDef,
6
+ tParamVal,
7
+ tGeom,
8
+ tPageDef
9
+ //tSubInst
10
+ //tSubDesign
11
+ } from 'geometrix';
12
+ import {
13
+ contour,
14
+ contourCircle,
15
+ figure,
16
+ //degToRad,
17
+ radToDeg,
18
+ ffix,
19
+ pNumber,
20
+ //pCheckbox,
21
+ //pDropdown,
22
+ initGeom,
23
+ EExtrude,
24
+ EBVolume
25
+ } from 'geometrix';
26
+
27
+ const pDef: tParamDef = {
28
+ partName: 'trapeze',
29
+ params: [
30
+ //pNumber(name, unit, init, min, max, step)
31
+ pNumber('L1', 'mm', 1600, 100, 4000, 10),
32
+ pNumber('L2', 'mm', 1000, 100, 4000, 10),
33
+ pNumber('L3', 'mm', 400, 100, 800, 10),
34
+ pNumber('L4', 'mm', 300, 100, 800, 10),
35
+ pNumber('N1', '', 7, 1, 20, 1),
36
+ pNumber('N2', '', 4, 1, 20, 1),
37
+ pNumber('N3', '', 2, 1, 20, 1),
38
+ pNumber('N4', '', 2, 1, 20, 1),
39
+ pNumber('L5', 'mm', 100, 1, 400, 1),
40
+ pNumber('L6', 'mm', 20, 1, 400, 1),
41
+ pNumber('L7', 'mm', 20, 1, 400, 1),
42
+ pNumber('D1', 'mm', 10, 1, 40, 10),
43
+ pNumber('D2', 'mm', 10, 1, 40, 10),
44
+ pNumber('D3', 'mm', 30, 1, 100, 10),
45
+ pNumber('D4', 'mm', 26, 1, 100, 10),
46
+ pNumber('R1', 'mm', 60, 1, 400, 1),
47
+ pNumber('R2', 'mm', 20, 1, 400, 1),
48
+ pNumber('R3', 'mm', 20, 1, 400, 1),
49
+ pNumber('H1', 'mm', 300, 0.5, 800, 0.5),
50
+ pNumber('H2', 'mm', 2, 0.5, 800, 0.5),
51
+ pNumber('H3', 'mm', 5, 0.5, 800, 0.5)
52
+ ],
53
+ paramSvg: {
54
+ L1: 'trapeze_top.svg',
55
+ L2: 'trapeze_top.svg',
56
+ L3: 'trapeze_top.svg',
57
+ L4: 'trapeze_top.svg',
58
+ N1: 'trapeze_top.svg',
59
+ N2: 'trapeze_top.svg',
60
+ N3: 'trapeze_top.svg',
61
+ N4: 'trapeze_top.svg',
62
+ L5: 'trapeze_top.svg',
63
+ L6: 'trapeze_top.svg',
64
+ L7: 'trapeze_top.svg',
65
+ D1: 'trapeze_top.svg',
66
+ D2: 'trapeze_top.svg',
67
+ D3: 'trapeze_rod.svg',
68
+ D4: 'trapeze_rod.svg',
69
+ R1: 'trapeze_top.svg',
70
+ R2: 'trapeze_top.svg',
71
+ R3: 'trapeze_top.svg',
72
+ H1: 'trapeze_side.svg',
73
+ H2: 'trapeze_side.svg',
74
+ H3: 'trapeze_side.svg'
75
+ },
76
+ sim: {
77
+ tMax: 180,
78
+ tStep: 0.5,
79
+ tUpdate: 500 // every 0.5 second
80
+ }
81
+ };
82
+
83
+ type tCtr1 = (px: number, py: number, angle: number) => tContour;
84
+
85
+ function pGeom(t: number, param: tParamVal): tGeom {
86
+ let ctrRodFootprint: tCtr1;
87
+ let ctrRod: tCtr1;
88
+ const rGeome = initGeom(pDef.partName);
89
+ const figFrame = figure();
90
+ const figPlate = figure();
91
+ const figRod = figure();
92
+ const figRodHollow = figure();
93
+ const figCutRod = figure();
94
+ rGeome.logstr += `${rGeome.partName} simTime: ${t}\n`;
95
+ try {
96
+ if (param.L3 > param.L1 - param.L5) {
97
+ throw `err595: L3 ${param.L3} too large compare to L1 ${param.L1} and L5 ${param.L5}`;
98
+ }
99
+ if (param.L4 > param.L2 - param.L5) {
100
+ throw `err596: L4 ${param.L4} too large compare to L2 ${param.L2} and L5 ${param.L5}`;
101
+ }
102
+ if (param.H1 - param.H2 - param.H3 < 4 * param.D3) {
103
+ throw `err597: H1 ${param.H1} too small compare to H2 ${param.H2}, H3 ${param.H3} and D3 ${param.D3}`;
104
+ }
105
+ const pad1 = param.R1 * (1 - 1 / Math.sqrt(2));
106
+ const pad3 = param.R3 * (1 - 1 / Math.sqrt(2));
107
+ const rod_x = param.L2 / 2 - pad1 - (param.L4 / 2 - pad3);
108
+ const rod_y = param.L1 / 2 - pad1 - (param.L3 / 2 - pad3);
109
+ const rod_xy = Math.sqrt(rod_x ** 2 + rod_y ** 2);
110
+ const rod_z = param.H1 - param.H2 - param.H3;
111
+ const rod_slope_length = Math.sqrt(rod_xy ** 2 + rod_z ** 2);
112
+ const rod_slope_angle = Math.atan2(rod_z, rod_xy);
113
+ const rod_xy_angle = Math.atan2(rod_y, rod_x);
114
+ rGeome.logstr += `rod-slope: length: ${ffix(rod_slope_length)} mm, angle: ${ffix(
115
+ radToDeg(rod_slope_angle)
116
+ )} degree\n`;
117
+ rGeome.logstr += `rod-xy-angle: ${ffix(radToDeg(rod_xy_angle))} degree\n`;
118
+ const rodFootprintLength = param.D3 / Math.cos(Math.PI / 2 - rod_slope_angle);
119
+ rGeome.logstr += `rod-footprint-length: ${ffix(rodFootprintLength)} mm\n`;
120
+ const rodFPl = Math.sqrt((rodFootprintLength / 2) ** 2 + (param.D3 / 2) ** 2);
121
+ const rodFPa = Math.atan2(param.D3, rodFootprintLength);
122
+ ctrRodFootprint = function (px: number, py: number, angle: number): tContour {
123
+ const rCtr = contour(px, py)
124
+ .addPointRP(angle + Math.PI - rodFPa, rodFPl)
125
+ .addSeg2Arcs(angle + Math.PI / 2, angle)
126
+ .addPointRP(angle + Math.PI + rodFPa, rodFPl)
127
+ .addSeg2Arcs(angle + Math.PI, angle + Math.PI / 2)
128
+ .addPointRP(angle - rodFPa, rodFPl)
129
+ .addSeg2Arcs(angle + (3 * Math.PI) / 2, angle + Math.PI)
130
+ .addPointRP(angle + rodFPa, rodFPl)
131
+ .addSeg2Arcs(angle, angle - Math.PI / 2);
132
+ return rCtr;
133
+ };
134
+ ctrRod = function (px: number, py: number, angle: number): tContour {
135
+ const px0 = px + rodFPl * Math.cos(angle + Math.PI - rodFPa);
136
+ const py0 = py + rodFPl * Math.sin(angle + Math.PI - rodFPa);
137
+ const rCtr = contour(px0, py0)
138
+ .addSegStrokeRP(angle + Math.PI, rod_xy)
139
+ .addSegStrokeRP(angle - Math.PI / 2, param.D3)
140
+ .addSegStrokeRP(angle, rod_xy)
141
+ .closeSegStroke();
142
+ return rCtr;
143
+ };
144
+ // figFrame
145
+ if (param.R1 > param.L1 / 4 || param.R1 > param.L2 / 4) {
146
+ throw `err614: R1 ${param.R1} too large compare to L1 ${param.L1} or L2 ${param.L2}`;
147
+ }
148
+ const ctrFrameExt = contour(param.L2 / 2, param.L1 / 2)
149
+ .addSegStrokeA(-param.L2 / 2, param.L1 / 2)
150
+ .addCornerRounded(param.R1)
151
+ .addSegStrokeA(-param.L2 / 2, -param.L1 / 2)
152
+ .addCornerRounded(param.R1)
153
+ .addSegStrokeA(param.L2 / 2, -param.L1 / 2)
154
+ .addCornerRounded(param.R1)
155
+ .closeSegStroke()
156
+ .addCornerRounded(param.R1);
157
+ if (param.R2 > (param.L1 - 2 * param.L5) / 4 || param.R2 > (param.L2 - 2 * param.L5) / 4) {
158
+ throw `err627: R2 ${param.R2} too large compare to L1 ${param.L1}, L2 ${param.L2} and L5 ${param.L5}`;
159
+ }
160
+ const ctrFrameInt = contour(param.L2 / 2 - param.L5, param.L1 / 2 - param.L5)
161
+ .addSegStrokeA(-param.L2 / 2 + param.L5, param.L1 / 2 - param.L5)
162
+ .addCornerRounded(param.R2)
163
+ .addSegStrokeA(-param.L2 / 2 + param.L5, -param.L1 / 2 + param.L5)
164
+ .addCornerRounded(param.R2)
165
+ .addSegStrokeA(param.L2 / 2 - param.L5, -param.L1 / 2 + param.L5)
166
+ .addCornerRounded(param.R2)
167
+ .closeSegStroke()
168
+ .addCornerRounded(param.R2);
169
+ if (param.R3 > param.L3 / 4 || param.R3 > param.L4 / 4) {
170
+ throw `err639: R3 ${param.R3} too large compare to L3 ${param.L3} or L4 ${param.L4}`;
171
+ }
172
+ const ctrPlate = contour(param.L4 / 2, param.L3 / 2)
173
+ .addSegStrokeA(-param.L4 / 2, param.L3 / 2)
174
+ .addCornerRounded(param.R3)
175
+ .addSegStrokeA(-param.L4 / 2, -param.L3 / 2)
176
+ .addCornerRounded(param.R3)
177
+ .addSegStrokeA(param.L4 / 2, -param.L3 / 2)
178
+ .addCornerRounded(param.R3)
179
+ .closeSegStroke()
180
+ .addCornerRounded(param.R3);
181
+ figFrame.addMain(ctrFrameExt);
182
+ figFrame.addMain(ctrFrameInt);
183
+ figFrame.addSecond(ctrPlate);
184
+ const step1 = param.L1 / (param.N1 + 1);
185
+ const step2 = param.L2 / (param.N2 + 1);
186
+ const step3 = param.L3 / (param.N3 + 1);
187
+ const step4 = param.L4 / (param.N4 + 1);
188
+ if (param.L5 < param.D1 + param.L6) {
189
+ throw `err658: L5 ${param.L5} too small compare to D1 ${param.D1} or L6 ${param.L6}`;
190
+ }
191
+ if (step3 < param.D2 + param.L7) {
192
+ throw `err661: D2 ${param.D2} or L7 ${param.L7} too large compare to L3 ${param.l3}`;
193
+ }
194
+ if (step4 < param.D2 + param.L7) {
195
+ throw `err664: D2 ${param.D2} or L7 ${param.L7} too large compare to L4 ${param.l4}`;
196
+ }
197
+ const lFrameHole: tContour[] = [];
198
+ for (let i = 1; i < param.N1 + 1; i++) {
199
+ lFrameHole.push(
200
+ contourCircle(param.L2 / 2 - param.L6, -param.L1 / 2 + i * step1, param.D1)
201
+ );
202
+ lFrameHole.push(
203
+ contourCircle(-param.L2 / 2 + param.L6, -param.L1 / 2 + i * step1, param.D1)
204
+ );
205
+ }
206
+ for (let i = 1; i < param.N2 + 1; i++) {
207
+ lFrameHole.push(
208
+ contourCircle(-param.L2 / 2 + i * step2, param.L1 / 2 - param.L6, param.D1)
209
+ );
210
+ lFrameHole.push(
211
+ contourCircle(-param.L2 / 2 + i * step2, -param.L1 / 2 + param.L6, param.D1)
212
+ );
213
+ }
214
+ const lPlateHole: tContour[] = [];
215
+ for (let i = 1; i < param.N3 + 1; i++) {
216
+ lPlateHole.push(
217
+ contourCircle(param.L4 / 2 - param.L7, -param.L3 / 2 + i * step3, param.D2)
218
+ );
219
+ lPlateHole.push(
220
+ contourCircle(-param.L4 / 2 + param.L7, -param.L3 / 2 + i * step3, param.D2)
221
+ );
222
+ }
223
+ for (let i = 1; i < param.N4 + 1; i++) {
224
+ lPlateHole.push(
225
+ contourCircle(-param.L4 / 2 + i * step4, param.L3 / 2 - param.L7, param.D2)
226
+ );
227
+ lPlateHole.push(
228
+ contourCircle(-param.L4 / 2 + i * step4, -param.L3 / 2 + param.L7, param.D2)
229
+ );
230
+ }
231
+ lFrameHole.forEach((ctr) => {
232
+ figFrame.addMain(ctr);
233
+ });
234
+ lPlateHole.forEach((ctr) => {
235
+ figFrame.addSecond(ctr);
236
+ });
237
+ const lRodFP: tContour[] = [];
238
+ lRodFP.push(ctrRodFootprint(param.L2 / 2 - pad1, param.L1 / 2 - pad1, rod_xy_angle));
239
+ lRodFP.push(ctrRodFootprint(param.L4 / 2 - pad3, param.L3 / 2 - pad3, rod_xy_angle));
240
+ lRodFP.push(
241
+ ctrRodFootprint(-param.L2 / 2 + pad1, param.L1 / 2 - pad1, Math.PI - rod_xy_angle)
242
+ );
243
+ lRodFP.push(
244
+ ctrRodFootprint(-param.L4 / 2 + pad3, param.L3 / 2 - pad3, Math.PI - rod_xy_angle)
245
+ );
246
+ lRodFP.push(
247
+ ctrRodFootprint(-param.L2 / 2 + pad1, -param.L1 / 2 + pad1, Math.PI + rod_xy_angle)
248
+ );
249
+ lRodFP.push(
250
+ ctrRodFootprint(-param.L4 / 2 + pad3, -param.L3 / 2 + pad3, Math.PI + rod_xy_angle)
251
+ );
252
+ lRodFP.push(ctrRodFootprint(param.L2 / 2 - pad1, -param.L1 / 2 + pad1, -rod_xy_angle));
253
+ lRodFP.push(ctrRodFootprint(param.L4 / 2 - pad3, -param.L3 / 2 + pad3, -rod_xy_angle));
254
+ const lRod: tContour[] = [];
255
+ lRod.push(ctrRod(param.L2 / 2 - pad1, param.L1 / 2 - pad1, rod_xy_angle));
256
+ lRod.push(ctrRod(-param.L2 / 2 + pad1, param.L1 / 2 - pad1, Math.PI - rod_xy_angle));
257
+ lRod.push(ctrRod(-param.L2 / 2 + pad1, -param.L1 / 2 + pad1, Math.PI + rod_xy_angle));
258
+ lRod.push(ctrRod(param.L2 / 2 - pad1, -param.L1 / 2 + pad1, -rod_xy_angle));
259
+ lRodFP.forEach((ctr) => {
260
+ figFrame.addSecond(ctr);
261
+ });
262
+ lRod.forEach((ctr) => {
263
+ figFrame.addSecond(ctr);
264
+ });
265
+ // figPlate
266
+ figPlate.addMain(ctrPlate);
267
+ lPlateHole.forEach((ctr) => {
268
+ figPlate.addMain(ctr);
269
+ });
270
+ figPlate.addSecond(ctrFrameExt);
271
+ figPlate.addSecond(ctrFrameInt);
272
+ lFrameHole.forEach((ctr) => {
273
+ figPlate.addSecond(ctr);
274
+ });
275
+ lRodFP.forEach((ctr) => {
276
+ figPlate.addSecond(ctr);
277
+ });
278
+ lRod.forEach((ctr) => {
279
+ figPlate.addSecond(ctr);
280
+ });
281
+ // figRod
282
+ if (param.D4 >= param.D3) {
283
+ throw `err218: D4 ${param.D4} larger than D3 ${param.D3}`;
284
+ }
285
+ figRod.addMain(contourCircle(0, 0, param.D3 / 2));
286
+ figRod.addSecond(contourCircle(0, 0, param.D4 / 2));
287
+ // figRodHollow
288
+ figRodHollow.addMain(contourCircle(0, 0, param.D4 / 2));
289
+ figRodHollow.addSecond(contourCircle(0, 0, param.D3 / 2));
290
+ // figCutRod
291
+ const rodFootprintHeight = param.D3 * Math.cos(rod_slope_angle);
292
+ const rodFootprintBack = rodFootprintHeight / Math.tan(rod_slope_angle);
293
+ const pad3x = pad3 + (rodFootprintLength / 2 + rodFootprintBack) * Math.cos(rod_xy_angle);
294
+ const pad3y = pad3 + (rodFootprintLength / 2 + rodFootprintBack) * Math.sin(rod_xy_angle);
295
+ const rodExtrudeLength =
296
+ rod_slope_length + 2 * (rodFootprintLength + rodFootprintBack + rodFootprintHeight);
297
+ const cutL = rodExtrudeLength + param.L3 + param.L4 + rodFootprintHeight;
298
+ const ctrCutRod = contour(cutL, cutL)
299
+ .addSegStrokeA(-cutL, cutL)
300
+ .addSegStrokeA(-cutL, -cutL)
301
+ .addSegStrokeA(cutL, -cutL)
302
+ .closeSegStroke();
303
+ figCutRod.addMain(ctrCutRod);
304
+ // final figure list
305
+ rGeome.fig = {
306
+ faceFrame: figFrame,
307
+ facePlate: figPlate,
308
+ faceRod: figRod,
309
+ faceRodHollow: figRodHollow,
310
+ faceCutRod: figCutRod
311
+ };
312
+ const designName = rGeome.partName;
313
+ rGeome.vol = {
314
+ extrudes: [
315
+ {
316
+ outName: `subpax_${designName}_frame`,
317
+ face: `${designName}_faceFrame`,
318
+ extrudeMethod: EExtrude.eLinearOrtho,
319
+ length: param.H2,
320
+ rotate: [0, 0, 0],
321
+ translate: [0, 0, param.H1 - param.H2]
322
+ },
323
+ {
324
+ outName: `subpax_${designName}_plate`,
325
+ face: `${designName}_facePlate`,
326
+ extrudeMethod: EExtrude.eLinearOrtho,
327
+ length: param.H3,
328
+ rotate: [0, 0, 0],
329
+ translate: [0, 0, 0]
330
+ },
331
+ {
332
+ outName: `subpax_${designName}_rod1`,
333
+ face: `${designName}_faceRod`,
334
+ extrudeMethod: EExtrude.eLinearOrtho,
335
+ length: rodExtrudeLength,
336
+ rotate: [0, Math.PI / 2 - rod_slope_angle, rod_xy_angle],
337
+ translate: [
338
+ param.L4 / 2 - pad3x,
339
+ param.L3 / 2 - pad3y,
340
+ param.H3 - rodFootprintHeight
341
+ ]
342
+ },
343
+ {
344
+ outName: `subpax_${designName}_rod2`,
345
+ face: `${designName}_faceRod`,
346
+ extrudeMethod: EExtrude.eLinearOrtho,
347
+ length: rodExtrudeLength,
348
+ rotate: [0, Math.PI / 2 - rod_slope_angle, Math.PI - rod_xy_angle],
349
+ translate: [
350
+ -param.L4 / 2 + pad3x,
351
+ param.L3 / 2 - pad3y,
352
+ param.H3 - rodFootprintHeight
353
+ ]
354
+ },
355
+ {
356
+ outName: `subpax_${designName}_rod3`,
357
+ face: `${designName}_faceRod`,
358
+ extrudeMethod: EExtrude.eLinearOrtho,
359
+ length: rodExtrudeLength,
360
+ rotate: [0, Math.PI / 2 - rod_slope_angle, Math.PI + rod_xy_angle],
361
+ translate: [
362
+ -param.L4 / 2 + pad3x,
363
+ -param.L3 / 2 + pad3y,
364
+ param.H3 - rodFootprintHeight
365
+ ]
366
+ },
367
+ {
368
+ outName: `subpax_${designName}_rod4`,
369
+ face: `${designName}_faceRod`,
370
+ extrudeMethod: EExtrude.eLinearOrtho,
371
+ length: rodExtrudeLength,
372
+ rotate: [0, Math.PI / 2 - rod_slope_angle, -rod_xy_angle],
373
+ translate: [
374
+ param.L4 / 2 - pad3x,
375
+ -param.L3 / 2 + pad3y,
376
+ param.H3 - rodFootprintHeight
377
+ ]
378
+ },
379
+ {
380
+ outName: `subpax_${designName}_rodH1`,
381
+ face: `${designName}_faceRodHollow`,
382
+ extrudeMethod: EExtrude.eLinearOrtho,
383
+ length: rodExtrudeLength,
384
+ rotate: [0, Math.PI / 2 - rod_slope_angle, rod_xy_angle],
385
+ translate: [
386
+ param.L4 / 2 - pad3x,
387
+ param.L3 / 2 - pad3y,
388
+ param.H3 - rodFootprintHeight
389
+ ]
390
+ },
391
+ {
392
+ outName: `subpax_${designName}_rodH2`,
393
+ face: `${designName}_faceRodHollow`,
394
+ extrudeMethod: EExtrude.eLinearOrtho,
395
+ length: rodExtrudeLength,
396
+ rotate: [0, Math.PI / 2 - rod_slope_angle, Math.PI - rod_xy_angle],
397
+ translate: [
398
+ -param.L4 / 2 + pad3x,
399
+ param.L3 / 2 - pad3y,
400
+ param.H3 - rodFootprintHeight
401
+ ]
402
+ },
403
+ {
404
+ outName: `subpax_${designName}_rodH3`,
405
+ face: `${designName}_faceRodHollow`,
406
+ extrudeMethod: EExtrude.eLinearOrtho,
407
+ length: rodExtrudeLength,
408
+ rotate: [0, Math.PI / 2 - rod_slope_angle, Math.PI + rod_xy_angle],
409
+ translate: [
410
+ -param.L4 / 2 + pad3x,
411
+ -param.L3 / 2 + pad3y,
412
+ param.H3 - rodFootprintHeight
413
+ ]
414
+ },
415
+ {
416
+ outName: `subpax_${designName}_rodH4`,
417
+ face: `${designName}_faceRodHollow`,
418
+ extrudeMethod: EExtrude.eLinearOrtho,
419
+ length: rodExtrudeLength,
420
+ rotate: [0, Math.PI / 2 - rod_slope_angle, -rod_xy_angle],
421
+ translate: [
422
+ param.L4 / 2 - pad3x,
423
+ -param.L3 / 2 + pad3y,
424
+ param.H3 - rodFootprintHeight
425
+ ]
426
+ },
427
+ {
428
+ outName: `subpax_${designName}_cut1`,
429
+ face: `${designName}_faceCutRod`,
430
+ extrudeMethod: EExtrude.eLinearOrtho,
431
+ length: cutL,
432
+ rotate: [0, 0, 0],
433
+ translate: [0, 0, -cutL]
434
+ },
435
+ {
436
+ outName: `subpax_${designName}_cut2`,
437
+ face: `${designName}_faceCutRod`,
438
+ extrudeMethod: EExtrude.eLinearOrtho,
439
+ length: cutL,
440
+ rotate: [0, 0, 0],
441
+ translate: [0, 0, param.H1]
442
+ }
443
+ ],
444
+ volumes: [
445
+ {
446
+ outName: `ipax_${designName}_rawRod`,
447
+ boolMethod: EBVolume.eUnion,
448
+ inList: [
449
+ `subpax_${designName}_rod1`,
450
+ `subpax_${designName}_rod2`,
451
+ `subpax_${designName}_rod3`,
452
+ `subpax_${designName}_rod4`
453
+ ]
454
+ },
455
+ {
456
+ outName: `ipax_${designName}_rodHollow`,
457
+ boolMethod: EBVolume.eUnion,
458
+ inList: [
459
+ `subpax_${designName}_rodH1`,
460
+ `subpax_${designName}_rodH2`,
461
+ `subpax_${designName}_rodH3`,
462
+ `subpax_${designName}_rodH4`
463
+ ]
464
+ },
465
+ {
466
+ outName: `ipax_${designName}_halfRods`,
467
+ boolMethod: EBVolume.eSubstraction,
468
+ inList: [`ipax_${designName}_rawRod`, `subpax_${designName}_cut1`]
469
+ },
470
+ {
471
+ outName: `ipax_${designName}_rods`,
472
+ boolMethod: EBVolume.eSubstraction,
473
+ inList: [`ipax_${designName}_halfRods`, `subpax_${designName}_cut2`]
474
+ },
475
+ {
476
+ outName: `ipax_${designName}_plus`,
477
+ boolMethod: EBVolume.eUnion,
478
+ inList: [
479
+ `subpax_${designName}_frame`,
480
+ `subpax_${designName}_plate`,
481
+ `ipax_${designName}_rods`
482
+ ]
483
+ },
484
+ {
485
+ outName: `pax_${designName}`,
486
+ boolMethod: EBVolume.eSubstraction,
487
+ inList: [`ipax_${designName}_plus`, `ipax_${designName}_rodHollow`]
488
+ }
489
+ ]
490
+ };
491
+ // sub-design
492
+ rGeome.sub = {};
493
+ // finalize
494
+ rGeome.logstr += 'trapeze draw successfully!\n';
495
+ rGeome.calcErr = false;
496
+ } catch (emsg) {
497
+ rGeome.logstr += emsg as string;
498
+ console.log(emsg as string);
499
+ }
500
+ return rGeome;
501
+ }
502
+
503
+ const trapezeDef: tPageDef = {
504
+ pTitle: 'Heliostat trapeze',
505
+ pDescription: 'The support of one solar panel. Made out of aluminium for lightness and cooling',
506
+ pDef: pDef,
507
+ pGeom: pGeom
508
+ };
509
+
510
+ export { trapezeDef };
package/src/index.ts ADDED
@@ -0,0 +1,33 @@
1
+ // index.ts : entry point
2
+
3
+ export * from './gears/gear_wheel_wheel';
4
+ export * from './gears/simplified_gear_wheel';
5
+
6
+ export * from './heliostat/heliostat';
7
+ export * from './heliostat/heliostat_2';
8
+ export * from './heliostat/base';
9
+ export * from './heliostat/pole_static';
10
+ export * from './heliostat/pole_rotor';
11
+ export * from './heliostat/rake';
12
+ export * from './heliostat/rake_stopper';
13
+ export * from './heliostat/spider';
14
+ export * from './heliostat/swing';
15
+ export * from './heliostat/rod';
16
+ export * from './heliostat/trapeze';
17
+ export * from './heliostat/surface';
18
+
19
+ export * from './dummy/circles';
20
+ export * from './dummy/rectangle';
21
+ export * from './dummy/pole_static';
22
+
23
+ export * from './geometrix_verification/verify_point';
24
+ export * from './geometrix_verification/verify_point_2';
25
+ export * from './geometrix_verification/verify_line';
26
+ export * from './geometrix_verification/verify_line_2';
27
+ export * from './geometrix_verification/verify_line_3';
28
+ export * from './geometrix_verification/verify_vector';
29
+ export * from './geometrix_verification/verify_contour_1';
30
+ export * from './geometrix_verification/verify_contour_2';
31
+ export * from './geometrix_verification/verify_contour_3';
32
+ export * from './geometrix_verification/verify_contour_4';
33
+ export * from './geometrix_verification/verify_exports_1';
@@ -0,0 +1,40 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <!-- Created with Inkscape (http://www.inkscape.org/) -->
3
+
4
+ <svg
5
+ width="199.99997"
6
+ height="200.00002"
7
+ viewBox="0 0 52.916659 52.91667"
8
+ version="1.1"
9
+ id="svg5"
10
+ xmlns="http://www.w3.org/2000/svg"
11
+ xmlns:svg="http://www.w3.org/2000/svg">
12
+ <defs
13
+ id="defs2">
14
+ <rect
15
+ x="102.45944"
16
+ y="286.96857"
17
+ width="176.77415"
18
+ height="48.735157"
19
+ id="rect1984-5-2-3" />
20
+ </defs>
21
+ <g
22
+ id="layer1"
23
+ transform="translate(-33.776882,-224.36675)">
24
+ <rect
25
+ style="fill:#ffffff;stroke:#ffffff;stroke-width:0.264583;stroke-dasharray:none;stroke-dashoffset:0"
26
+ id="rect1448-3"
27
+ width="52.652084"
28
+ height="52.652084"
29
+ x="33.909172"
30
+ y="224.49904" />
31
+ <text
32
+ xml:space="preserve"
33
+ transform="matrix(0.26458333,0,0,0.26458333,11.23015,171.5253)"
34
+ id="text1982-6-5-6"
35
+ style="font-size:14.6667px;line-height:1.25;font-family:sans-serif;white-space:pre;shape-inside:url(#rect1984-5-2-3);display:inline;fill:#ff6600"><tspan
36
+ x="102.45898"
37
+ y="299.94534"
38
+ id="tspan474">default_param_blank</tspan></text>
39
+ </g>
40
+ </svg>
package/tsconfig.json ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "esnext",
4
+ "module": "esnext",
5
+ "outDir": "./dist",
6
+ "esModuleInterop": true,
7
+ "moduleResolution": "bundler",
8
+ "declaration": true,
9
+ "sourceMap": true,
10
+ "strict": true
11
+ },
12
+ "include": ["./src"]
13
+ }
@@ -0,0 +1,7 @@
1
+ import { defineConfig } from 'vitest/config';
2
+
3
+ export default defineConfig({
4
+ test: {
5
+ include: ['src/**/*.{test,spec}.{js,ts}']
6
+ }
7
+ });