CascadeStudio_3D_Manual

Форк
0
230 строк · 6.8 Кб
1
// Three armed lever
2

3
function Dxy(currentPoint,dx,dy)
4
{ 
5
    let newPoint = []; 
6
    newPoint[0]  = currentPoint[0] + dx;
7
    newPoint[1]  = currentPoint[1] + dy; 
8
    return newPoint
9
}
10

11
function Dx(currentPoint,dx)
12
{ 
13
    let newPoint = []; 
14
    newPoint[0]  = currentPoint[0] + dx;
15
    newPoint[1]  = currentPoint[1] ; 
16
    return newPoint
17
}
18

19
function Dy(currentPoint,dy)
20
{ 
21
    let newPoint = []; 
22
    newPoint[0]  = currentPoint[0];
23
    newPoint[1]  = currentPoint[1] + dy; 
24
    return newPoint
25
}
26

27
function Polar(currentPoint,distance,angleDegToX)
28
{ 
29
    let newPoint = []; 
30
    let angleRad = angleDegToX * Math.PI/180;
31
    newPoint[0]  = currentPoint[0] + (distance * Math.cos(angleRad));
32
    newPoint[1]  = currentPoint[1] + (distance * Math.sin(angleRad)); 
33
    return newPoint
34
}
35

36
function PolarX(currentPoint,xdistance,angleDegToX)
37
{ 
38
    let newPoint = []; 
39
    let angleRad = angleDegToX * Math.PI/180;
40
    newPoint[0]  = currentPoint[0] + xdistance;
41
    newPoint[1]  = currentPoint[1] + xdistance * Math.tan(angleRad); 
42
    return newPoint
43
}
44

45
function PolarY(currentPoint,ydistance,angleDegToX)
46
{ 
47
    let newPoint = []; 
48
    let angleRad = angleDegToX * Math.PI/180;
49
    newPoint[0]  = currentPoint[0] + ydistance/Math.tan(angleRad);
50
    newPoint[1]  = currentPoint[1] + ydistance; 
51
    return newPoint
52
}
53

54
function RadiusArc(currentPoint,endPoint,radius, clockwise)
55
{
56
    let midPoint = [];
57
    let dx = endPoint[0] - currentPoint[0];
58
    let dy = endPoint[1] - currentPoint[1];
59
    let dist = Math.sqrt(Math.pow(dx,2)+Math.pow(dy,2));
60
    let alpha = Math.asin(dy/dist);
61
    let beta  = Math.asin((dist/2)/radius);
62
    let sag = radius - (Math.cos(beta) * radius)
63
    if (dx<0){clockwise = !clockwise}
64
    if (clockwise == true)
65
    {
66
    midPoint[0] = currentPoint[0] + dx/2 - Math.sin(alpha)*sag;
67
    midPoint[1] = currentPoint[1] + dy/2 + Math.cos(alpha)*sag; 
68
    }
69
    else
70
    {
71
    midPoint[0] = currentPoint[0] + dx/2 + Math.sin(alpha)*sag;
72
    midPoint[1] = currentPoint[1] + dy/2 - Math.cos(alpha)*sag;
73
    }
74
    return midPoint
75
}
76

77

78
function SagArc(currentPoint,endPoint,sag,clockwise)
79
{
80
    let midPoint = [];
81
    let dx = endPoint[0] - currentPoint[0];
82
    let dy = endPoint[1] - currentPoint[1];
83
    let dist = Math.sqrt(Math.pow(dx,2)+Math.pow(dy,2));
84
    let alpha = Math.asin(dy/dist);
85
    if (dx<0){clockwise = !clockwise}
86
    if (clockwise == true)
87
    {
88
    midPoint[0] = currentPoint[0] + dx/2 - Math.sin(alpha)*sag;
89
    midPoint[1] = currentPoint[1] + dy/2 + Math.cos(alpha)*sag; 
90
    }
91
    else
92
    {
93
    midPoint[0] = currentPoint[0] + dx/2 + Math.sin(alpha)*sag;
94
    midPoint[1] = currentPoint[1] + dy/2 - Math.cos(alpha)*sag;
95
    }
96
    return midPoint
97
}
98

99
function MirrorX(currentPoint, yvalue)
100
    {
101
        let mirrorPoint = [];    
102
        mirrorPoint[0] = currentPoint[0];
103
        mirrorPoint[1] = yvalue - (currentPoint[1]-yvalue);
104
        return mirrorPoint
105
    }
106

107
function MirrorY(currentPoint, xvalue)
108
    {
109
        let mirrorPoint = [];    
110
        mirrorPoint[0] = xvalue - (currentPoint[0]-xvalue);
111
        mirrorPoint[1] = currentPoint[1];
112
        return mirrorPoint
113
    }
114

115
// testing function to check if sketching commands work correctly
116
// let q0 = [0,0]
117
// let q1= [50,0]
118
// let q1a = SagArc(q0,q1,5,false)
119
// let q2= [50,50]
120
// let q2a = SagArc(q1,q2,5,false)
121
// let q3= [0,50]
122
// let q3a= SagArc(q2,q3,5,false)
123
// let q4= [0,0]
124
// let q4a= SagArc(q3,q4,5,false)
125

126
// let qsketch=new Sketch(q0)
127
// .ArcTo(q1a,q1)
128
// .ArcTo(q2a,q2)
129
// .ArcTo(q3a,q3)
130
// .ArcTo(q4a,q4)
131
// .End().Face()
132

133

134

135
// Box(10,10,10,false) // can be used to determine position of the axes. 
136

137
// parameters that define the design intent
138
let d       = 45; // distance center to radius of arm
139
let r0      = 10; // radius top of arm
140
let adeg    = 13; // widening angle of arm
141
let arad    = adeg * Math.PI/180; 
142
let d1      = d + Math.sin(arad)*r0
143
let r1      = 13; // inner radius of center cylinder
144
let t1      = 5 ; // wall thickness of center cylinder  
145
let h1      = 37; // height of inner cylinder
146
let h2      = 10; // height at end of the arm
147
let gamma   = 25; // angle deg from tip of arm to cylinder
148
let r2      = 25; // radius of fillets between arms
149
let t3      = 7 ; // wallthickness arms
150
let r3      = 10; // cylinder at end of arms
151
let r4      = 1.5 // rounding of cutout
152
let ra      = 2.5 // radius of hole at end of arm
153
let rcb     = 5   // radius of counterbore 
154
let hcb     = 7   // height of counterbore
155

156

157
// generate center cylinder
158
let centerCyl0   = Translate([0,0,h1/2],Cylinder((r1+t1),h1,true))
159
let armCyl      = Translate([0,d,h1/2], Cylinder(r3,h1,true))
160

161
// points for sketch of the arm
162
let p0 = [0,0];
163
let p1 = Dy(p0, d);
164
let p2 = Polar(p1,r0,adeg);
165
let p3 = MirrorY(p2,0);
166
let p4 = RadiusArc(p2,p3,r0,false);
167
let p5 = PolarY(p2,-d1,adeg-90)
168
let p6 = MirrorY(p5,0)
169

170
// generate sketch of one arm 
171
let armSketch = new Sketch(p0)
172
.LineTo(p5)
173
.LineTo(p2)
174
.ArcTo(p4,p3)
175
.LineTo(p6)
176
.LineTo(p0)
177
.End().Face()
178
let arm1        = Extrude(armSketch,[0,0,h1]);
179
let armCutout   = Offset(arm1,-t3,0.01,true);
180
let armCutout1  = Difference(armCutout,[centerCyl0,armCyl]);
181
let armCutout2  = Translate([0,0,h1/2],armCutout1,true);
182
let armCutout3  = Translate([0,0,-h1/2],armCutout1,true);
183
armCutout  = Union([armCutout1,armCutout2,armCutout3]);
184
armCutout  = Offset(armCutout,-r4);
185
armCutout  = Offset(armCutout,r4);
186
arm1        = Difference(arm1,[armCutout]);
187

188
// copy three rotated arms
189
let arm2 = Rotate([0,0,1],120,arm1,true)
190
let arm3 = Rotate([0,0,1],240,arm1,true)
191

192
let arms = Union([arm1,arm2,arm3])
193
arms = FilletEdges(arms, r2, [34,39,61])
194

195
// create sketch of cutting object to taper arms
196
let pc0 = [d+r0+5,h2]
197
let pc1 = [d+r0,h2];
198
let pc2 = PolarX(pc1, -(r0+d)+(r1+t1),(180-gamma));
199
let pc3 = Dx(pc2,-t1-r1/2)
200
let pc4 = Dy(pc3,h1);
201
let pc5 = Dx(pc4,d+r0+10);
202
let pc6 = pc0;
203

204
let cutterSketch = new Sketch(pc0)
205
.LineTo(pc0)
206
.LineTo(pc1)
207
.LineTo(pc2)
208
.LineTo(pc3)
209
.LineTo(pc4)
210
.LineTo(pc5)
211
.LineTo(pc6)
212
.End().Face(true);
213
let cutterFace = Rotate([1,0,0],90,cutterSketch);
214
let cutterShape= Revolve(cutterFace);
215
let shapedArms = Difference(arms,[cutterShape]);
216
shapedArms = FilletEdges(shapedArms,1.5,[51])
217

218
let centerCyl1  = Translate([0,0,h1/2],Cylinder((r1+t1),h1,true))
219
let centerHole  = Translate([0,0,h1/2],Cylinder((r1),h1+20,true))
220
let armHole     = Translate([0,d,h1/2],Cylinder((ra),h1+20,true))
221
let countHole   = Translate([0,d,hcb],Cylinder((rcb),h1+20,false))
222
let armHoleCb1   = Union([countHole,armHole])
223
let armHoleCb2 = Rotate([0,0,1],120,armHoleCb1,true)
224
let armHoleCb3 = Rotate([0,0,1],240,armHoleCb1,true)
225

226

227

228
let armsTot     = Union([shapedArms,centerCyl1])
229
let armsTot1    = Difference(armsTot,[centerHole]);
230
let armsTot2    = Difference(armsTot1,[armHoleCb1,armHoleCb2,armHoleCb3]);
231

232

233

234

235

236

237

238

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.