-
Notifications
You must be signed in to change notification settings - Fork 1
/
PlumPott.rb
executable file
·502 lines (433 loc) · 10.5 KB
/
PlumPott.rb
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
require './Jacksloon.rb'
#require 'Complex'
$bitwidth = 2.0/25.4
$halfwidth = $bitwidth/2
class PlumPott < Jacksloon
@@engravedeep = -0.05
def initialize(starx, stary)
@resinx=0
@resiny=0
super(starx, stary)
end
def resin(x,y)
@resinx=x
@resiny=y
end
def cutoPointSpesal(x,y)
pyth = ((x-@resinx)**2 + (y-@resiny)**2)**0.5
if pyth>0.04 then
printf "G1 X%5.5f Y%5.5f\n", x, y #@@feedrate
resin(x,y)
end
end
def organoPHORM(arr,x,y,sig)
skimtoPoint(x+(sig*arr[0][1]),
y+(sig*arr[0][0]),0.1)
penetrate(@@engravedeep)
resin(x+(sig*arr[0][1]),y+(sig*arr[0][0]))
arr.each{|rr| cutoPointSpesal(x+(sig*rr[1]),y+(sig*rr[0]))}
#skimtoPoint(x+(sig*arr[0][1]),
# y+(sig*arr[0][0]),0.1)
#penetrate(@@engravedeep)
#resin(x+(sig*arr[0][1]),y+(sig*arr[0][0]))
#arr.each{|rr| cutoPointSpesal(x+(sig*rr[1]),y+(sig*rr[0]))}
#arr.reverse_each{|rr| cutoPointSpesal(x+(sig*rr[1]),y+(sig*rr[0]))}
retrax(0.1)
end
def johnson(x,y)
spyrtub(x,y,5.0/32,0.15/32)
#pipe(x,y,5.1/32,0,-@depth)#spyrtub(x,y,5.25/32,5.0/32)
end
def johnsoninv(x,y,theta)
johnson(x,y)
#spyrtub(x,y,5.1/32,5.0/32)
retract
r = 0.275
for i in 1..6 do
xx = r * Math.sin(theta * Math::PI / 180)
yy = r * Math.cos(theta * Math::PI / 180)
drillus(x+xx,y+yy,0,@@engravedeep)
theta += 360/6
end
end
def looscrew(x,y)
if $bitwidth == 0.125 then
drillus(x,y,0,-@depth)
else
pipe(x,y,1.0/14,0,-@depth)
end
end
def lediode(x,y)
pipe(x,y,3.3/32,0,-@depth)
end
#NUMSEGS = 32
def alpscirque(x,y,theta)
innerrad = 0.28
outerrad = 0.31
for i in 0..32 do
thetai = i
radioi = innerrad
#@@feedrate = 40
if i < 3 then
thetai = 2
radioi = outerrad
#@@feedrate = 20
end
if i >29 then
thetai = 30
radioi = outerrad
#@@feedrate = 20
end
thetai += theta*NUMSEGS/360
yy = radioi * Math.sin(2 * thetai * Math::PI / NUMSEGS)
xx = radioi * Math.cos(2 * thetai * Math::PI / NUMSEGS)
cutoPoint(x+xx,y+yy)
end
thetai = 2 + theta*NUMSEGS/360
#@@feedrate = 20
yy = outerrad * Math.sin(2 * thetai * Math::PI / NUMSEGS)
xx = outerrad * Math.cos(2 * thetai * Math::PI / NUMSEGS)
cutoPoint(x+xx,y+yy)
#@@feedrate = 40
end
def alpscirqueconventional(x,y,theta)
innerrad = 0.28
outerrad = 0.31
for i in 0..32 do
thetai = 32-i
radioi = innerrad
@@feedrate = 40
if thetai < 3 then
thetai = 2
radioi = outerrad
@@feedrate = 20
end
if thetai >29 then
thetai = 30
radioi = outerrad
@@feedrate = 20
end
thetai += theta*NUMSEGS/360
yy = radioi * Math.sin(2 * thetai * Math::PI / NUMSEGS)
xx = radioi * Math.cos(2 * thetai * Math::PI / NUMSEGS)
cutoPoint(x+xx,y+yy)
end
thetai = 30 + theta*NUMSEGS/360
@@feedrate = 20
yy = outerrad * Math.sin(2 * thetai * Math::PI / NUMSEGS)
xx = outerrad * Math.cos(2 * thetai * Math::PI / NUMSEGS)
cutoPoint(x+xx,y+yy)
@@feedrate = 40
end
def alpspot(x,y,theta)
incro = (Float(0-@depth) / Float(@zstep))
skimtoPoint(x,y,0.1)
for i in 1..@zstep do
penetrate((incro * i))
alpscirque(x,y,theta)
end
end
def alpspot(x,y,theta)
alpsdot(x,y,theta)
skimtoPoint(x,y,0.1)
innerrad = 0.3 #0.28
outerrad = 0.33 #0.31
i = 0
z = 0
incro = (Float(@depth) / Float(@zstep))
while z > -@depth - incro do
z -= incro / NUMSEGS
thetai = i % NUMSEGS
radioi = innerrad
if thetai < 3 then
thetai = 2
radioi = outerrad
end
if thetai >29 then
thetai = 30
radioi = outerrad
end
thetai += theta*NUMSEGS/360
yy = radioi * Math.sin(2 * thetai * Math::PI / NUMSEGS)
xx = radioi * Math.cos(2 * thetai * Math::PI / NUMSEGS)
cutoPointDeepo(x+xx,y+yy,z)
i += 1
end
end
def pyth(x,y,th,r,z)
yy = r*Math.sin(2 * th * Math::PI)
xx = r*Math.cos(2 * th * Math::PI)
cutoPointDeepo(x+xx,y+yy,z)
end
def pyrc(x,y,th,r,z,lth)
yy = r*Math.sin(2 * th * Math::PI)
xx = r*Math.cos(2 * th * Math::PI)
ly = r*Math.sin(2 * lth * Math::PI)
lx = r*Math.cos(2 * lth * Math::PI)
if $DEBUG then
printf "G3 X%5.5f Y%5.5f I%5.5f J%5.5f Z%5.5f\n",
x+xx, y+yy, x, y, z
else
printf "G3 X%5.5f Y%5.5f I%5.5f J%5.5f Z%5.5f\n",
x+xx, y+yy, -lx, -ly, z
end
end
def dz(z)
if z<-@depth then return -@depth end
return z
end
def alpsdot(x,y,theta)
skimtoPoint(x,y,0.1)
#innerrad =
outerrad = 3.55/25.4 - $halfwidth
i = 0
z = 0
deepak = -0.35
incro = (Float(-deepak) / Float(@zstep))
while z > deepak do
z -= incro / NUMSEGS
thetai = i % NUMSEGS
radioi = outerrad
if thetai < 6 then
thetai = 7
end
if thetai >26 then
thetai = 25
end
thetai += theta*NUMSEGS/360
yy = radioi * Math.sin(2 * thetai * Math::PI / NUMSEGS)
xx = radioi * Math.cos(2 * thetai * Math::PI / NUMSEGS)
cutoPointDeepo(x+xx,y+yy,z)
i += 1
end
cutoPoint(x,y)
end
def alpsdot(x,y,theta)
drillus(x,y,0,-@depth)
end
def alpsdot(x,y,theta)
skimtoPoint(x,y,0.1)
#innerrad =
outerrad = 3.0/25.4 - $halfwidth #3.2!
i = 0
z = 0
deepak = -0.45
incro = (Float(-deepak) / Float(@zstep))
drepak = deepak - incro
while z > drepak do
z -= incro / NUMSEGS
zz = max(z,deepak)
thetai = i % NUMSEGS
radioi = outerrad
if thetai < 6 then
thetai = 6
end
if thetai >26 then
thetai = 26
end
thetai += theta*NUMSEGS/360
yy = radioi * Math.sin(2 * thetai * Math::PI / NUMSEGS)
xx = radioi * Math.cos(2 * thetai * Math::PI / NUMSEGS)
cutoPointDeepo(x+xx,y+yy,zz)
i += 1
end
while z < 0 do
z += incro / NUMSEGS
zz = max(z,deepak)
thetai = i % NUMSEGS
radioi = outerrad
if thetai < 6 then
thetai = 7
end
if thetai >26 then
thetai = 25
end
thetai += theta*NUMSEGS/360
yy = radioi * Math.sin(2 * thetai * Math::PI / NUMSEGS)
xx = radioi * Math.cos(2 * thetai * Math::PI / NUMSEGS)
cutoPointDeepo(x+xx,y+yy,zz)
i += 1
end
end
def alpsdot(x,y,theta)
#drillus(x,y,0,-@depth)
skimtoPoint(x,y,0.1)
outerrad = 3.0/25.4 - $halfwidth #3.2!
deepak = -0.39
z=0
incro = (Float(-deepak) / Float(@zstep))
incro /= 3.0
theta = Float(theta)/360
drepak = deepak -incro
while z > drepak do
pyth(x,y,26.0/32.0+theta,outerrad,dz(z))
z-=incro
pyth(x,y,6.0/32.0+theta,outerrad,dz(z))
z-=incro
pyrc(x,y,26.0/32.0+theta,outerrad,dz(z),6.0/32+theta)
z-=incro
end
z+=incro
while z < 0 do
pyth(x,y,26.0/32.0+theta,outerrad,dz(z))
z+=incro
pyth(x,y,6.0/32.0+theta,outerrad,dz(z))
z+=incro
pyrc(x,y,26.0/32.0+theta,outerrad,dz(z),6.0/32+theta)
z+=incro
end
pyth(x,y,26.0/32.0+theta,outerrad,dz(z))
end
def alpspot(x,y,theta)
#drillus(x,y,0,-@depth)
skimtoPoint(x,y,0.1)
retract()
z=0
incro = (Float(@depth) / Float(@zstep))
incro /= 4.0
theta = Float(theta)/360
while z>-@depth - incro do
pyth(x,y,30.0/32.0+theta,0.33,dz(z))
z-=incro
pyth(x,y,2.0/32.0+theta,0.33,dz(z))
z-=incro
pyth(x,y,3.0/32.0+theta,0.3,dz(z))
z-=incro
pyrc(x,y,29.0/32.0+theta,0.3,dz(z),3.0/32+theta)
z-=incro
end
pyth(x,y,30.0/32.0+theta,0.33,dz(z))
end
def alpspot_exp(x,y,theta)
#drillus(x,y,0,-@depth)
skimtoPoint(x,y,0.1)
#alpsdot(x,y,theta)
alpsdot(x,y,180)
spyrtub(x,y,0.3,0.01)
pipe(x,y,0.33,0,-0.1)
end
def rotaframe(x,y,wido,hido,theta)
wido -= $bitwidth
hido -= $bitwidth
wido /= 2
hido /= 2
theta = Math::PI*theta/180
angol = Math.atan(hido/wido)
radio = Math.sqrt(hido*hido+wido*wido)
euler=Complex.polar(radio,angol+theta)
cutoPoint(x+euler.real,y+euler.imag)
euler=Complex.polar(radio,Math::PI-angol+theta)
cutoPoint(x+euler.real,y+euler.imag)
euler=Complex.polar(radio,Math::PI+angol+theta)
cutoPoint(x+euler.real,y+euler.imag)
euler=Complex.polar(radio,0-angol+theta)
cutoPoint(x+euler.real,y+euler.imag)
euler=Complex.polar(radio,angol+theta)
cutoPoint(x+euler.real,y+euler.imag)
end
def rotaframeconventional(x,y,wido,hido,theta)
wido -= $bitwidth
hido -= $bitwidth
wido /= 2
hido /= 2
theta = Math::PI*theta/180
angol = Math.atan(hido/wido)
radio = Math.sqrt(hido*hido+wido*wido)
euler=Complex.polar(radio,angol+theta)
cutoPoint(x+euler.real,y+euler.imag)
euler=Complex.polar(radio,0-angol+theta)
cutoPoint(x+euler.real,y+euler.imag)
euler=Complex.polar(radio,Math::PI+angol+theta)
cutoPoint(x+euler.real,y+euler.imag)
euler=Complex.polar(radio,Math::PI-angol+theta)
cutoPoint(x+euler.real,y+euler.imag)
euler=Complex.polar(radio,angol+theta)
cutoPoint(x+euler.real,y+euler.imag)
end
def rotabo(x,y,wido,hido,deep,step,theta)
incro = (Float(0-deep) / Float(step))
skimtoPoint(x,y,0.1)
for i in 1..step do
penetrate((incro * i))
rotaframe(x,y,wido,hido,theta)
end
end
def rotabox(x,y,wido,hido,theta)
incro = (Float(0-@depth) / Float(@zstep))
skimtoPoint(x,y,0.1)
for i in 1..@zstep do
penetrate((incro * i))
rotaframe(x,y,wido,hido,theta)
end
end
def rotabox(x,y,wido,hido,theta)
wido -= $bitwidth
hido -= $bitwidth
wido /= 2
hido /= 2
theta = Math::PI*theta/180
angol = Math.atan(hido/wido)
radio = Math.sqrt(hido*hido+wido*wido)
skimtoPoint(x,y,0.1)
z = 0
incro = (Float(@depth) / Float(@zstep))
while z > -@depth - incro do
euler=Complex.polar(radio,angol+theta)
cutoPointDeepo(x+euler.real,y+euler.imag,z)
z -= incro / 4
euler=Complex.polar(radio,Math::PI-angol+theta)
cutoPointDeepo(x+euler.real,y+euler.imag,z)
z -= incro / 4
euler=Complex.polar(radio,Math::PI+angol+theta)
cutoPointDeepo(x+euler.real,y+euler.imag,z)
z -= incro / 4
euler=Complex.polar(radio,0-angol+theta)
cutoPointDeepo(x+euler.real,y+euler.imag,z)
z -= incro / 4
end
end
def swdpdt(x,y,theta)
rotabox(x,y,0.37,0.35+$bitwidth,theta)
end
def swdpst(x,y,theta)
rotabox(x,y,0.37,0.25,theta)
end
def cutoPointz(x,y,z)
if z<0 then
printf "G1 X%5.3f Y%5.3f Z%5.3f\n", x, y, z
end
end
def parabolza(x,y,z,xx,yy)
#feb24 was x12 y12 z10
x/=12.0
y/=16.0
z/=13.0
cutoPointz(xx+x,yy+y,(x**4)+8*(y**4)-z)
end
def shallot(x,y,xs)
skimtoPoint(x,y,0.1)
signx = signy = 1
for k in 0..3 do
for j in 0..12 do
for i in -13..14 do
parabolza(xs*j,signy*i,k,x,y)
end
signy*=-1
end
signx*=-1
end
end
def microshallot(x,y,xs)
skimtoPoint(x,y,0.1)
signx = signy = 1
for k in 0..2 do
for j in 0..12 do
for i in -13..14 do
parabolza(xs*j,signy*i,k,x,y)
end
signy*=-1
end
signx*=-1
end
end
end