summaryrefslogtreecommitdiff
path: root/trunk/users/metalab/python/spiralglass/test2.py
blob: 2123ecc90b28c680f98dc19c9baf13d15a27027b (plain)
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
#!/usr/bin/python

from math import pi, cos, sin

def layerStart(z):
    print "(<layerStart> %(Z)f)\n" % {'Z':z}

def moveTo(x, y, z, f):
    print "G1 X%(X)f Y%(Y)f Z%(Z)f F%(F)f" % {'X':x,'Y':y, 'Z':z, 'F':f}

def spiral(x, y, z, f, r, roh, outward):
    phimax = (2*pi*r)/roh
    if outward==1:
        phi = 0.0
        while (phi < phimax):
            r = (phi*roh)/(2*pi)
            nextx= x+cos(phi)*r
            nexty= y+sin(phi)*r
            moveTo(nextx, nexty, z, f)
            phi += 0.2
    else:
        phi = phimax
        while (phi > 0):
            r = (phi*roh)/(2*pi)
            nextx= x+cos(phi)*r
            nexty= y+sin(phi)*r
            moveTo(nextx, nexty, z, f)
            phi -= 0.2

def circle(x, y, z, f, r, outward):
    if outward==1:
        phi = 0.0
        while (phi < 2*pi):
            nextx= x+cos(phi)*r
            nexty= y+sin(phi)*r
            moveTo(nextx, nexty, z, f)
            phi += 0.2
    else:
        phi = 2*pi
        while (phi > 0):
            nextx= x+cos(phi)*r
            nexty= y+sin(phi)*r
            moveTo(nextx, nexty, z, f)
            phi -= 0.2
        


feedrate = 180
layerheight = 0.7
density = 1.2
radius = 12
radius1 = 7
radius2 = 3

layer = layerheight / 2.0

print "G21"
print "G90"
print "G28"
print "M103"
print "M108 S130.0"
print "M101"

play = 5

layerStart(layer);
spiral(radius+play, radius+play, layer, feedrate, radius1, density, 1)
layer += layerheight
layerStart(layer);
spiral(radius+play, radius+play, layer, feedrate, radius1, density, 0)
layer += layerheight
layerStart(layer);
spiral(radius+play, radius+play, layer, feedrate, radius1, density, 1)
layer += layerheight
layerStart(layer);
spiral(radius+play, radius+play, layer, feedrate, radius1, density, 0)
layer += layerheight

for i in range(0, 15):
    layerStart(layer);
    circle(radius+play, radius+play, layer, feedrate, radius2, 1)
    layer += layerheight
for i in range(0, 30):
    layerStart(layer);
    circle(radius+play, radius+play, layer, feedrate, radius2 + i*(radius-radius2)/30.0, 1)
    layer += layerheight

print "M103"