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,238 @@
1
+ // spider.ts
2
+
3
+ import type {
4
+ tContour,
5
+ tParamDef,
6
+ tParamVal,
7
+ tGeom,
8
+ tExtrude,
9
+ tPageDef
10
+ //tSubInst
11
+ //tSubDesign
12
+ } from 'geometrix';
13
+ import {
14
+ contour,
15
+ contourCircle,
16
+ figure,
17
+ //degToRad,
18
+ radToDeg,
19
+ ffix,
20
+ pNumber,
21
+ //pCheckbox,
22
+ //pDropdown,
23
+ initGeom,
24
+ EExtrude,
25
+ EBVolume
26
+ } from 'geometrix';
27
+
28
+ const pDef: tParamDef = {
29
+ partName: 'spider',
30
+ params: [
31
+ //pNumber(name, unit, init, min, max, step)
32
+ pNumber('D1', 'mm', 100, 10, 400, 1),
33
+ pNumber('L1', 'mm', 400, 100, 1000, 10),
34
+ pNumber('L2', 'mm', 400, 100, 1000, 10),
35
+ pNumber('L3', 'mm', 100, 10, 400, 1),
36
+ pNumber('L4', 'mm', 3000, 500, 8000, 10),
37
+ pNumber('L5', 'mm', 2000, 100, 8000, 10),
38
+ pNumber('L6', 'mm', 30, 1, 100, 1),
39
+ pNumber('E1', 'mm', 3, 1, 80, 1),
40
+ pNumber('E2', 'mm', 50, 1, 200, 1),
41
+ pNumber('E3', 'mm', 3, 1, 80, 1),
42
+ pNumber('R2', 'mm', 100, 0, 400, 10),
43
+ pNumber('N1', '', 6, 1, 20, 1)
44
+ ],
45
+ paramSvg: {
46
+ D1: 'spider_profile.svg',
47
+ L1: 'spider_profile.svg',
48
+ L2: 'spider_profile.svg',
49
+ L3: 'spider_profile.svg',
50
+ L4: 'spider_profile.svg',
51
+ L5: 'spider_lateral.svg',
52
+ L6: 'spider_lateral.svg',
53
+ E1: 'spider_profile.svg',
54
+ E2: 'spider_profile.svg',
55
+ E3: 'spider_profile.svg',
56
+ R2: 'spider_profile.svg',
57
+ N1: 'spider_lateral.svg'
58
+ },
59
+ sim: {
60
+ tMax: 360,
61
+ tStep: 0.5,
62
+ tUpdate: 500 // every 0.5 second
63
+ }
64
+ };
65
+
66
+ type tCtr1 = (sx: number, sy: number, sl: number) => tContour;
67
+ type tCtr2 = (width: number, height: number, xpos: number, ypos: number) => tContour;
68
+
69
+ function pGeom(t: number, param: tParamVal): tGeom {
70
+ let ctrSquare: tCtr1;
71
+ let ctrRect: tCtr2;
72
+ const rGeome = initGeom(pDef.partName);
73
+ const figLegs = figure();
74
+ const figTube = figure();
75
+ const figBody = figure();
76
+ rGeome.logstr += `${rGeome.partName} simTime: ${t}\n`;
77
+ try {
78
+ const R1 = param.D1 / 2;
79
+ if (param.D1 < param.E2) {
80
+ throw `err476: D1 ${param.D1} smaller then E2 ${param.E2}`;
81
+ }
82
+ const legE2 = param.E2 / 2;
83
+ const legStartY = Math.sqrt(R1 ** 2 - legE2 ** 2);
84
+ const legL2 = param.L1 + param.L2 * Math.sqrt(2);
85
+ const legL3 = param.L2 + param.L1 * Math.sqrt(2);
86
+ const legL4 = param.L4 - legL3;
87
+ if (legL4 < param.R2) {
88
+ throw `err984: L4 ${param.L4} too small compare to R2 ${param.R2}`;
89
+ }
90
+ const legL4x = legL4 * Math.cos(Math.PI / 4);
91
+ const legL4y = legL4 * Math.sin(Math.PI / 4);
92
+ const E2x = param.E2 * Math.cos(Math.PI / 4);
93
+ const E2y = param.E2 * Math.sin(Math.PI / 4);
94
+ const elbowx = param.E2 * Math.tan(Math.PI / 8);
95
+ if (R1 < param.E1) {
96
+ throw `err092: D1 ${param.D1} too small compare to E1 ${param.E1}`;
97
+ }
98
+ if (param.L3 < param.E2) {
99
+ throw `err994: L3 ${param.L3} smaller than E2 ${param.E2}`;
100
+ }
101
+ if (param.L3 < 2 * param.E3) {
102
+ throw `err997: L3 ${param.L3} too small compare to E3 ${param.E3}`;
103
+ }
104
+ const squareD = ((param.L3 - param.E2) / 2) * Math.cos(Math.PI / 4);
105
+ const squareX = legL2 + legL4x + squareD;
106
+ const squareY = -param.L1 - legL4y + squareD;
107
+ const squareY2 = squareY - param.E3 * Math.sqrt(2);
108
+ if (param.L5 < param.N1 * param.L6) {
109
+ throw `err110: L5 ${param.L5} too small compare to N1 ${param.N1} and L6 ${param.L6}`;
110
+ }
111
+ let legStep = 1;
112
+ if (param.N1 > 1) {
113
+ legStep = (param.L5 - param.L6) / (param.N1 - 1);
114
+ }
115
+ const legPos = [...Array(param.N1).keys()].map((i) => i * legStep);
116
+ ctrSquare = function (sx: number, sy: number, sl: number): tContour {
117
+ const rCtr = contour(sx, sy)
118
+ .addSegStrokeA(sx + sl * Math.cos(Math.PI / 4), sy - sl * Math.sin(Math.PI / 4))
119
+ .addSegStrokeA(sx, sy - 2 * sl * Math.sin(Math.PI / 4))
120
+ .addSegStrokeA(sx - sl * Math.cos(Math.PI / 4), sy - sl * Math.sin(Math.PI / 4))
121
+ .closeSegStroke();
122
+ return rCtr;
123
+ };
124
+ ctrRect = function (width: number, height: number, xpos: number, ypos: number): tContour {
125
+ const rCtr = contour(xpos, ypos)
126
+ .addSegStrokeA(xpos + width, ypos)
127
+ .addSegStrokeA(xpos + width, ypos + height)
128
+ .addSegStrokeA(xpos, ypos + height)
129
+ .closeSegStroke();
130
+ return rCtr;
131
+ };
132
+ const posAngle = (Math.sin((2 * Math.PI * t) / pDef.sim.tMax) * Math.PI) / 2;
133
+ rGeome.logstr += `spide leg number: ${param.N1}\n`;
134
+ rGeome.logstr += `spide position angle: ${ffix(radToDeg(posAngle))} degree\n`;
135
+ // figLegs
136
+ const ctrLeg = contour(legE2, -legStartY)
137
+ .addCornerRounded(param.R2)
138
+ .addSegStrokeA(legE2, -param.L1)
139
+ .addCornerRounded(param.R2)
140
+ .addSegStrokeA(legL2, -param.L1)
141
+ .addCornerRounded(param.R2 + param.E2)
142
+ .addSegStrokeA(legL2 + legL4x, -param.L1 - legL4y)
143
+ .addSegStrokeA(legL2 + legL4x - E2x, -param.L1 - legL4y - E2y)
144
+ .addSegStrokeA(legL2 - elbowx, -param.L1 - param.E2)
145
+ .addCornerRounded(param.R2)
146
+ .addSegStrokeA(-legL2 + elbowx, -param.L1 - param.E2)
147
+ .addCornerRounded(param.R2)
148
+ .addSegStrokeA(-legL2 - legL4x + E2x, -param.L1 - legL4y - E2y)
149
+ .addSegStrokeA(-legL2 - legL4x, -param.L1 - legL4y)
150
+ .addSegStrokeA(-legL2, -param.L1)
151
+ .addCornerRounded(param.R2 + param.E2)
152
+ .addSegStrokeA(-legE2, -param.L1)
153
+ .addCornerRounded(param.R2)
154
+ .addSegStrokeA(-legE2, -legStartY)
155
+ .addCornerRounded(param.R2)
156
+ .closeSegArc(R1, true, false);
157
+ figLegs.addMain(ctrLeg);
158
+ figLegs.addMain(contourCircle(0, 0, R1 - param.E1));
159
+ figLegs.addSecond(ctrSquare(squareX, squareY, param.L3));
160
+ figLegs.addSecond(ctrSquare(squareX, squareY2, param.L3 - 2 * param.E3));
161
+ figLegs.addSecond(ctrSquare(-squareX, squareY, param.L3));
162
+ figLegs.addSecond(ctrSquare(-squareX, squareY2, param.L3 - 2 * param.E3));
163
+ // figTube
164
+ figTube.addMain(contourCircle(0, 0, R1));
165
+ figTube.addMain(contourCircle(0, 0, R1 - param.E1));
166
+ figTube.addMain(ctrSquare(squareX, squareY, param.L3));
167
+ figTube.addMain(ctrSquare(squareX, squareY2, param.L3 - 2 * param.E3));
168
+ figTube.addMain(ctrSquare(-squareX, squareY, param.L3));
169
+ figTube.addMain(ctrSquare(-squareX, squareY2, param.L3 - 2 * param.E3));
170
+ figTube.addSecond(ctrLeg);
171
+ // figBody
172
+ figBody.addSecond(ctrRect(param.L5, param.D1, 0, -param.D1 / 2));
173
+ figBody.addSecond(ctrRect(param.L5, param.L3, 0, -param.L4 - param.L3));
174
+ for (const posx of legPos) {
175
+ figBody.addSecond(ctrRect(param.L6, param.L4, posx, -param.L4));
176
+ }
177
+ // final figure list
178
+ rGeome.fig = {
179
+ faceLegs: figLegs.rotate(0, 0, posAngle),
180
+ faceTube: figTube.rotate(0, 0, posAngle),
181
+ faceBody: figBody
182
+ };
183
+ const designName = rGeome.partName;
184
+ const preExtrude = legPos.map((posX, idx) => {
185
+ const rElem: tExtrude = {
186
+ outName: `subpax_${designName}_leg_${idx}`,
187
+ face: `${designName}_faceLegs`,
188
+ extrudeMethod: EExtrude.eLinearOrtho,
189
+ length: param.L6,
190
+ rotate: [0, 0, 0],
191
+ translate: [0, 0, posX]
192
+ };
193
+ return rElem;
194
+ });
195
+ const legList = legPos.map((elem, idx) => {
196
+ const subElem = `subpax_${designName}_leg_${idx}`;
197
+ return subElem;
198
+ });
199
+ rGeome.vol = {
200
+ extrudes: [
201
+ {
202
+ outName: `subpax_${designName}_tube`,
203
+ face: `${designName}_faceTube`,
204
+ extrudeMethod: EExtrude.eLinearOrtho,
205
+ length: param.L5,
206
+ rotate: [0, 0, 0],
207
+ translate: [0, 0, 0]
208
+ },
209
+ ...preExtrude
210
+ ],
211
+ volumes: [
212
+ {
213
+ outName: `pax_${designName}`,
214
+ boolMethod: EBVolume.eUnion,
215
+ inList: [`subpax_${designName}_tube`, ...legList]
216
+ }
217
+ ]
218
+ };
219
+ // sub-design
220
+ rGeome.sub = {};
221
+ // finalize
222
+ rGeome.logstr += 'heliostat-spider draw successfully!\n';
223
+ rGeome.calcErr = false;
224
+ } catch (emsg) {
225
+ rGeome.logstr += emsg as string;
226
+ console.log(emsg as string);
227
+ }
228
+ return rGeome;
229
+ }
230
+
231
+ const spiderDef: tPageDef = {
232
+ pTitle: 'Heliostat spider',
233
+ pDescription: 'The spider part for the control of the inclination of the heliostat',
234
+ pDef: pDef,
235
+ pGeom: pGeom
236
+ };
237
+
238
+ export { spiderDef };
@@ -0,0 +1,320 @@
1
+ // surface.ts
2
+
3
+ import type {
4
+ tContour,
5
+ tParamDef,
6
+ tParamVal,
7
+ tGeom,
8
+ tExtrude,
9
+ tPageDef
10
+ //tSubInst
11
+ //tSubDesign
12
+ } from 'geometrix';
13
+ import {
14
+ contour,
15
+ //contourCircle,
16
+ figure,
17
+ //degToRad,
18
+ //radToDeg,
19
+ ffix,
20
+ pNumber,
21
+ pCheckbox,
22
+ pDropdown,
23
+ initGeom,
24
+ EExtrude,
25
+ EBVolume
26
+ } from 'geometrix';
27
+
28
+ const pDef: tParamDef = {
29
+ partName: 'surface',
30
+ params: [
31
+ //pNumber(name, unit, init, min, max, step)
32
+ pNumber('LH', 'mm', 1600, 100, 4000, 1),
33
+ pNumber('LV', 'mm', 1000, 100, 4000, 1),
34
+ pNumber('LZ', 'mm', 40, 0, 100, 1),
35
+ pNumber('nx', '', 9, 1, 40, 1),
36
+ pNumber('ny', '', 9, 1, 40, 1),
37
+ pDropdown('main_direction', ['horizontal', 'vertical']),
38
+ pCheckbox('crenel', false),
39
+ pNumber('first_row', '', 9, 1, 40, 1),
40
+ pNumber('second_row', '', 9, 1, 40, 1),
41
+ pNumber('EH', 'mm', 10, 0, 1000, 1),
42
+ pCheckbox('EH_gradient', false),
43
+ pNumber('EH_sup', 'mm', 500, 0, 1000, 1),
44
+ pNumber('EH_cycle', '', 1, 0, 3, 0.05),
45
+ pNumber('EH_start', '', 0, 0, 1, 0.05),
46
+ pDropdown('EH_shape', ['sinusoid', 'triangle', 'sawUp', 'sawDown']),
47
+ pNumber('EV', 'mm', 10, 0, 1000, 1),
48
+ pCheckbox('EV_gradient', false),
49
+ pNumber('EV_sup', 'mm', 500, 0, 1000, 1),
50
+ pNumber('EV_cycle', '', 1, 0, 3, 0.05),
51
+ pNumber('EV_start', '', 0, 0, 1, 0.05),
52
+ pDropdown('EV_shape', ['sinusoid', 'triangle', 'sawUp', 'sawDown']),
53
+ pNumber('power_efficiency', '%', 16, 0, 100, 0.1),
54
+ pNumber('solar_power', 'W/m2', 816, 100, 2000, 1) // 1361*0.6=816 W/m2
55
+ ],
56
+ paramSvg: {
57
+ LH: 'surface_main.svg',
58
+ LV: 'surface_main.svg',
59
+ LZ: 'surface_lz.svg',
60
+ nx: 'surface_main.svg',
61
+ ny: 'surface_main.svg',
62
+ main_direction: 'surface_crenel.svg',
63
+ crenel: 'surface_crenel.svg',
64
+ first_row: 'surface_extremities.svg',
65
+ second_row: 'surface_extremities.svg',
66
+ EH: 'surface_main.svg',
67
+ EH_gradient: 'surface_space_evolution.svg',
68
+ EH_sup: 'surface_space_evolution.svg',
69
+ EH_cycle: 'surface_space_evolution.svg',
70
+ EH_start: 'surface_space_evolution.svg',
71
+ EH_shape: 'surface_space_shape.svg',
72
+ EV: 'surface_main.svg',
73
+ EV_gradient: 'surface_space_evolution.svg',
74
+ EV_sup: 'surface_space_evolution.svg',
75
+ EV_cycle: 'surface_space_evolution.svg',
76
+ EV_start: 'surface_space_evolution.svg',
77
+ EV_shape: 'surface_space_shape.svg',
78
+ power_efficiency: 'surface_power.svg',
79
+ solar_power: 'surface_power.svg'
80
+ },
81
+ sim: {
82
+ tMax: 180,
83
+ tStep: 0.5,
84
+ tUpdate: 500 // every 0.5 second
85
+ }
86
+ };
87
+
88
+ // (px, py) coordinates of bottom-left of the panel in mm
89
+ type tCtr1 = (px: number, py: number) => tContour;
90
+ type tPositions = [number, number][];
91
+
92
+ function pGeom(t: number, param: tParamVal): tGeom {
93
+ let ctrPanelProfile: tCtr1;
94
+ const rGeome = initGeom(pDef.partName);
95
+ const figSurface = figure();
96
+ const figOnePanel = figure();
97
+ rGeome.logstr += `${rGeome.partName} simTime: ${t}\n`;
98
+ try {
99
+ const panel_surface = (param.LH * param.LV) / 10 ** 6;
100
+ const panel_power = (param.solar_power * panel_surface * param.power_efficiency) / 100;
101
+ rGeome.logstr += `panel surface: ${ffix(panel_surface)} m2\n`;
102
+ rGeome.logstr += `panel power: ${ffix(panel_power)} W\n`;
103
+ const max_panel_nb = param.nx * param.ny;
104
+ rGeome.logstr += `max panel number: ${max_panel_nb}\n`;
105
+ rGeome.logstr += `max panel surface: ${ffix(max_panel_nb * panel_surface)} m2\n`;
106
+ rGeome.logstr += `max panel power: ${ffix(max_panel_nb * panel_power)} W\n`;
107
+ const lenMain = param.main_direction === 1 ? param.ny : param.nx;
108
+ const lenLateral = param.main_direction === 1 ? param.nx : param.ny;
109
+ const EMain = param.main_direction === 1 ? param.EV : param.EH;
110
+ const EMainGradient = param.main_direction === 1 ? param.EV_gradient : param.EH_gradient;
111
+ const EMainSup = param.main_direction === 1 ? param.EV_sup : param.EH_sup;
112
+ const EMainCycle = param.main_direction === 1 ? param.EV_cycle : param.EH_cycle;
113
+ const EMainStart = param.main_direction === 1 ? param.EV_start : param.EH_start;
114
+ const EMainShape = param.main_direction === 1 ? param.EV_shape : param.EH_shape;
115
+ const ELateral = param.main_direction === 0 ? param.EV : param.EH;
116
+ const ELateralGradient = param.main_direction === 0 ? param.EV_gradient : param.EH_gradient;
117
+ const ELateralSup = param.main_direction === 0 ? param.EV_sup : param.EH_sup;
118
+ const ELateralCycle = param.main_direction === 0 ? param.EV_cycle : param.EH_cycle;
119
+ const ELateralStart = param.main_direction === 0 ? param.EV_start : param.EH_start;
120
+ const ELateralShape = param.main_direction === 0 ? param.EV_shape : param.EH_shape;
121
+ const lenRow: number[] = [];
122
+ for (let i = 0; i < lenMain; i++) {
123
+ const iEven = (i + 1) % 2; // 0 or 1
124
+ const elemNb = param.crenel ? lenLateral - iEven : lenLateral;
125
+ lenRow.push(elemNb);
126
+ }
127
+ lenRow[0] = param.first_row;
128
+ lenRow[lenRow.length - 1] = param.first_row;
129
+ if (lenMain > 2) {
130
+ lenRow[1] = param.second_row;
131
+ lenRow[lenRow.length - 2] = param.second_row;
132
+ }
133
+ let panelNb = 0;
134
+ lenRow.forEach((oneRow) => {
135
+ panelNb += oneRow;
136
+ });
137
+ rGeome.logstr += `actual panel number: ${panelNb} (${ffix(
138
+ (100 * panelNb) / max_panel_nb
139
+ )} %)\n`;
140
+ rGeome.logstr += `actual panel surface: ${ffix(panelNb * panel_surface)} m2\n`;
141
+ rGeome.logstr += `actual panel power: ${ffix(panelNb * panel_power)} W\n`;
142
+ const eMain: number[] = [];
143
+ for (let i = 0; i < lenMain - 1; i++) {
144
+ let eSpace = EMain;
145
+ if (EMainGradient === 1) {
146
+ const gapNb = lenMain > 2 ? lenMain - 2 : 1; // -2 to get a complete cycle
147
+ const phase = (EMainStart + (i * EMainCycle) / gapNb) % 1;
148
+ switch (EMainShape) {
149
+ case 0: // sinusoid
150
+ eSpace += (EMainSup * (1 - Math.cos(phase * 2 * Math.PI))) / 2;
151
+ break;
152
+ case 1: // triangle
153
+ eSpace += EMainSup * (1 - 2 * Math.abs(phase - 0.5));
154
+ break;
155
+ case 2: // sawUp
156
+ eSpace += EMainSup * phase;
157
+ break;
158
+ case 3: // sawDown
159
+ eSpace += EMainSup * (1 - phase);
160
+ break;
161
+ default:
162
+ eSpace += EMainSup;
163
+ }
164
+ }
165
+ eMain.push(eSpace);
166
+ }
167
+ let eMainTotal = 0;
168
+ const eMainCumul: number[] = [];
169
+ eMainCumul.push(0);
170
+ eMain.forEach((eSpace) => {
171
+ eMainTotal += eSpace;
172
+ eMainCumul.push(eMainTotal);
173
+ });
174
+ const eLateral: number[] = [];
175
+ for (let i = 0; i < lenLateral - 1; i++) {
176
+ let eSpace = ELateral;
177
+ if (ELateralGradient === 1) {
178
+ const gapNb = lenLateral > 2 ? lenLateral - 2 : 1; // -2 to get a complete cycle
179
+ const phase = (ELateralStart + (i * ELateralCycle) / gapNb) % 1;
180
+ switch (ELateralShape) {
181
+ case 0: // sinusoid
182
+ eSpace += (ELateralSup * (1 - Math.cos(phase * 2 * Math.PI))) / 2;
183
+ break;
184
+ case 1: // triangle
185
+ eSpace += ELateralSup * (1 - 2 * Math.abs(phase - 0.5));
186
+ break;
187
+ case 2: // sawUp
188
+ eSpace += ELateralSup * phase;
189
+ break;
190
+ case 3: // sawDown
191
+ eSpace += ELateralSup * (1 - phase);
192
+ break;
193
+ default:
194
+ eSpace += ELateralSup;
195
+ }
196
+ }
197
+ eLateral.push(eSpace);
198
+ }
199
+ let eLateralTotal = 0;
200
+ const eLateralCumul: number[] = [];
201
+ eLateralCumul.push(0);
202
+ eLateral.forEach((eSpace) => {
203
+ eLateralTotal += eSpace;
204
+ eLateralCumul.push(eLateralTotal);
205
+ });
206
+ let gLenHorizontal = 0; // mm
207
+ let gLenVertical = 0; // mm
208
+ if (param.main_direction === 0) {
209
+ // horizontal
210
+ gLenHorizontal = lenMain * param.LH + eMainTotal;
211
+ gLenVertical = lenLateral * param.LV + eLateralTotal;
212
+ } else {
213
+ // vertical
214
+ gLenHorizontal = lenLateral * param.LH + eLateralTotal;
215
+ gLenVertical = lenMain * param.LV + eMainTotal;
216
+ }
217
+ const gArea = (gLenHorizontal * gLenVertical) / 10 ** 6; // m2
218
+ rGeome.logstr += `global horizontal width: ${ffix(gLenHorizontal / 1000)} m\n`;
219
+ rGeome.logstr += `global vertical height: ${ffix(gLenVertical / 1000)} m\n`;
220
+ rGeome.logstr += `global area: ${ffix(gArea)} m2\n`;
221
+ rGeome.logstr += `area efficiency: ${ffix((100 * panelNb * panel_surface) / gArea)} %\n`;
222
+ const ox = -gLenHorizontal / 2;
223
+ const oy = -gLenVertical / 2;
224
+ ctrPanelProfile = function (px: number, py: number): tContour {
225
+ const rPanelProfile = contour(px, py)
226
+ .addSegStrokeA(px + param.LH, py)
227
+ .addSegStrokeA(px + param.LH, py + param.LV)
228
+ .addSegStrokeA(px, py + param.LV)
229
+ .closeSegStroke();
230
+ return rPanelProfile;
231
+ };
232
+ // figSurface
233
+ const panelPositions: tPositions = [];
234
+ lenRow.forEach((oneRow, rowIdx) => {
235
+ const half = (lenLateral - oneRow) % 2;
236
+ const offset = Math.floor((lenLateral - oneRow) / 2);
237
+ for (let pIdx = 0; pIdx < oneRow; pIdx++) {
238
+ let dx = 0;
239
+ let dy = 0;
240
+ if (param.main_direction === 0) {
241
+ // horizontal
242
+ dx = ox + rowIdx * param.LH + eMainCumul[rowIdx];
243
+ dy = oy + (offset + pIdx) * param.LV + eLateralCumul[offset + pIdx];
244
+ if (half === 1) {
245
+ dy +=
246
+ (param.LV +
247
+ eLateralCumul[offset + pIdx + 1] -
248
+ eLateralCumul[offset + pIdx]) /
249
+ 2;
250
+ }
251
+ } else {
252
+ // vertical
253
+ dy = oy + rowIdx * param.LV + eMainCumul[rowIdx];
254
+ dx = ox + (offset + pIdx) * param.LH + eLateralCumul[offset + pIdx];
255
+ if (half === 1) {
256
+ dx +=
257
+ (param.LH +
258
+ eLateralCumul[offset + pIdx + 1] -
259
+ eLateralCumul[offset + pIdx]) /
260
+ 2;
261
+ }
262
+ }
263
+ panelPositions.push([dx, dy]);
264
+ }
265
+ });
266
+ for (const pos of panelPositions) {
267
+ figSurface.addMain(ctrPanelProfile(pos[0], pos[1]));
268
+ }
269
+ // figOnePanel
270
+ figOnePanel.addMain(ctrPanelProfile(0, 0));
271
+ // final figure list
272
+ rGeome.fig = {
273
+ faceSurface: figSurface,
274
+ faceOnePanel: figOnePanel
275
+ };
276
+ const designName = rGeome.partName;
277
+ rGeome.vol = {
278
+ extrudes: panelPositions.map((elem, idx) => {
279
+ const rElem: tExtrude = {
280
+ outName: `subpax_${designName}_panel_${idx}`,
281
+ face: `${designName}_faceOnePanel`,
282
+ extrudeMethod: EExtrude.eLinearOrtho,
283
+ length: param.LZ,
284
+ rotate: [0, 0, 0],
285
+ translate: [elem[0], elem[1], 0]
286
+ };
287
+ return rElem;
288
+ }),
289
+ volumes: [
290
+ {
291
+ outName: `pax_${designName}`,
292
+ //boolMethod: EBVolume.eIdentity,
293
+ boolMethod: EBVolume.eUnion,
294
+ inList: panelPositions.map((elem, idx) => {
295
+ const subElem = `subpax_${designName}_panel_${idx}`;
296
+ return subElem;
297
+ })
298
+ }
299
+ ]
300
+ };
301
+ // sub-design
302
+ rGeome.sub = {};
303
+ // finalize
304
+ rGeome.logstr += 'panel-surface draw successfully!\n';
305
+ rGeome.calcErr = false;
306
+ } catch (emsg) {
307
+ rGeome.logstr += emsg as string;
308
+ console.log(emsg as string);
309
+ }
310
+ return rGeome;
311
+ }
312
+
313
+ const surfaceDef: tPageDef = {
314
+ pTitle: 'Heliostat panel-surface',
315
+ pDescription: 'The surface collecting the solar power',
316
+ pDef: pDef,
317
+ pGeom: pGeom
318
+ };
319
+
320
+ export { surfaceDef };