Advertisement
Guest User

Untitled

a guest
Feb 16th, 2020
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. import math
  2.  
  3. # for CC arch
  4. CPx = int(input("Center point x \n"))
  5. CPy = int(input("Center point y \n"))
  6. xS = int(input("Start point x \n"))
  7. yS = int(input("Start point y \n"))
  8. div = int(input("divisions over a 180 deg rotation? \n"))
  9. direct = input("CC or CW? \n")
  10. d = '3'
  11. print('G0' ' X' + str(round(xS)) + ' Y' + str(round(yS)))
  12. if direct == "CW":
  13. print("M280 P4 S850 I1")
  14. else:
  15. print("M280 P4 S1668 I1")
  16.  
  17. print("G4 500")
  18.  
  19. for i in range(div):
  20. a = i+1
  21. r = a/div
  22.  
  23. if direct == "CW":
  24. d = "2"
  25. r = -r
  26.  
  27. # CPx = 150
  28. # CPy = 0
  29. # xS = 150
  30. # yS = -100
  31. # r = 0.5
  32.  
  33. theta = r
  34. fudge = 11 / 12 # ;
  35. theta = -theta #
  36. maxz = 2350 # ; % Max pulse duration (us)
  37. minz = 850 # ; % Min pulse duration (us)
  38. pos = (theta % 2 * math.pi) / (fudge * 2 * math.pi) # ; % Nomalized position (rad/2pi)
  39. pos = round(pos * (maxz - minz) + minz) # ; % Scaled pulse duraction (us)
  40. print('M280 P4 S' + str(pos) + ' I1') # ;
  41.  
  42. Xshift = ((xS - CPx) * math.cos(r * math.pi)) + ((CPy - yS) * math.sin(r * math.pi))
  43. Yshift = ((yS - CPy) * math.cos(r * math.pi)) + ((xS - CPx) * math.sin(r * math.pi))
  44. NewX = CPx + Xshift
  45. NewY = CPy + Yshift
  46. NewI = CPx - NewX
  47. NewJ = CPy - NewY
  48. 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