(info: arc1: inside/outside, cw/ccw, cutter radius compensation) ; Arc making subroutine formatted for ngcgui ; Specify: ; dir == 2 for cw, 3 for ccw ; inside == 1 for inside, 0 for outside ; xoff,yoff == arc center ; arc radius == distance to center of rotation ; angle == anglular spread of arc ; rotate == rotation of arc ; width == width of arc ; see also arc2.ngc to specify using center of rotation ;---------------------------------------------------------------------- ; Copyright: 2012 ; Author: Dewey Garrett ; ; This program is free software; you can redistribute it and/or modify ; it under the terms of the GNU General Public License as published by ; the Free Software Foundation; either version 2 of the License, or ; (at your option) any later version. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ; GNU General Public License for more details. ; ; You should have received a copy of the GNU General Public License ; along with this program; if not, write to the Free Software ; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ;---------------------------------------------------------------------- o sub # = #1 (=1) # = #2 (=2 2:cw 3:ccw) # = #3 (=1 1:inside 0:outside) # = #4 (=2000) # = #5 (=100) # = #6 # = #7 # = #8 (=0.25) # = #9 (=0) # = #10 (=.3) # = #11 (=45 Angle) # = #12 (=2 Arc Radius) # = #13 (=-90) # = #14 (=2) # = #15 (=0) # = #16 (=1) # = #17 (=0) # = #18 (=1) # = #19 (=0) # = #20 (=0) # = 1 ;minimum angle g40; cutter comp off to begin o if [# LE 0] (print, arc1: bad scale: # - EXITING) (debug, arc1: bad scale: # - EXITING) (AXIS,notify, arc1: bad scale - EXITING) m2 o endif o if [[# NE 2] AND [# NE 3]] (print, arc1: bad dir=# - EXITING) (debug, arc1: bad dir=# - EXITING) (AXIS,notify, arc1: bad dir - EXITING) m2 o endif o if [[# NE 1] AND [# NE 0]] (print, arc1: bad inside specifier: # - EXITING) (debug, arc1: bad inside specifier: # - EXITING) (AXIS,notify, arc1: bad inside specifier - EXITING) m2 o endif o if [# LT #] (print, arc1: angle too small: # - EXITING) (debug, arc1: angle too small: # - EXITING) (AXIS,notify, arc1: angle too small - EXITING) m2 o endif o call [#][#][#][#] # = [#5410 + .001] o if [[# GT #] AND [# EQ 1]] (print, arc1: tooldiam too big: # - EXITING) (debug, arc1: tooldiam too big: # - EXITING) (AXIS,notify, arc1: tooldiam too big - EXITING) m2 o endif ; construct arc parallel to x axis (for transformation later) # = [#/2] # = [90 - #/2] # = [2 * # * COS[#]] ; between endpoints ; (xa,ya), (xb,yb), ... are points on arc ; (vxas,vyas), (vxbs,vybs), ... are vectors to subarc centers (short ones) ; (vxal,vyal), (vxbl,vybl), ... are vectors to subarc centers (long ones) ; start point is at center of outside arc: # = 0 # = [# + # * [1 - sin[#]]] # = 0 # = [0 - # - #] # = [0 + #/2 + # * cos[#]] # = [0 + # * sin[#]] # = [0 - # * cos[#]] # = [0 - # * sin[#]] # = [0 - [# + #] * cos[#]] # = [0 - [# + #] * sin[#]] # = [0 + #/2 - # * cos[#]] # = [0 - # * sin[#]] # = [0 + # * cos[#]] # = [0 + # * sin[#]] # = [0 - [# - #] * cos[#]] # = [0 - [# - #] * sin[#]] # = [0 - #/2 + # * cos[#]] # = [0 - # * sin[#]] # = [0 - # * cos[#]] # = [0 + # * sin[#]] # = [0 + [# - #] * cos[#]] # = [0 - [# - #] * sin[#]] # = [0 - #/2 - # * cos[#]] # = [0 + # * sin[#]] # = [0 + # * cos[#]] # = [0 - # * sin[#]] # = [0 + [# + # ] * cos[#]] # = [0 - [# + # ] * sin[#]] ;# this offset makes center at x,y = 0,0 for convenience: # = [0 - # * [1 - sin[#]]] # = [# + #] # = [# + #] # = [# + #] # = [# + #] # = [# + #] ; choose points according to dir: o if [# EQ 2] ; cw 0->a->b->c->d->0 # = 2 ; pre entry # = 2 ; most # = 3 ; inside of arc ; 1/4 circle arc entry move # = [# - #/2] # = [# - #/2] # = [#/2] # = 0 # = # # = # # = # # = # # = # # = # # = # # = # # = # # = # # = # # = # # = # # = # # = # # = # o else ; ccw 0->d->c->b->a->0 # = 3 ; pre entry # = 3 ; most # = 2 ; inside of arc ; 1/4 circle arc entry move # = [# + #/2] # = [# - #/2] # = [0 - #/2] # = 0 # = # # = # # = # # = # # = # # = # # = # # = # # = # # = # # = # # = # # = # # = # # = # # = # o endif ; apply rotation, scaling, offsets o call [#][#][#][#][#][#] # = #<_move:x> # = #<_move:y> o call [#][#][#][#][#][#] # = #<_move:x> # = #<_move:y> o call [#][#][#][#][#][#] # = #<_move:x> # = #<_move:y> o call [#][#][#][#][#][#] # = #<_move:x> # = #<_move:y> o call [#][#][#][#][#][#] # = #<_move:x> # = #<_move:y> o call [#][#][#][#][#][#] # = #<_move:x> # = #<_move:y> ; vectors to arc centers: just rotate and scale, no offset o call [#][#][#][#][0][0] # = #<_move:x> # = #<_move:y> o call [#][#][#][#][0][0] # = #<_move:x> # = #<_move:y> o call [#][#][#][#][0][0] # = #<_move:x> # = #<_move:y> o call [#][#][#][#][0][0] # = #<_move:x> # = #<_move:y> o call [#][#][#][#][0][0] # = #<_move:x> # = #<_move:y> o call [#][#][#][#][0][0] # = #<_move:x> # = #<_move:y> s # m3 o if [# GT 0] o call [#] o endif f# g0 z# g0 x# y# ; pre-entry point o if [# EQ 1] o if [# EQ 2] /g42 ;# cutter compensation right of path o else /g41 ;# cutter compensation left of path o endif o else o if [# EQ 2] /g41 ;# cutter compensation left of path o else /g42 ;# cutter compensation right of path o endif o endif ; entry with cutter radius compensation g# x# y# i # j # g1 z# # = [# - #] o while [# GT [0 - #]] g# x# y# i# j# z # g# x# y# i# j# g# x# y# i# j# g# x# y# i# j# g# x# y# i# j# #=[#-#] o endwhile g# x# y# i# j# z [0 - #] g# x# y# i# j# g# x# y# i# j# g# x# y# i# j# g# x# y# i# j# g# x# y# i# j# g0 z# g40 ;# cancel cutter radius compensation o endsub