oquad.ngc
1 (outside traverse arbitrary quadrangle) 2 (computes direction for polygon cw or ccw and swaps if required) 3 4 (info: oquad: outside quadrilateral, specify four x,y points) 5 o<oquad> sub 6 7 #<toolno> = #1 (=1) 8 #<rpm> = #2 (=1) 9 #<dir> = #3 (=2 2conv|3climb) 10 #<feedrate> = #4 (=10) 11 #<cutdepth> = #5 12 #<zincr> = #6 13 #<zsafe> = #7 (=0.2) 14 #<zstart> = #8 (=0) 15 #<x1> = #9 16 #<y1> = #10 17 #<x2> = #11 18 #<y2> = #12 19 #<x3> = #13 20 #<y3> = #14 21 #<x4> = #15 22 #<y4> = #16 23 #<scale> = #17 (=1) 24 #<rotate> = #18 (=0) 25 #<xoff> = #19 (=0) 26 #<yoff> = #20 (=0) 27 #<spin_notify> = #21 (=0) 28 #<use_g43> = #22 (=1) 29 #<h_for_g43> = #23 (=0) 30 #<verbose> = #24 (=0) 31 32 o<i0> if [#<scale> EQ 0] 33 #<scale> = 1.0 34 (debug, scale was 0, setting #<scale>) 35 o<i0> endif 36 37 o<loadtool> call [#<toolno>][#<use_g43>][#<h_for_g43>][#<verbose>] 38 #<tooldiam> = [#5410 + .001] 39 40 o<l00> if [[#<dir> NE 2] AND [#<dir> NE 3]] 41 (debug, oquad: bogus direction #<dir> - EXITING) 42 (print, oquad: bogus direction #<dir> - EXITING) 43 (AXIS,notify, oquad: bogus direction - EXITING) 44 m2 45 o<l00> endif 46 47 (determine direction eg cw or ccw of points) 48 o<dir> call [4][#<x1>][#<y1>][#<x2>][#<y2>][#<x3>][#<y3>][#<x4>][#<y4>] 49 #<pointsdir> = #<_dir:> 50 51 o<l20> if [#<pointsdir> NE #<dir>] 52 (swap 1234 --> 1432) 53 #<xt> = #<x2> 54 #<yt> = #<y2> 55 #<x2> = #<x4> 56 #<y2> = #<y4> 57 #<x4> = #<xt> 58 #<y4> = #<yt> 59 o<l20> endif 60 61 (apply scale, rotate, then offset to all input points) 62 o<move> call [#<x1>][#<y1>][#<rotate>][#<scale>][#<xoff>][#<yoff>] 63 #<x1> = #<_move:x> 64 #<y1> = #<_move:y> 65 o<move> call [#<x2>][#<y2>][#<rotate>][#<scale>][#<xoff>][#<yoff>] 66 #<x2> = #<_move:x> 67 #<y2> = #<_move:y> 68 o<move> call [#<x3>][#<y3>][#<rotate>][#<scale>][#<xoff>][#<yoff>] 69 #<x3> = #<_move:x> 70 #<y3> = #<_move:y> 71 o<move> call [#<x4>][#<y4>][#<rotate>][#<scale>][#<xoff>][#<yoff>] 72 #<x4> = #<_move:x> 73 #<y4> = #<_move:y> 74 75 #<r> = [#<tooldiam>/2] 76 #<cutdepth> = [0 - #<cutdepth>] 77 #<zincr> = [0 - #<zincr>] 78 79 (get lengths and angles for connecting lines) 80 o<line> call [#<x1>][#<y1>][#<x2>][#<y2>] 81 #<phi12> = #<_line:phi> 82 83 g40 (cutter radius compensation off) 84 f #<feedrate> 85 s #<rpm> m3 (spindle cw) 86 o<if1> if [#<spin_notify> GT 0] 87 o<spin> call [#<rpm>] 88 o<if1> endif 89 g0 z#<zsafe> 90 #<zcurrent> = #<zstart> 91 #<pass> = 1 92 93 o<wh010> while [#<zcurrent> GT #<cutdepth>] 94 #<zcurrent> = [#<zcurrent> + #<zincr>] 95 o<wh020> if [#<zcurrent> LT #<cutdepth>] 96 #<zcurrent> = #<cutdepth> 97 o<wh020> endif 98 o<wh030> if [#<pass> GT 100] 99 (debug, oquad: too many passes - EXITING) 100 (print, oquad: too many passes - EXITING) 101 (AXIS,notify, oquad: too many passes - EXITING) 102 m2 103 o<wh030> endif 104 105 o<pas00> if [#<pass> EQ 1] 106 o<dir00> if [#<dir> EQ 2] 107 #<bx> = [#<x1> - #<r> * sin[#<phi12>] - #<r> * cos[#<phi12>]] 108 #<by> = [#<y1> + #<r> * cos[#<phi12>] - #<r> * sin[#<phi12>]] 109 #<vx> = [ #<r> * cos[#<phi12>]] (b to arc center) 110 #<vy> = [ #<r> * sin[#<phi12>]] 111 g0 x #<bx> y #<by> 112 / g41 (cutter radius comp left of path) 113 g3 x #<x1> y #<y1> i #<vx> j #<vy> (arc entry) 114 o<dir00> else (dir EQ 3 CCW) 115 #<bx> = [#<x1> + #<r> * sin[#<phi12>] - #<r> * cos[#<phi12>]] 116 #<by> = [#<y1> - #<r> * cos[#<phi12>] - #<r> * sin[#<phi12>]] 117 #<vx> = [ #<r> * cos[#<phi12>]] (b to arc center) 118 #<vy> = [ #<r> * sin[#<phi12>]] 119 g0 x #<bx> y #<by> 120 / g42 (cutter radius comp right of path) 121 g2 x #<x1> y #<y1> i #<vx> j #<vy> (arc entry) 122 o<dir00> endif 123 #<xfinal> = #<x2> 124 #<yfinal> = #<y2> 125 g1 z #<zstart> (plunge to start height todo:g0) 126 o<pas00> endif 127 x #<x2> y #<y2> z#<zcurrent> (ramp down to zcurrent) 128 x #<x3> y #<y3> 129 x #<x4> y #<y4> 130 x #<x1> y #<y1> 131 #<pass> = [#<pass> + 1] 132 o<wh010> endwhile 133 g1 x #<xfinal> y #<yfinal> 134 g0 z #<zsafe> 135 g40 136 o<oquad> endsub