Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- # for CC arch
- CPx = int(input("Center point x \n"))
- CPy = int(input("Center point y \n"))
- xS = int(input("Start point x \n"))
- yS = int(input("Start point y \n"))
- div = int(input("divisions over a 180 deg rotation? \n"))
- direct = input("CC or CW? \n")
- d = '3'
- print('G0' ' X' + str(round(xS)) + ' Y' + str(round(yS)))
- if direct == "CW":
- print("M280 P4 S850 I1")
- else:
- print("M280 P4 S1668 I1")
- print("G4 500")
- for i in range(div):
- a = i+1
- r = a/div
- if direct == "CW":
- d = "2"
- r = -r
- # CPx = 150
- # CPy = 0
- # xS = 150
- # yS = -100
- # r = 0.5
- theta = r
- fudge = 11 / 12 # ;
- theta = -theta #
- maxz = 2350 # ; % Max pulse duration (us)
- minz = 850 # ; % Min pulse duration (us)
- pos = (theta % 2 * math.pi) / (fudge * 2 * math.pi) # ; % Nomalized position (rad/2pi)
- pos = round(pos * (maxz - minz) + minz) # ; % Scaled pulse duraction (us)
- print('M280 P4 S' + str(pos) + ' I1') # ;
- Xshift = ((xS - CPx) * math.cos(r * math.pi)) + ((CPy - yS) * math.sin(r * math.pi))
- Yshift = ((yS - CPy) * math.cos(r * math.pi)) + ((xS - CPx) * math.sin(r * math.pi))
- NewX = CPx + Xshift
- NewY = CPy + Yshift
- NewI = CPx - NewX
- NewJ = CPy - NewY
- print('G' + d + ' X' + str(round(NewX)) + ' Y' + str(round(NewY)) + ' I' + str(round(NewI)) + ' J' + str(round(NewJ)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement