-
Notifications
You must be signed in to change notification settings - Fork 0
/
kugel.py
50 lines (44 loc) · 1.72 KB
/
kugel.py
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
#!/usr/bin/env python
# ----------------------------------------------------------------------------
# "THE BEER-WARE LICENSE" (Revision 42):
# <[email protected]> wrote this file. As long as you retain this notice you
# can do whatever you want with this stuff. If we meet some day, and you think
# this stuff is worth it, you can buy me a beer in return Sebastian Bachmann
# ----------------------------------------------------------------------------
import numpy
import sys
from math import sqrt, pi, sin, cos, asin, acos
# in mm
r=200.0
# how much slices should be generated
steps = 20.0
# how much of the sphere should be done (from top down)
segment_height=10.0
# anlaufbogenradius
a=10
# we consider that the top of the sphere is X0 Y0 Z0
print "G21 ;mm"
print "G90 ; absolute coordinates"
print "F500 ;500mm/minutes movement speed"
print "M7 ; staubsauger an"
print "S1 M3 ; fraeser einschalten"
print "G4 P2 ; 2 sekunden warten bis motor gut rennt"
print "G0 X0 Y0 Z%f; position ourself above the center of the sphere" %(10)
# going top down
fstart = (pi/2) - 0.01
fstop = asin((r-segment_height) / r)
sys.stderr.write(str(fstart)+" "+str(fstop))
for alpha in numpy.linspace(fstart, fstop, steps):
p = r * cos(alpha)
# need r - ... here to have the circle top on z = 0
h = (r * sin(alpha)) - r
# position vor dem anlaufbogen anfahren
print "G0 X%f Y%f Z%f" %(-p, -a, h+a)
# anlaufbogen, ccw in YZ Plane - parallel to X Axis
print "G19 G3 Y0 Z%f J%f F100" %(h, a)
# kreis fraesen
print "G17 G2 X%f Y0 I%f F100" %(-p, p)
# anlaufbogen, ccw in YZ Plane - parallel to X Axis
print "G19 G3 Y%f Z%f K%f F100" %(a, h+a, a)
print "G0 X0 Y0 Z%f; position ourself above the center of the sphere" %(40)
print "M30"