-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlucy-kwad-modules.scad
1315 lines (1293 loc) · 66.5 KB
/
lucy-kwad-modules.scad
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
module WbraceP(partLayout = 0){
difference(){
hull(){
translate([carbUWP.x - 8, fs.y / 2 - 4 + 1.6, carbUWP.z])cylinder(h = 4, d = 6);
translate([carbUWP.x - 8 - 5, fs.y / 2, carbLWP.z])cube([10, 4, 4]);
tranX(carbUWP.x - 8)UpperWingSpace()tranY(UW_FWO + 3.5)cylinder(h = 4, d = 6);
}
translate([carbUWP.x - 8, fs.y / 2 - 4 + 1.6, carbUWP.z])cylinder(h = 4, d = 4);
tranX(carbUWP.x - 8)UpperWingSpace()tranY(UW_FWO + 3.5)cylinder(h = 4, d = 4);
wingU3(100, 0.2);
fuse3(100, 0.2);
}
}
{module WbraceC(partLayout = 0)
tranX(-100 * partLayout){//wing brace carbon fiber
neg = partLayout == 0 ? 1 : 0;
braceH = fs.z - CarBT - FR_CuT + WB_RSD;
echo(braceH);
//moveRadiiPoints(rp,tran=[0,0],rot=0)
braceP = concat(//brace points
[[carbUWP.z, 0, 0]],
moveRadiiPoints(WB_PP(), [carbUWP.z, fs.y / 2 - WB_BNO - (fs_bd + fs_bhd) / 2]),
moveRadiiPoints(fs_BP(), [carbUWP.z, fs.y / 2 - WB_BNO - fs_bd / 2], 90),
[[carbUWP.z, carbUWP.y, 0]],
let(h = 3 + WB_PW)moveRadiiPoints(WB_PP(), [carbUWP.z + h, carbUWP.y + (h) / tan(UWXang)], -UWXang),
moveRadiiPoints(fs_BP(), [carbUWP.z + braceH / 2.5, carbUWP.y + braceH / 2.5 / tan(UWXang)], 90 - UWXang),
moveRadiiPoints(WB_PP(), [carbUWP.z + braceH - 11, carbUWP.y + (braceH - 11) / tan(UWXang)], -UWXang),
//[[carbUWP.z+braceH,carbUWP.y+braceH/tan(UWXang),0]],
[[carbUWP.z + braceH - 7, (fs.y / 2 + carbUWP.y + (braceH - 6) / tan(UWXang)) / 2 - 3, 10]],
[[carbUWP.z + braceH, fs.y / 2, 0]],
[[carbUWP.z + braceH - WB_RSD, fs.y / 2, 0]],
[[carbUWP.z + braceH - WB_RSD, fs.y / 2 - FR_CaT, 0]],
[[carbUWP.z + fs.z - CarBT, fs.y / 2 - FR_CaT, 0]],
[[carbUWP.z + fs.z - CarBT + 2, 0, 70]]
);
color("red")tranX(WB_XP)rotate([0, -90 * neg, 0])linear_extrude(WB_CaT)shell2d(-4, 0, 1)difference(){
polygon(polyRound(mirrorPoints(braceP, atten = [1, 1]), gfn));
for (i = [0, 1])mirror([0, i, 0]){
translate([carbUWP.z + braceH - WB_RSD, fs.y / 2 - FR_CaT - WB_tol / 2, 0])internalSq([FR_CuT * 3, FR_CaT + WB_tol], WB_mir);
//#translate([carbUWP.z+braceH-14,carbUWP.y+(braceH-14)/tan(UWXang)])circle(WB_mir);
for (i = [1, 4, 15, 18, 28])translate(parallelFollow([braceP[i - 1], braceP[i], braceP[i + 1]], thick = WB_mir * cos(45), minR = 0))circle(WB_mir);
//translate(parallelFollow([braceP[14],braceP[15],braceP[16]],thick=WB_mir*cos(45),minR=0))circle(WB_mir);
//translate(parallelFollow([braceP[17],braceP[18],braceP[19]],thick=WB_mir*cos(45),minR=0))circle(WB_mir);
//translate(parallelFollow([braceP[27],braceP[28],braceP[29]],thick=WB_mir*cos(45),minR=0))circle(WB_mir);
}
}
}
function WB_PP(index1, index2)=//post points
let(WB_PP = [//post points
[0, -WB_PW, WB_mir],
[-WB_CaT, -WB_PW, 0],
[-WB_CaT, 0, 0],
[0, 0, WB_mir],
])
range(WB_PP, index1, index2);
}
module thecam(index = 0){
//translate([72,0,cos(theta-camA)*(camD/2)+carbLWP[2]+CarBT/2])rotate([0,theta-camA,0])difference(){
if (index == 0) {
translate([64 + fusehozoff, 0, carbLWP[2] + CarBT / 2 + camMH])difference(){
union(){
//bracket
translate([-camM[0] / 2, camM[1] / 2 - camM[3], -camM[4]])cube([camM[0], camM[3], camM[2]]);
translate([-camM[0] / 2, 0, -camM[4]])cube([camM[0], camM[1] / 2, camM[3]]);
rotate([0, theta - camA, 0])hull(){//camera unit
translate([-camPP, -camW / 2, -camH / 2])cube([10, camW, camH]);
translate([camL - camPP, 0, 0])rotate([0, 90, 0])cylinder(d = camD, h = 0.01);
}
}
union(){
translate([0, camM[6] / 2, -50])cylinder(d = camM[5], h = 40);
}
}
} else {
translate([54 + fusehozoff, 0, carbLWP[2] + CarBT / 2 + camMH])translate([0, camM[6] / 2, -50])cylinder(d = camM[5], h = 40);
}
}
module cam(expand = 0, mode = 0){
div = mode == 0 ? 2 : 10;
sl = 10;//square length
dia = 17;
translate([camP[0], 0, carbLWP[2] + camP[1]]){
hull()for(i = [70 - camA.x, 70 - camA.y])rotate([0, i, 0])if(expand > 0) translate([camL + sl * 2 - camHP[1] + expand, 0, 0])rotate([0, -90, 0])cylinder(h = camL + sl - camHP[1] + expand, d = dia + expand * 2);
if (mode == 0) {
//hull()rotate([0, 20, 0])difference(){
hull()for(i = [70 - camA.x:(camA.x - camA.y) / div:70 - camA.y])rotate([0, i, 0])difference(){
union(){
translate([sl / 2 - camHP[1] - expand, 0, 0])cube([sl, camW + expand * 2, camH + expand * 2], true);
translate([camL - camHP[1] + 2 + expand, 0, 0])rotate([0, -90, 0])cylinder(h = 3, d = dia + expand * 2);
}
union(){
translate([0, w / 2 - 3, 0])rotate([-90, 0, 0]){
cylinder(d = 3.2, h = 10);
translate([camHP[0] - camHP[1], 0, 0])cylinder(d = 3.2, h = 10);
}
}
}
} else {
for (i = [70 - camA.x:(camA.x - camA.y) / div:70 - camA.y])hull(){
rotate([0, i, 0])translate([camL + sl / 2 - camHP[1] + expand, 0, 0])rotate([0, -90, 0])cylinder(h = 3, d = dia + expand * 2);
rotate([0, i + 1, 0])translate([camL + sl / 2 - camHP[1] + expand, 0, 0])rotate([0, -90, 0])cylinder(h = 3, d = dia + expand * 2);
}
}
}
}
module camRef(partLayout = 0){
mntT = 3;//mount thick
cen = [camP.x, carbLWP.z + camP.y];
H = (camHP.y - camHP.x);//hypotenuse
p1a = [-cos(theta - camA.x - 10) * H, sin(theta - camA.x - 10) * H] + cen;
p2a = [-cos(theta - camA.y + 10) * H, sin(theta - camA.y + 10) * H] + cen;
p1b = [-cos(theta - camA.x - 10) * H - 0.01, sin(theta - camA.x - 10) * H - 0.01] + cen;
p2b = [-cos(theta - camA.y + 10) * H - 0.01, sin(theta - camA.y + 10) * H - 0.01] + cen;
thinwall_1side = concat(
[[camP.x - camRR, 0, 1]],
[[camP.x - camRR, railTE(0).y, 10]],
railTE(1, 2),
[[frontRailClip(1).x, frontRailClip(1).y, 0]]
);
thinwall = concat(
thinwall_1side,
//RailCustomiser(thinwall_1side,camST,0.5,1,1,0,0)
//RailCustomiser(rp,thick,minR,sgn=1,endpointenable=1,endAng1=0,endAng2=0)
revList(RailCustomiser(thinwall_1side, o1 = camST + 0.06/*camMT*1.3*/, minR = 0.5, mode = 0))
);
thinwall1 = concat(
thinwall_1side,
//RailCustomiser(thinwall_1side,camMT*1.3,0.5,1,1,0,0)
revList(RailCustomiser(thinwall_1side, o1 = camMT * 1.3, minR = 0.5, mode = 0))
);
//#for(i=thinwall_1side)rotate([-90,0,0])translate(i)circle(1);
// #for(i=thinwall)rotate([-90,0,0])translate(i)circle(0.5);
// #for(i=thinwall1)rotate([-90,0,0])translate(i)circle(1);
// echo(len(thinwall),len(thinwall1));
railsubtract = concat(
//railTE(),
//[[frontRailClip(0).x,-50,0]],
//RailCustomiser(concat([rearRailClip(7)],railTE()),30,2,1,0)
RailCustomiser(concat(railTE(), [[frontRailClip(0).x, -50, 0]]), o1 = 0, o2 = 60, minR = 2, mode = 0, a2 = -1)
);
bottomMountS = [//bottomMountSubtract points
[camST, camBMH, 3],
[camMT * 2 + camBMD, camBMH - camMT * 2 - camBMD + camST, 3],
[camMT * 2 + camBMD, camBMH - camMT * 2 - camBMD + camST - 20, 0],
[camMT * 2 + camBMD + 4, camBMH - camMT * 2 - camBMD + camST - 20, 0],
[camMT * 2 + camBMD + 4, camBMH + 4, 0],
[camST, camBMH + 4, 0],
];
tranX(60 * partLayout)rotX(partLayout * 180)difference(){
union(){
CamMSpace(0)difference(){
// linear_extrude(camBMH + 2)round2d(0, 2){
// tranX(camMT + camBMD / 2)circle(d = camMT * 2 + camBMD);
// square([camST, fs.y / 4]);
// }
// tranY(fs.y / 4)rotX(90)linear_extrude(fs.y / 2)polygon(polyRound(bottomMountS, gfn, 0));
}
hull(){
// intersection(){
// tranY(fs.y / 2 - carbW[2])rotX(90)linear_extrude(mntT * 3)translate([fs.x / 2 + fusehozoff + FR_OH + FR_CuT * tan(atan(fs.z / 2 / FR_OH) / 2 + 90), (carbLWP[2] - carbW[2] / 2) + fs.z - FR_CuT])circle(d = FR_BD + mntT * 3);
// translate([0, w / 2 - FR_CaT, carbLWP[2] - carbW[2] / 2])rotate([90, 0, 0])linear_extrude(camMT * 3)polygon(polyRound(thinwall1, gfn, 0));
// }
// tranY(fs.y / 2 - carbW[2])rotX(90)linear_extrude(mntT * 3)translate([fs.x / 2 + fusehozoff + FR_OH + FR_CuT * tan(atan(fs.z / 2 / FR_OH) / 2 + 90), (carbLWP[2] - carbW[2] / 2) + fs.z - FR_CuT])circle(d = FR_BD + mntT * 2);
}
// translate([0, w / 2 - FR_CaT, carbLWP[2] - carbW[2] / 2])rotate([90, 0, 0])linear_extrude(fs[1] / 2 - FR_CaT)polygon(polyRound(thinwall, gfn, 0));
// translate([0, w / 2 - FR_CaT, carbLWP[2] - carbW[2] / 2])rotate([90, 0, 0])linear_extrude(camMT)polygon(polyRound(thinwall1, gfn, 0));
// hull(){
// translate([camP.x - 7, w / 2 - FR_CaT - mntT, carbLWP[2] - carbW[2] / 2 + fs.z - 0.1])cube([10, mntT, 0.05]);
// translate([0, camW / 2 + mntT / 2, 0])rotate([90, 0, 0])linear_extrude(mntT * 0.5)union()offset(mntT + 1.1)hull(){
// polygon(concat(CentreN2PointsArc(p1a, p2a, cen, 0, 20), CentreN2PointsArc(p2b, p1b, cen, 0, 20)));
// translate(cen)circle(d = 0.01);
// }
// }
// difference(){
// union(){
// hull()translate([cen.x, 0, cen.y])for(i = [70 - camA.x:(camA.x - camA.y) / 5:70 - camA.y])rotate([0, i, 0])tranX(camL - camHP[1] + camD / 2 - 14)sphere(d = camD + 7);
// }
// translate([0, w / 2 + 0.1, carbLWP[2] - carbW[2] / 2])rotate([90, 0, 0])linear_extrude(fs[1] + 0.2)polygon(polyRound(railsubtract, gfn, 0));
// }
}
union(){
// cam(0.4, 0);
// fuseRev2(100, 0.2);
// fuseRailsRev2(0.2);
// tranY(fs.y / 2 - carbW[2] - 0.1)rotX(90)linear_extrude(mntT * 3 + 0.2)translate([fs.x / 2 + fusehozoff + FR_OH + FR_CuT * tan(atan(fs.z / 2 / FR_OH) / 2 + 90), (carbLWP[2] - carbW[2] / 2) + fs.z - FR_CuT])circle(d = FR_BD);
// #translate([camMT + camBMD / 2, 0, -0.1])CamMSpace(0)linear_extrude(bottomMountS[1].y)circle(d = camBMD);
// CamMSpace(0)translate([-50, -100.02, -50])cube([150, 100, 100]);
translate([0, camW / 2 + mntT+5, 0])rotate([90, 0, 0])tranZ(-0.05)linear_extrude(mntT + 0.1 + 10){//camer mount plate
union()offset(1.1){
polygon(concat(CentreN2PointsArc(p1a, p2a, cen, 0, 20), CentreN2PointsArc(p2b, p1b, cen, 0, 20)));
translate(cen)circle(d = 0.02);
}
}
}
}
/*rotX(-90)translate([cen.x,-cen.y])linear_extrude(10)intersection(){
difference(){
circle(camL-camHP.x+4,$fn=50);
circle(camL-camHP.x,$fn=50);
}
polygon([[0,0],[cos(70-camA.x-20)*50,sin(70-camA.x-20)*50],[cos(70-camA.y+20)*50,sin(70-camA.y+20)*50]]);
}*/
}
module camM(partLayout = 0){
mntT = 3;//mount thick
cen = [camP.x, carbLWP.z + camP.y];
H = (camHP.y - camHP.x);//hypotenuse
p1a = [-cos(theta - camA.x - 10) * H, sin(theta - camA.x - 10) * H] + cen;
p2a = [-cos(theta - camA.y + 10) * H, sin(theta - camA.y + 10) * H] + cen;
p1b = [-cos(theta - camA.x - 10) * H - 0.01, sin(theta - camA.x - 10) * H - 0.01] + cen;
p2b = [-cos(theta - camA.y + 10) * H - 0.01, sin(theta - camA.y + 10) * H - 0.01] + cen;
thinwall_1side = concat(
[[camP.x - camRR, 0, 1]],
[[camP.x - camRR, railTE(0).y, 10]],
railTE(1, 2),
[[frontRailClip(1).x, frontRailClip(1).y, 0]]
);
thinwall = concat(
thinwall_1side,
//RailCustomiser(thinwall_1side,camST,0.5,1,1,0,0)
//RailCustomiser(rp,thick,minR,sgn=1,endpointenable=1,endAng1=0,endAng2=0)
revList(RailCustomiser(thinwall_1side, o1 = camST + 0.06/*camMT*1.3*/, minR = 0.5, mode = 0))
);
thinwall1 = concat(
thinwall_1side,
//RailCustomiser(thinwall_1side,camMT*1.3,0.5,1,1,0,0)
revList(RailCustomiser(thinwall_1side, o1 = camMT * 1.3, minR = 0.5, mode = 0))
);
//#for(i=thinwall_1side)rotate([-90,0,0])translate(i)circle(1);
// #for(i=thinwall)rotate([-90,0,0])translate(i)circle(0.5);
// #for(i=thinwall1)rotate([-90,0,0])translate(i)circle(1);
// echo(len(thinwall),len(thinwall1));
railsubtract = concat(
//railTE(),
//[[frontRailClip(0).x,-50,0]],
//RailCustomiser(concat([rearRailClip(7)],railTE()),30,2,1,0)
RailCustomiser(concat(railTE(), [[frontRailClip(0).x, -50, 0]]), o1 = 0, o2 = 60, minR = 2, mode = 0, a2 = -1)
);
bottomMountS = [//bottomMountSubtract points
[camST, camBMH, 3],
[camMT * 2 + camBMD, camBMH - camMT * 2 - camBMD + camST, 3],
[camMT * 2 + camBMD, camBMH - camMT * 2 - camBMD + camST - 20, 0],
[camMT * 2 + camBMD + 4, camBMH - camMT * 2 - camBMD + camST - 20, 0],
[camMT * 2 + camBMD + 4, camBMH + 4, 0],
[camST, camBMH + 4, 0],
];
tranX(60 * partLayout)rotX(partLayout * 180)difference(){
union(){
CamMSpace(0)difference(){
linear_extrude(camBMH + 2)round2d(0, 2){
tranX(camMT + camBMD / 2)circle(d = camMT * 2 + camBMD);
square([camST, fs.y / 4]);
}
tranY(fs.y / 4)rotX(90)linear_extrude(fs.y / 2)polygon(polyRound(bottomMountS, gfn, 0));
}
hull(){
intersection(){
tranY(fs.y / 2 - carbW[2])rotX(90)linear_extrude(mntT * 3)translate([fs.x / 2 + fusehozoff + FR_OH + FR_CuT * tan(atan(fs.z / 2 / FR_OH) / 2 + 90), (carbLWP[2] - carbW[2] / 2) + fs.z - FR_CuT])circle(d = FR_BD + mntT * 3);
translate([0, w / 2 - FR_CaT, carbLWP[2] - carbW[2] / 2])rotate([90, 0, 0])linear_extrude(camMT * 3)polygon(polyRound(thinwall1, gfn, 0));
}
tranY(fs.y / 2 - carbW[2])rotX(90)linear_extrude(mntT * 3)translate([fs.x / 2 + fusehozoff + FR_OH + FR_CuT * tan(atan(fs.z / 2 / FR_OH) / 2 + 90), (carbLWP[2] - carbW[2] / 2) + fs.z - FR_CuT])circle(d = FR_BD + mntT * 2);
}
translate([0, w / 2 - FR_CaT, carbLWP[2] - carbW[2] / 2])rotate([90, 0, 0])linear_extrude(fs[1] / 2 - FR_CaT)polygon(polyRound(thinwall, gfn, 0));
translate([0, w / 2 - FR_CaT, carbLWP[2] - carbW[2] / 2])rotate([90, 0, 0])linear_extrude(camMT)polygon(polyRound(thinwall1, gfn, 0));
hull(){
translate([camP.x - 7, w / 2 - FR_CaT - mntT, carbLWP[2] - carbW[2] / 2 + fs.z - 0.1])cube([10, mntT, 0.05]);
translate([0, camW / 2 + mntT / 2, 0])rotate([90, 0, 0])linear_extrude(mntT * 0.5)union()offset(mntT + 1.1)hull(){
polygon(concat(CentreN2PointsArc(p1a, p2a, cen, 0, 20), CentreN2PointsArc(p2b, p1b, cen, 0, 20)));
translate(cen)circle(d = 0.01);
}
}
difference(){
union(){
hull()translate([cen.x, 0, cen.y])for(i = [70 - camA.x:(camA.x - camA.y) / 5:70 - camA.y])rotate([0, i, 0])tranX(camL - camHP[1] + camD / 2 - 14)sphere(d = camD + 7);
}
translate([0, w / 2 + 0.1, carbLWP[2] - carbW[2] / 2])rotate([90, 0, 0])linear_extrude(fs[1] + 0.2)polygon(polyRound(railsubtract, gfn, 0));
}
}
union(){
cam(0.4, 0);
fuseRev2(100, 0.2);
fuseRailsRev2(0.2);
tranY(fs.y / 2 - carbW[2] - 0.1)rotX(90)linear_extrude(mntT * 3 + 0.2)translate([fs.x / 2 + fusehozoff + FR_OH + FR_CuT * tan(atan(fs.z / 2 / FR_OH) / 2 + 90), (carbLWP[2] - carbW[2] / 2) + fs.z - FR_CuT])circle(d = FR_BD);
translate([camMT + camBMD / 2, 0, -0.1])CamMSpace(0)linear_extrude(bottomMountS[1].y)circle(d = camBMD);
CamMSpace(0)translate([-50, -100.02, -50])cube([150, 100, 100]);
translate([0, camW / 2 + mntT, 0])rotate([90, 0, 0])tranZ(-0.05)linear_extrude(mntT + 0.1 + 10){//camer mount plate
union()offset(1.1){
polygon(concat(CentreN2PointsArc(p1a, p2a, cen, 0, 20), CentreN2PointsArc(p2b, p1b, cen, 0, 20)));
translate(cen)circle(d = 0.02);
}
}
}
}
/*rotX(-90)translate([cen.x,-cen.y])linear_extrude(10)intersection(){
difference(){
circle(camL-camHP.x+4,$fn=50);
circle(camL-camHP.x,$fn=50);
}
polygon([[0,0],[cos(70-camA.x-20)*50,sin(70-camA.x-20)*50],[cos(70-camA.y+20)*50,sin(70-camA.y+20)*50]]);
}*/
}
module stackMountHoles(holeD = 3.2, holeS = 30.5){//two holes for the quad electronics stack
for (i = [0, 90])rotate([0, 0, i])translate([holeS / 2, holeS / 2, -10])circle(d = holeD);
}
{module wingU3(shellT = 6.2, tol_expand = 0, partLayout = 0)//upper carbon fiber wing
/*rotX(180-UWXang*partLayout)translate([0,0,-(carbUWP[2]-carbW[2]*0)*partLayout])*/{
tranY(180 * partLayout)UpperWingSpace(partLayout)tranZ((carbW[2] + tol_expand) * partLayout / 2 - (carbW[2] * 2 + tol_expand) / 2)linear_extrude(carbW[2] + tol_expand)offset(tol_expand)shell2d(-shellT, 0, 1)difference(){//difference the mounting holes from the wing polygon, shell the result, extrude it and translate into position.
polygon(polyRound(UWingRP, gfn, 0));//rounded wing polygon
if (shellT < 99) {//don't include if shell is very large as it is being used to differnce from the motor mount and it causes trouble when included in the difference
translate(UWing_MMH)circle(d = motP_mntD);//motor mount hole at the top of the wing
translate([WB_XP - WB_CaT / 2, (fs.z - CarBT - FR_CuT + WB_RSD) / 2.5 / sin(UWXang)])circle(d = motP_mntD);//motor mount hole at the top of the wing
translate([WB_XP - WB_CaT, -WB_PW + (3 + WB_PW) / sin(UWXang)])internalSq([WB_CaT, WB_PW], WB_mir);
translate([WB_XP - WB_CaT, -WB_PW + (fs.z - CarBT - FR_CuT + WB_RSD - 11) / sin(UWXang)])internalSq([WB_CaT, WB_PW], WB_mir);
translate([carbUWP.x - 8, UW_FWO + 3.5])circle(d = 3.2);
//fs.z-CarBT-FR_CuT+WB_RSD
//translate(UWing_FWMH)circle(d=motP_mntD);//bottom front mouting hole (coulpes the wing to the base)
//translate(UWing_RWMH)circle(d=motP_mntD);//bottom rear mouting hole (coulpes the wing to the base)
//translate([UWing_TMHX,UWing_TMHY])circle(d=motP_mntD);//teather mounting hole
}
}
}
{
function UWing_MMP(index1, index2)=
let(UWing_MMP = [//motor mount points
//[UWing_MFBMX-6, UWing_MFBMY, 0],
[UWing_MFBMX + UWing_XMHO, UWing_MFBMY, 1],
UWingRP[1] + [-carbUWTO.x, 0, 0],
UWingRP[2],
[UWing_MRBMX, UWing_MRBMY, 0]
])
range(UWing_MMP, index1, index2);
}
}
{
function UWing_BP(index1, index2)=//brace points
let(UWing_BP = [//brace points
[UWing_BFT.x, UWing_BFT.y, 3],
[UWing_BFT.x - 7, UWing_BFT.y, 3],
[(UWing_BFT.x + UWing_BRT.x + 6) / 2, UWing_BFT.y - 10, 6],
[UWing_BRT.x + 10, UWing_BRT.y, 3],
[UWing_BRT.x, UWing_BRT.y, 3],
[UWingRP[3].x, UWingRP[3].y, 5],
[UWingRP[3].x, (carbUWP[2] - 2) * cos(UWXang), 4],
[UWingRP[0].x, (carbUWP[2] - 2) * cos(UWXang), 4],
[UWingRP[0].x, UWingRP[0].y, 5]
//[UWing_BRB.x, UWing_BRB.y, 0],
//[UWing_BFB.x, UWing_BFB.y, 0],
//[carbUWP[0]-carbW[0], 0, 3],
//[carbUWP[0], 0, 3],
])
range(UWing_BP, index1, index2);
}
{module motMntU(Hrot = 30, partLayout = 0)
translate([100 * partLayout, 100 * partLayout, ((-mot_s[2] / 2 + motP_MT) * partLayout)])rotY((180 - theta) * partLayout){
difference(){
union(){
UpperWingSpace()tranZ(-carbW[2] * 2 / 2 - motP_MT2)linear_extrude(motP_MT2)offset(motP_MT2)polygon(polyRound(UWing_MMP(), gfn, 0));//wing tip mounting hole polygon extrude
for (i = [0:3])hullIndiv(){ //using hull here to effectively fill in the gap between where this mount attaches to the wing and where the motor mounts to this part
UpperWingSpace()tranZ(-carbW[2] * 2 / 2 - motP_MT2)linear_extrude(carbW[2] + motP_MT2 * 2)offset(motP_MT2)polygon(polyRound(UWing_MMPS(), gfn, 0)); //wing tip mount
if (i < 2) motSpace(1)rotate([0, theta, 0])rotate([0, 0, 25 + i * 40])translate([0, motP_dia / 2 + motP_MG[1], 0]) cylinder(h = motP_MT * 3, d = motP_MG[0] + 3); //extent motor mount to help protect motor
motSpace(1)rotate([0, theta, 0])rotate([0, 0, Hrot])linear_extrude(motP_MT)offset(4)motMntHoles("2d", i);// offset and linearly extruded the 2d motor mount holes to form the top of motor mounts
//motSpace(1)rotate([0,theta,0]) cylinder(h=motP_MT,d=motP_dia);
//for(i=[25,65])motSpace(1)rotate([0,theta,0])rotate([0,0,i])translate([0,motP_dia/2+motP_MG[1],0]) cylinder(h=motP_MT,d=motP_MG[0]); //extent motor mount to help protect motor
//motSpace(1)rotate([0,theta,0])rotate([0,0,65])translate([0,motP_dia/2+motP_MG[1],0]) cylinder(h=motP_MT,d=motP_MG[0]+2); //extent motor mount to help protect motor
//for(i=[0:3])motSpace(1)rotate([0,theta,0])rotate([0,0,Hrot])linear_extrude(motP_MT)offset(4)motMntHoles("2d",i);// offset and linearly extruded the 2d motor mount holes to form the top of motor mounts
//motSpace(1)rotate([0,theta,0])rotate([0,0,Hrot])linear_extrude(motP_MT)offset(4)motMntHoles("2d",1);// offset and linearly extruded the 2d motor mount holes to form the top of motor mounts
//motSpace(1)rotate([0,theta,0])rotate([0,0,Hrot])linear_extrude(motP_MT)offset(4)motMntHoles("2d",2);// offset and linearly extruded the 2d motor mount holes to form the top of motor mounts
//motSpace(1)rotate([0,theta,0])rotate([0,0,Hrot])linear_extrude(motP_MT)offset(4)motMntHoles("2d",3);// offset and linearly extruded the 2d motor mount holes to form the top of motor mounts
}
}
union(){
//slightly better than below but hard to print motSpace(1)rotate([0,theta,0]) translate([0,0,motP_MT])cylinder(h=motP_MT*2,d1=motP_dia*1.2,d2=motP_dia*1.2+motP_MT*10);
motSpace(1)rotate([0, theta, 0]) translate([0, 0, motP_MT + 0.01])cylinder(h = motP_MT * 5, d = motP_dia * 5);//large disk used to ensure the part is printable
motSpace(1)rotate([0, theta, 0])translate([0, 0, motP_MT - motP_CHD])cylinder(h = motP_CHD * 3, d = motP_CHdia); // centre hole
motSpace(1)rotate([0, theta, 0])rotate([0, 0, Hrot])motMntHoles("3d"); // motor mount holes (3d)
wingU3(100, 0.35); //Subtract the wing from this part, expanded a small amount for tolerance
UpperWingMMHSpace(){
tranZ(-25)cylinder(d = motP_mntD, h = 50);// mounting hole for this part
tranZ(-motP_MT2 - 10)cylinder(d = motP_HD, h = 10, $fn = motP_HoS); // hex or square hole or nut capture
//tranZ(motP_MT2/2+motP_WMHCS)cylinder(d1=motP_mntD,d2=motP_mntD+15,h=15); // counter sunk hole NOT USED CURRENTLY
}
}
}
}
{
function UWing_MMPS(index1, index2)=
let(UWing_MMPS = [//motor mount points small
[UWing_MFBMSX - 5, UWing_MFBMSY, 0],
[UWing_MFBMSX, UWing_MFBMSY, 0],
UWingRP[1],
UWingRP[2],
[UWing_MRBMX, UWing_MRBMY, 0]
])
range(UWing_MMPS, index1, index2);
}
}
{
module motMntL(Hrot = 30, partLayout = 0)
translate([-100 * partLayout, 100 * partLayout, ((mot_s[2] / 2 + motP_MT) * partLayout)])rotY((180 - theta) * partLayout){
difference(){
union(){
tranZ(carbLWP[2] - carbW[2] / 2 - motP_MT2)linear_extrude(motP_MT2)offset(motP_MT2)polygon(polyRound(LWing_MMP(), gfn, 0));//wing tip mounting hole polygon extrude
for (i = [0:3])hullIndiv(){//using hull here to effectively fill in the gap between where this mount attaches to the wing and where the motor mounts to this part
tranZ(carbLWP[2] - carbW[2] / 2 - motP_MT2)linear_extrude(carbW[2] + motP_MT2 * 2)offset(motP_MT2)polygon(polyRound(LWing_MMPS(), gfn, 0)); //wing tip mount
//motSpace(0)rotate([0,theta,0]) cylinder(h=motP_MT,d=motP_dia);
motSpace(0)rotate([0, theta, 0])rotate([0, 0, Hrot])linear_extrude(motP_MT)offset(4)motMntHoles("2d", i);// offset and linearly extruded the 2d motor mount holes to form the top of motor mounts
if (i < 2) motSpace(0)rotate([0, theta, 0])rotate([0, 0, 25 + i * 40])translate([motP_dia / 2 + motP_MG[1], 0, 0]) cylinder(h = motP_MT, d = motP_MG[0] + 3); //extent motor mount to help protect motor
}
}
union(){
motSpace(0)rotate([0, theta, 0]) tranZ(motP_MT)cylinder(h = motP_MT * 5, d = motP_dia * 5);//large disk used to ensure the part is printable
motSpace(0)rotate([0, theta, 0])translate([0, 0, motP_MT - motP_CHD])cylinder(h = motP_CHD * 3, d = motP_CHdia);// centre hole
motSpace(0)rotate([0, theta, 0])rotate([0, 0, Hrot])motMntHoles("3d"); // motor mount holes (3d)
fuse3(100, 0.35); //Subtract the wing/base from this part, expanded a small amount for tolerance
translate([LWing_MMH[0], LWing_MMH[1], carbLWP[2] - carbW[2] / 2]){
tranZ(-25)cylinder(d = motP_mntD, h = 50);// mounting hole for this part
tranZ(-motP_MT2 - 10)cylinder(d = motP_HD, h = 10, $fn = motP_HoS);// hex or square hole or nut capture
//tranZ(motP_MT2+motP_WMHCS)cylinder(d1=motP_mntD,d2=motP_mntD+15,h=15);// counter sunk hole NOT USED CURRENTLY
}
}
}
}
{
function LWing_MMPS(index1, index2)=
let(LWing_MMPS = [//motor mount points small
[LWing_MRBMSX, LWing_MRBMSY, 0],
LWingRP(1),
LWingRP(2),
[LWing_MFBMX, LWing_MFBMY, 0]
])
range(LWing_MMPS, index1, index2);
}
}
module motMntHoles(mode = 0, index){
coneht = tan(motP_CA) * (motP_CD - motP_mntD) / 2;
a = [0, 180, 90, 270];
for (i = [0:3]){
newi = mode == "2d" ? index : i;
newj = i < 2 ? 0 : 2;
rotate([0, 0, a[newi]])/*translate([0,motP_mntS[newj+j],-0.1])*/{
if (mode == 0 || mode == "3d") {//hull()ing mush be done individually otherwise it all of the cylinders below will be hull()ed together into a mess :(
hull()for(h = [0, 1])translate([0, motP_mntS[newj + h], -0.1])cylinder(h = motP_MT * 5 + 0.2, d = motP_mntD); //hulling two cylinders to form a elongated hole
hull()for(h = [0, 1])translate([0, motP_mntS[newj + h], -coneht])cylinder(h = coneht, d1 = motP_CD, d2 = motP_mntD);//done again with a cone for the counter sunch section
hull()for(h = [0, 1])translate([0, motP_mntS[newj + h], -coneht - 100 + 0.05])cylinder(h = 100, d = motP_CD);// and again for the bolt head
//}
} else {
hull()for(h = [0, 1])tranY(motP_mntS[newj + h])circle(d = motP_mntD); //hulling two cylinders to form a elongated oval thing
}
}
}
}
{module fuse3(shellT = 6.5, tol_expand = 0, partLayout = 0){
tranZ(carbLWP[2] - carbW[2] / 2 - (carbLWP[2] - carbW[2] / 2) * partLayout){
fs_postP = [
[fusehozoff + l / 2 - fs_minT + fs_mir, w / 2 + FR_tol / 2, fs_mir],
[fusehozoff + l / 2 - fs_minT, w / 2 - CarRT / 2 - FR_tol / 4, 0],
[fusehozoff + l / 2 - fs_minT + fs_mir, w / 2 - CarRT - FR_tol / 2, fs_mir],
[fusehozoff + l / 2 - fs_minT - FR_CuT - fs_mir, w / 2 - CarRT - FR_tol / 2, fs_mir],
[fusehozoff + l / 2 - fs_minT - FR_CuT, w / 2 - CarRT / 2 - FR_tol / 4, 0],
[fusehozoff + l / 2 - fs_minT - FR_CuT - fs_mir, w / 2 + FR_tol / 2, fs_mir]
];
WB_ppb = [//wing brace post points for the base
[WB_XP, fs.y / 2 - WB_BNO - (fs_bd + fs_bhd) / 2, 0],
[WB_XP - WB_CaT, fs.y / 2 - WB_BNO - (fs_bd + fs_bhd) / 2, 0],
[WB_XP - WB_CaT, fs.y / 2 - WB_BNO - (fs_bd + fs_bhd) / 2 + WB_PP(1).y, 0],
[WB_XP, fs.y / 2 - WB_BNO - (fs_bd + fs_bhd) / 2 + WB_PP(1).y, 0],
];
tranZ(-tol_expand / 2)linear_extrude(CarBT + tol_expand){
difference(){
offset(tol_expand)shell2d(-shellT, 0, 1.2){
difference(){
union(){
polygon(polyRound(mirrorPoints(fs_basePoints(), atten = [1, 1]), gfn, 0));
}
union(){
for (i = [0:1])mirror([0, i, 0]){
//polygon(polyRound(fs_postP,gfn,0));
translate([fusehozoff + l / 2 - fs_minT - FR_CuT / 2, (w - CarRT) / 2])internalSq([FR_CuT + FR_tol, CarRT + FR_tol], fs_mir, 1);
translate([fusehozoff - l / 2, (w - FR[0]) / 2])internalSq([FR_SD[0] * 2 + FR_tol, FR[0] + FR_tol], fs_mir, 1);
//polygon(polyRound(WB_ppb,gfn,0));
translate([WB_XP - WB_CaT, fs.y / 2 - WB_BNO - (fs_bd + fs_bhd) / 2 + WB_PP(1).y])internalSq([WB_CaT, abs(WB_PP(1).y)], WB_mir);
if (shellT < 99) translate(LWing_MMH)circle(d = motP_mntD);//don't include if shell i very large as it is being used to differnce from the motor mount and it causes trouble included
//translate([fusehozoff+l/2-fs_minT-FR_CuT-FR_BHD/2,w/2-CarRT/2])circle(d=3.2);
translate([l / 2 + fusehozoff - fs_minT - FR_CuT - fs_bhd / 2/*+FR_BD/2*/, w / 2 - CarRT / 2])circle(d = 3.2);
translate([WB_XP - WB_CaT / 2, fs.y / 2 - WB_BNO - fs_bd / 2])circle(d = 3.2);
translate([carbUWP.x - 8, fs.y / 2 - 4 + 1.6])circle(d = 3.2);
for (i = [-79, -79/*20*/])translate([i, 0, 0])stackMountHoles();
}
CamMSpace(0)tranX(camMT + camBMD / 2)circle(d = camBMD);
}
}
scale([1.2, 1, 1])translate([-17, 0, 0])gridpattern(4.5, sqrt(sq(fs[1] - 12) / 4), 11, 3);
}
}
}
}
}
{
function LWingRP(index1, index2)=
let(l = fs[0],
w = fs[1],
LWingRP = [//Lower ring radii points. First point starts at the rear base of the wing, then moves out to the tip of the wing
[carbLWP[0] - carbW[0], w / 2, fs_wbr[1]],
[mot_cords[0][0] + carbLWTO[0] - carbW[1], mot_cords[0][1] + carbLWTO[1], fs_wtr],
[mot_cords[0][0] + carbLWTO[0], mot_cords[0][1] + carbLWTO[1], fs_wtr],
[carbLWP[0], w / 2, fs_wbr[0]],
])
range(LWingRP, index1, index2);
}
{
function fs_basePoints(index1, index2)=
let(l = fs[0],
w = fs[1],
fs_basePoints = concat([
[-l / 2 + fusehozoff + 7, 0, 25],
[-l / 2 + fusehozoff, w / 2 - FR[0] - FR_tol / 2 - fs_minT, 15]
], fs_RCRP(),
//moveRadiiPoints(fs_pp(),[carbUWP[0]-carbW[0],fs[1]/2]),
//moveRadiiPoints(fs_BP(),[carbUWP[0]-carbW[0]/2,fs[1]/2]),
//moveRadiiPoints(fs_pp(),[carbUWP[0]-fs_minT-fs_pt*2,fs[1]/2]),
LWingRP(), [
[l / 2 + fusehozoff - fs_minT - CarRT - fs_mir * 2, w / 2 + fs_minT, fs_sr],
[l / 2 + fusehozoff, w / 2 + fs_minT, fs_sr],
[l / 2 + fusehozoff, w / 2 - fs_minT - CarRT * .75, fs_sr * 3],
[l / 2 + fusehozoff - 50, 0, 10]
]))
range(fs_basePoints, index1, index2);
}
{
function LWing_MMP(index1, index2)=//motor mount points with wrapper function
let(LWing_MMP = [//motor mount points
[LWing_MFBMX, LWing_MFBMY, 0],
LWingRP(2),
LWingRP(1),
[LWing_MRBMX, LWing_MRBMY, 0],
[LWing_MRBMX + 5, LWing_MRBMY, 0]
])
range(LWing_MMP, index1, index2);
}
{
function fs_RCRP(index1, index2)=//rear clip radii points with wrapper function
let(l = fs[0],
w = fs[1],
fs_RCRP = [//rear clip radii points
[-l / 2 + fusehozoff, w / 2 - FR[0] - FR_tol / 2, 0],
[-l / 2 + fusehozoff + FR_SD[0], w / 2 - FR[0] - FR_tol / 2, fs_mir],
[-l / 2 + fusehozoff + FR_SD[0], w / 2 + FR_tol / 2, fs_mir],
[-l / 2 + fusehozoff, w / 2 + FR_tol / 2, 0],
[-l / 2 + fusehozoff + fs_minT, w / 2 + fs_minT, 10],
[-l / 2 + fusehozoff + FR_SD[0] + fs_minT * 0.5, w / 2 + fs_minT, 10],
[-l / 2 + fusehozoff + FR_SD[0] + fs_minT * 3, w / 2, 25]
])
range(fs_RCRP, index1, index2);
}
{
function fs_pp(index1, index2)=//post points with wrapper function
let(fs_pp = [//post points
[fs_minT, 0, fs_mir],
[fs_minT, fs_ph, 0],
[fs_minT + fs_pt, fs_ph, 0],
[fs_minT + fs_pt, 0, fs_mir],
])
range(fs_pp, index1, index2);
}
{
function fs_BP(index1, index2)=//bolt radii points with wrapper function
let(fs_BP = [//bolt points
[-fs_bd / 2, 0, 0],
[-fs_bd / 2, -fs_bmt, 0],
[-fs_bhd / 2, -fs_bmt, fs_mir],
[-fs_bhd / 2, -fs_bmt - fs_bhh, fs_mir],
[0, -fs_bmt - fs_bhh - 1.5, fs_mir],
[fs_bhd / 2, -fs_bmt - fs_bhh, fs_mir],
[fs_bhd / 2, -fs_bmt, fs_mir],
[fs_bd / 2, -fs_bmt, 0],
[fs_bd / 2, 0, 0],
])
range(fs_BP, index1, index2);
}
}
{
module fuseRailsRev2(expand = 0, partLayout = 0)
/*tranZ(-carbLWP[2])rotX(partLayout*-90)*/{
neg = partLayout == 1 ? 0 : 1;
l = fs.x;//fuselage length. Temp varible for use in polyRound() arrays
w = fs.y;//fuselage width. Temp varible for use in polyRound() arrays
h = fs.z;//fuselage height. Temp varible for use in polyRound() arrays
offs = fusehozoff;//fuselage offset. Temp varible for use in polyRound() arrays
WBBp = [//wing brace brace points
[WB_XP - WB_CaT - 10, fs.z - FR_CuT, 0],
[WB_XP - WB_CaT - 5, fs.z - FR_CuT, 8],
[WB_XP - WB_CaT, fs.z - FR_CuT - 2, 0],
[WB_XP - WB_CaT, fs.z - FR_CuT, FR_MIR],
[WB_XP, fs.z - FR_CuT, FR_MIR],
[WB_XP, fs.z - FR_CuT - 2.5, 0],
[WB_XP + 5, fs.z - FR_CuT, 8],
[WB_XP + 10, fs.z - FR_CuT, 0],
[WB_XP - WB_CaT / 2, fs.z - FR_CuT + 1, 0],
];
railPoints = concat(
rearRailClip(),
railTE(),
frontRailClip(),
revList(RailCustomiser(concat([rearRailClip(7)], railTE(), [frontRailClip(0)]), o1 = FR_CuT, minR = 2, mode = 1))
);
translate([0, w / 2 + partLayout * 100, (carbLWP[2] - carbW[2] / 2) * neg])rotX(90 * neg)tranZ(expand)linear_extrude(CarRT + expand * 2)offset(expand)difference(){
union(){
polygon(polyRound(railPoints, gfn, 0));
polygon(polyRound(WBBp, gfn));
//translate(FR_RHP)circle(d=FR_BD+FR_CuT);
translate([l / 2 + offs + FR_OH + FR_CuT * tan(atan(h / 2 / FR_OH) / 2 + 90), h - FR_CuT])circle(d = FR_BD + FR_CuT);
}
union(){
//translate(FR_RHP)circle(d=FR_BD);
translate([l / 2 + offs + FR_OH + FR_CuT * tan(atan(h / 2 / FR_OH) / 2 + 90), h - FR_CuT])circle(d = FR_BD);
translate([WB_XP - WB_CaT / 2, fs.z - FR_CuT * 1.5])internalSq([WB_CaT + FR_tol, FR_CuT + FR_tol], FR_MIR, 1);
}
}
}
{
function rearRailClip(index1, index2)=
let(l = fs[0],//fuselage length. Temp varible for use in polyRound() arrays
w = fs[1],//fuselage width. Temp varible for use in polyRound() arrays
h = fs[2],//fuselage height. Temp varible for use in polyRound() arrays
offs = fusehozoff,//fuselage offset. Temp varible for use in polyRound() arrays
rearRailClip = [
[-l / 2 + offs + FR_SD[0] + FR_CuT * tan(FR_RA), CarBT + FR_CuT, 15],
[-l / 2 + offs + FR_SD[0] + FR_SD[1], CarBT + FR_tol, 0],
[-l / 2 + offs + FR_SD[0], CarBT + FR_tol, FR_MIR],
[-l / 2 + offs + FR_SD[0], 0, FR_MIR],
[-l / 2 + offs + FR_SD[0] + FR_SD[1], 0, 0],
[-l / 2 + offs + FR_SD[0], -FR_MT, FR_SR],
[-l / 2 + offs + FR_SD[0] - FR_CuT, -FR_MT, FR_SR],
[-l / 2 + offs + FR_SD[0] - FR_CuT, CarBT + FR_CuT, 10],
])
range(rearRailClip, index1, index2);
}
{
function frontRailClip(index1, index2)=
let(l = fs[0],//fuselage length. Temp varible for use in polyRound() arrays
w = fs[1],//fuselage width. Temp varible for use in polyRound() arrays
h = fs[2],//fuselage height. Temp varible for use in polyRound() arrays
offs = fusehozoff,//fuselage offset. Temp varible for use in polyRound() arrays
frontRailClip = concat([
[l / 2 + offs - fs_minT, CarBT + FR_MT + FR_BHH, 0],
[l / 2 + offs - fs_minT, 0, 1],
[l / 2 + offs - fs_minT - FR_CuT, 0, 1],
[l / 2 + offs - fs_minT - FR_CuT, CarBT, FR_MIR],
[l / 2 + offs - fs_minT - FR_CuT - (FR_BHD - FR_BD) / 2, CarBT, 0]],
moveRadiiPoints(fs_BP(), [l / 2 + offs - FR_CuT - fs_minT - fs_bhd / 2.2, CarBT], 180),
[[l / 2 + offs - fs_minT * 1.4 - FR_CuT - fs_bhd - FR_MT, CarBT, 1],
[l / 2 + offs - fs_minT * 1.8 - FR_CuT - FR_BHD - FR_MT, CarBT + FR_MT + FR_BHH, 10]
]))
range(frontRailClip, index1, index2);
}
{
function railTE(index1, index2)=
let(l = fs[0],//fuselage length. Temp varible for use in polyRound() arrays
w = fs[1],//fuselage width. Temp varible for use in polyRound() arrays
h = fs[2],//fuselage height. Temp varible for use in polyRound() arrays
offs = fusehozoff,//fuselage offset. Temp varible for use in polyRound() arrays
railTE = [//rail top edge
[-l / 2 + offs + FR_SD[0] - FR_CuT + h * tan(FR_RA), h, FR_R1],
[l / 2 + offs + FR_OH, h, FR_R2],
[l / 2 + offs - fs_minT, h / 2, FR_R3]
])
range(railTE, index1, index2);
}
}
module prop(NP = 3, propD = 25.4 * 5){
thick = 1;
width = 30;
propR = propD / 2;
startA = 40;
finA = 10;
IP = [
[5, 0, 0],
[10, propR / 5, 1],
[3, propR / 3 + 5, 50],
[0, propR - 10, 100],
[3, propR, 1],
[2, propR, 1],
[-5, propR - 5, 20],
[-15, propR * 2 / 3, 50],
[-5, 0, 0],
];
difference(){
union(){
translate([0, 0, 5])for(i = [0:NP - 1])rotate([0, 0, 360 * i / NP])intersection(){
rotate([-90, 0, 0])rotate([0, 0, startA - 90])linear_extrude(height = propR, twist = startA - finA, $fa = 0.5, $fn = 400)square([thick, width], true);
translate([0, 0, -20])linear_extrude(40)polygon(polyRound(IP));
}
cylinder(h = 10, d = 12);
}
union(){
translate([0, 0, -0.1])cylinder(h = 10 + 0.2, d = 5);
}
}
}
module motor(motD=28,motH=18){
motR=motD/2;
shaftR=2.5;
rp=[
[-motR,0,0],
[-motR,motH*0.75,2],
[-motR*0.75,motH,2],
[-shaftR,motH,0.5],
[-shaftR,motH+8,0.3],
[0,motH+8,0.3],
];
rp2=RailCustomiser(rp,o1=0,o2=1,mode=0);
cylinder(r=motR,h=2);
cylinder(r=motR*0.7,h=motH*0.9);
difference(){
union(){
rotate_extrude()polygon(polyRound(rp2,gfn));
cylinder(r=motR,h=2);
}
for(i=[0:45:360])rotate([0,0,i])translate([0,0,motH*0.7])cube([motD*2,motD*0.25,motH*0.3],true);
cylinder(r=motR*1.1,h=2.5);
}
}
module Print2Console(){//Print things to console
ZposStr = str("fuselage Z position\t= ", carbLWP[2] + fs[2] / 2, "mm (aim for > -10mm as a guide)");
/*
greater than -10mm is a guide because if fuselarge is too far below 0 than the lower
motors won't have as much levelage on the pitch axis as the upper motors, might start
making PID tuning problematic!?
*/
diagonalMotDis = sqrt(mot_s[0] * mot_s[0] + (mot_s[1] + mot_s[3]) / 2 * (mot_s[1] + mot_s[3]) / 2);
diagonalMotDisStr = str("diagonal motor distance\t=", diagonalMotDis, "mm");
/*
mmix [motor number] [throttle] [roll] [pitch] [yaw]
mmix 1 1.000 -1.000 1.000 -1.000 (Rear Right motor)
mmix 2 1.000 -1.000 -1.000 1.000 (Front Right motor)
mmix 3 1.000 1.000 1.000 1.000 (Rear Left motor)
mmix 4 1.000 1.000 -1.000 -1.000 (Front Left motor)
*/
uroll = mot_s[3] / dem;//upper roll
lroll = mot_s[1] / dem;//lower roll
pitch = mot_s[0] / dem;// pitch
mmix0 = str("mmix 0 1.000\t", -uroll, "\t", pitch, "\t-1.000");
mmix1 = str("mmix 1 1.000\t", -lroll, "\t", -pitch, "\t1.000");
mmix2 = str("mmix 2 1.000\t", uroll, "\t", pitch, "\t1.000");
mmix3 = str("mmix 3 1.000\t", lroll, "\t", -pitch, "\t-1.000");
echo(str("\r",
ZposStr, "\r",
diagonalMotDisStr, "\r\r",
"mmix values for each motor (currently this does not take into account weight distribution)\r",
mmix0, "\r",
mmix1, "\r",
mmix2, "\r",
mmix3, "\r"
));
}
// handly modules, not of specific parts
module axis(size = 50){
color("blue"){
cylinder(h = size, d = 0.5);
translate([0, 0, size])rotate([90, 0, 0])text("Z");
}
color("green"){
rotate([-90, 0, 0])cylinder(h = size, d = 0.5);
translate([0, size, 0])text("Y");
}
color("red"){
rotate([0, 90, 0])cylinder(h = size, d = 0.5);
translate([size, 0, 0])rotate([0, 0, -90])text("X");
}
}
module gridpattern(memberW = 4, sqW = 12, iter = 5, r = 3){
round2d(0, r)rotate([0, 0, 45])translate([-(iter * (sqW + memberW) + memberW) / 2, -(iter * (sqW + memberW) + memberW) / 2])difference(){
square([(iter) * (sqW + memberW) + memberW, (iter) * (sqW + memberW) + memberW]);
for (i = [0:iter - 1], j = [0:iter - 1]){
translate([i * (sqW + memberW) + memberW, j * (sqW + memberW) + memberW])square([sqW, sqW]);
}
}
}
module hullIndiv(){
for (i = [1:$children - 1])hull(){
children(0);
children(i);
}
}
//COORDINATE SPACE MODULES
module UpperWingMMHSpace(){
UpperWingSpace()translate(UWing_MMH)children();
}
module UpperWingSpace(disable = 0){
if (disable == 0) {
translate([0, carbUWP[1], carbUWP[2]])rotate([UWXang, 0, 0])children();
} else { children(); }
}
module motSpace(lowOrUp = 0){
if (lowOrUp > 1) {
echo("motSpace() index out of range");
} else {
translate([mot_cords[lowOrUp][0], mot_cords[lowOrUp][1], mot_cords[lowOrUp][2]])children();
}
}
module braceMountSpace(holeIndex = 0){
if (holeIndex == 0) {//front fuselage base mount
translate([carbUWP[0] - UWB_MT2 / 2 - UWB_Hdia, fs[1] / 2 - UWB_MT2 / 2 - UWB_Hdia / 2, carbLWP[2] + FR[0] / 2]){children(); }
} else if (holeIndex == 1) {//rear fuselage base mount
translate([carbUWP[0] - carbW[0] + UWB_MT2 / 2 + UWB_Hdia / 2, fs[1] / 2 - UWB_MT2 / 2 - UWB_Hdia / 2, carbLWP[2] + FR[0] / 2]){children(); }
} else if (holeIndex == 2) {//front rail mount
translate([carbUWP[0], fs[1] / 2, carbLWP[2]])rotate([0, UWFYang - 90, 0])translate([0, 0, (fs[2] - FR[0] / 2 - RCutT / 2) / cos(90 - UWFYang)])rotate([0, -UWFYang + 90, 0])rotate([-90, 0, 0]){children(); }
} else if (holeIndex == 3) {//rear rail mount
translate([carbUWP[0] - carbW[0], fs[1] / 2, carbLWP[2]])rotate([0, UWRYang - 90, 0])translate([0, 0, (fs[2] - FR[0] / 2 - RCutT / 2) / cos(90 - UWRYang)])rotate([0, -UWRYang + 90, 0])rotate([-90, 0, 0]){children(); }
} else if (holeIndex == 4) {//front wing base mount
translate(carbUWP - [-carbW[3] / 2 + UWB_MO[0] * 1.3, 0, 0])rotate([-90 + UWXang, 0, 0])rotate([0, -90 + UWFYang, 0])translate([0, -carbW[2] / 2, (UWB_MT2 + UWB_Hdia + UWB_MO[1]) / (2 * cos(90 - UWFYang) * cos(90 - UWXang))])rotate([90, 0, 0]){children(); }
} else if (holeIndex == 5) {//rear wing base mount
translate(carbUWP - [carbW[0] + carbW[3] * 0 - UWB_MO[0], 0, 0])rotate([-90 + UWXang, 0, 0])rotate([0, -90 + UWRYang, 0])translate([0, -carbW[2] / 2, (UWB_MT2 + UWB_Hdia + UWB_MO[1]) / (2 * cos(90 - UWRYang) * cos(90 - UWXang))])rotate([90, 0, 0]){children(); }
} else if (holeIndex == 6) {//top centre wing mount
//translate(carbUWP-[carbW[0]/2+carbW[3]*-0+0.1-0.5,0,0])rotate([-90+UWXang,0,0])rotate([0,-90+(UWRYang+UWRYang)/2,0])translate([0,-carbW[2]/2,(fs[2]-(UWB_MT2*2+UWB_Hdia*2+RCutT)/2-UWB_MO[1])/(cos(90-UWRYang)*cos(90-UWXang))])rotate([0,90-(UWRYang+UWRYang)/2,0])rotate([90,0,0]){children();}
translate(carbUWP - [carbW[0] / 2 + carbW[3] * -0 + 0.1 - 0.5, 0, 0])rotate([-90 + UWXang, 0, 0])rotate([0, -90 + (UWRYang + UWRYang) / 2, 0])translate([0, -carbW[2] / 2, (-UWB_MO[1] + fs[2] - FR[0] - RCutT / 2) / (cos(90 - UWRYang) * cos(90 - UWXang))])rotate([0, 90 - (UWRYang + UWRYang) / 2, 0])rotate([90, 0, 0]){children(); }
//(fs[2]-FR[0]/2-RCutT/2-UWB_Hdia)
} else { echo("braceMountSpace() index out of range"); }
}
module CamMSpace(index = 0){
if (index == 0) {//rear hole
translate([camP.x - camRR, 0, carbLWP.z + carbW[2] / 2])children();
}
}
module tranX(offset){
translate([offset, 0, 0])children();
}
module tranY(offset){
translate([0, offset, 0])children();
}
module tranZ(offset){
translate([0, 0, offset])children();
}
module rotX(rot){
rotate([rot, 0, 0])children();
}
module rotY(rot){
rotate([0, rot, 0])children();
}
module rotZ(rot){
rotate([0, 0, rot])children();
}
//FUNCTIONS - Put inside braces {} so that they collapse :)
/*{function mirrorPoints(a)= //mirrors a list of points about Y, ignoring the first and last points and returning them in reverse order for use with polygon or polyRound
let(temp=[for(i=[2:len(a)-1]) [a[len(a)-i][0],a[len(a)-i][1]*-1,a[len(a)-i][2]]])
concat(a,temp);}*/
{
function interpX(p0, p1, theY)=//outputs linearly interpolated X value for a given Y.
p0.x + (theY - p0.y) * (p1.x - p0.x) / (p1.y - p0.y);
}
{
function range(p, index1, index2)=
index1 > len(p) - 1 || index2 > len(p) - 1 ?//error check
"outside range" :
index1 > index2 ?
"index1 less than index2" :
index1 == undef ?
p : //index1 is not defined,return all
index2 == undef ?
p[index1] ://index2 is not define, return element at index1
[for(i = [index1:index2]) p[i]];//return range
}
// Old modules, will probably delete sooner or later
{
module fuseRev2(shellT = 6.5, tol_expand = 0, partLayout = 0){
tranZ(carbLWP[2] - carbW[2] / 2 - (carbLWP[2] - carbW[2] / 2) * partLayout){
fs_postP = [
[fusehozoff + l / 2 - fs_minT + fs_mir, w / 2 + FR_tol / 2, fs_mir],
[fusehozoff + l / 2 - fs_minT, w / 2 - CarRT / 2 - FR_tol / 4, 0],
[fusehozoff + l / 2 - fs_minT + fs_mir, w / 2 - CarRT - FR_tol / 2, fs_mir],
[fusehozoff + l / 2 - fs_minT - FR_CuT - fs_mir, w / 2 - CarRT - FR_tol / 2, fs_mir],
[fusehozoff + l / 2 - fs_minT - FR_CuT, w / 2 - CarRT / 2 - FR_tol / 4, 0],
[fusehozoff + l / 2 - fs_minT - FR_CuT - fs_mir, w / 2 + FR_tol / 2, fs_mir]
];
tranZ(-tol_expand / 2)linear_extrude(CarBT + tol_expand){
difference(){
offset(tol_expand)shell2d(-shellT, 0, 1.2){
difference(){
union(){
polygon(polyRound(mirrorPoints(fs_basePoints(), atten = [1, 1]), gfn, 0));
}
union(){
for (i = [0:1])mirror([0, i, 0]){
polygon(polyRound(fs_postP, gfn, 0));
if (shellT < 99) translate(LWing_MMH)circle(d = motP_mntD);//don't include if shell i very large as it is being used to differnce from the motor mount and it causes trouble included
//translate([fusehozoff+l/2-fs_minT-FR_CuT-FR_BHD/2,w/2-CarRT/2])circle(d=3.2);
translate([l / 2 + fusehozoff - fs_minT - FR_CuT - fs_bhd / 2/*+FR_BD/2*/, w / 2 - CarRT / 2])circle(d = 3.2);
for (i = [-76, -76/*20*/])translate([i, 0, 0])stackMountHoles();
}
CamMSpace(0)tranX(camMT + camBMD / 2)circle(d = camBMD);
}
}
scale([1.2, 1, 1])translate([-17, 0, 0])gridpattern(4.5, sqrt(sq(fs[1] - 12) / 4), 11, 3);
}
}
}
}
}
}
{
module UWingBrace2(printLayout = 0){//printed part that connects the upper wings to the base
w = fs[1];// temp base width varible for use in polygons
UWB2_MT1 = 2;
UWing_BEC = [0, carbUWP[2] + sin(90 - UWXang) * carbW[2] / 2, w / 2 + fs_ph + carbW[2] / 2 - cos(90 - UWXang) * carbW[2] / 2];//bottom edge coordinates
UWing_BEO = [0, -1 * sin(UWXang), -1 * cos(UWXang)];//bottom edge offset
UWing_BT = [0, UWing_BTO * sin(UWXang), UWing_BTO * cos(UWXang)];//brace tip
UWB_XEP = [// Upper Wing Brace X Extrude Points
[UWing_BEC.y + UWing_BT.y, UWing_BEC.z + UWing_BT.z - 3, 2],
[UWing_BEC.y + UWing_BT.y, UWing_BEC.z + UWing_BT.z, 0],
[UWing_BEC.y + UWing_BEO.y, UWing_BEC.z + UWing_BEO.z, 3],
[carbLWP[2] - CarBT / 2 - UWB2_MT1, w / 2 + fs_ph, 0.5],
[carbLWP[2] - CarBT / 2 - UWB2_MT1, w / 2, 0.5],
[carbLWP[2] + CarBT / 2, w / 2, 0],
[carbLWP[2] + CarBT / 2, w / 2 - FR_CaT, 0],
[carbLWP[2] + CarBT / 2 + 2, w / 2 - FR_CaT, 1.5],
];
UWB_ZEP = [// Upper Wing Brace Z Extrude Points
[carbUWP[0] + 5, w / 2 - FR_CaT, 0],
[carbUWP[0] + 5, w / 2 + 30, 0],
[carbUWP[0] + 5 - carbW[0] * 2, w / 2 + 30, 0],
[carbUWP[0] + 5 - carbW[0] * 2, w / 2 - FR_CaT, 0],
[fs_BPC - fs_bhd, w / 2 - FR_CaT, 8],
[fs_BPC, w / 2, 20],
[fs_BPC + fs_bhd, w / 2 - FR_CaT, 8],
];
translate([-130 * partLayout, 25 * partLayout, 0])rotX(printLayout * (getAngle(UWB_XEP[len(UWB_XEP) - 1], UWB_XEP[0]) + 90))difference(){ //rotate ready to be printed
intersection(){ //bulk of the brace is made from intertecting extruded polygons
translate([carbUWP[0] + 5, 0, 0])rotate([0, -90, 0])linear_extrude(carbW[0] * 2)polygon(polyRound(UWB_XEP, gfn, 0)); //X Extrued
tranZ(carbLWP[2] - 20)linear_extrude(40)polygon(polyRound(UWB_ZEP, gfn, 0)); // Z Extrude
UpperWingSpace()tranZ(-20)linear_extrude(40)polygon(polyRound(UWing_BP(), gfn, 0)); // perpendictular to wing extrude
}
union(){
fuseRev2(100, 0.2); // Subtract the frame base (with very large shell thickness and expanded a small amount for tolerance)
UpperWingSpace()tranZ(-25)translate(UWing_RWMH)cylinder(d = motP_mntD, h = 50); // Subtract rear wing mounting hole
UpperWingSpace()tranZ(-25)translate(UWing_FWMH)cylinder(d = motP_mntD, h = 50); // Subtract front wing mounting hole
translate([fs_BPC, 0, carbLWP[2]])rotate([-90, 0, 0])cylinder(d = motP_mntD, h = 50); // Subtracte hole for mounting to the base
}
}
}
}
/*{module wingUrev2(shellT=6.2,tol_expand=0,partLayout=0)//upper carbon fiber wing
{
tranY(180*partLayout)UpperWingSpace(partLayout)tranZ((carbW[2]+tol_expand)*partLayout/2-(carbW[2]+tol_expand)/2)linear_extrude(carbW[2]+tol_expand)offset(tol_expand)shell2d(-shellT,0,1)difference(){//difference the mounting holes from the wing polygon, shell the result, extrude it and translate into position.
polygon(polyRound(UWingRP,gfn,0));//rounded wing polygon
if(shellT<99){//don't include if shell is very large as it is being used to differnce from the motor mount and it causes trouble when included in the difference
translate(UWing_MMH)circle(d=motP_mntD);//motor mount hole at the top of the wing
translate(UWing_FWMH)circle(d=motP_mntD);//bottom front mouting hole (coulpes the wing to the base)
translate(UWing_RWMH)circle(d=motP_mntD);//bottom rear mouting hole (coulpes the wing to the base)
translate([UWing_TMHX,UWing_TMHY])circle(d=motP_mntD);//teather mounting hole
}
}
}
{function UWing_MMP(index1,index2)=
let(UWing_MMP=[//motor mount points
//[UWing_MFBMX-6, UWing_MFBMY, 0],
[UWing_MFBMX+UWing_XMHO, UWing_MFBMY, 1],
UWingRP[1]+[-carbUWTO.x,0,0],
UWingRP[2],
[UWing_MRBMX, UWing_MRBMY, 0]
])
range(UWing_MMP,index1,index2);
}
}*/
module teather(partLayout = 0){
r = 0.5;
/*p=[
[-FR_CuT*2,-FR_CuT/2+,1],
[0,-FR_CuT/2,r],
[FR_CuT*1.3+2,FR_CuT/2,1.5],
[2,FR_CuT/2,5]
];*/
p = [
[-FR_CuT * 2, 0, 1],
[0, 0, r],
[FR_CuT * 1.3 + 2, FR_CuT, 1.5],
[2, FR_CuT, 5]
];
TTSP = [ //teather tip subtract points
[-TeMT * 4, TeMT * 2, 0],
[-TeMT * 4, 0, 0],
[0, TeMT, 5],
[TeMT * 2, 0, 0],