Polygonal Exclusion Zone Macro in CNC Applications | Steve Wait – December 3, 2019

A portion of the macro below (in red) is an example of hexagonal boundary membership validation.

Reference prior post: CNC PARABOLOID INTERPOLATION

%
O01491 (PARABOLIC, METRIC)
N8T8M6 (50.8mm 2FL HSS B EM)
G21G40G80G90T2
G187P3
(/M1)
(M8)
/M88
G54M11
G0X0.Y0.M3S3750
G43H1Z50.8M31
G1Z25.4F1.
G65P1492D50.8K312.369 (PASS VARIABLES TO MACRO)
G0G28G91Z0.M89
G90Y101.6M9
M30
%

%
O01492(AXIS SYMMETRIC, CONCAVE PARABOLOID, INTERPOLATION MACRO)
#1=1/[4*#6] (A, COEFFICIENT)
#3=0. (INITIALIZE RADIAL DISPLACEMENT OF PARABOLA X COORDINATE IN XZ PLANE)
#4=.0005 (RADIAL INCREMENT OF X COORDINATE)
#5=0. (INITIALIZE ANGULAR DISPLACMENT OF THETA IN XY PLANE)
#8=.3 (ANGULAR INCREMENT OF THETA IN XY PLANE)
N1#3=#3+#4 (NEXT RADIAL DISPLACEMENT OF X COORDINATE IN XZ PLANE)
#5=#5+#8 (NEXT ANGULAR DISPLACEMENT OF THETA IN XY PLANE)
#23=#1*[#3*#3] (PARABOLA Z COORDINATE IN XZ PLANE)
#24=[COS[#5]]*[#3-[[[#3*#7]*SQRT[[[4*[#6*#6]]+[#3*#3]]]]/[[8*[#6*#6]]+[2*[#3*#3]]]]](COMPENSATED AND ROTATIONALLY TRANSFORMED VALUE OF X – BALL CENTER)
#25=[SIN[#5]]*[#3-[[[#3*#7]*SQRT[[[4*[#6*#6]]+[#3*#3]]]]/[[8*[#6*#6]]+[2*[#3*#3]]]]](COMPENSATED AND ROTATIONALLY TRANSFORMED VALUE OF Y – BALL CENTER)
#26=#23+[[[#6*#7]*SQRT[[[4*[#6*#6]]+[#3*#3]]]]/[[4*[#6*#6]]+[#3*#3]]] (COMPENSATED VALUE OF Z – BALL CENTER)
IF[#5EQ360.]THEN#5=0. (RESET OF THETA IN XY PLANE – ANGULAR DISPLACEMENT TO 0 WHEN 360)
#100=SQRT[[#24*#24]+[#25*#25]] (RADIAL LIMIT CALC)
IF[#100 GT 258.0987]GOTO19 (MAX RADIAL LIMIT FOR PROG END TEST)
(HEXAGONAL BOUNDARY TESTING)
IF[#24 LT 258.0987]GOTO11 (X+, TEST)
GOTO1 (NEXT CALC)
N11#101=[-1.732051615*#24]+447.04
IF[#25 LT #101]GOTO12 (X+,Y+ TEST)
GOTO1 (NEXT CALC)
N12IF[#25 LT 223.52]GOTO13 (Y+ TEST)
GOTO1 (NEXT CALC)
N13#102=[1.732051615*#24]+447.04
IF[#25 LT #102]GOTO14 (X-,Y+ TEST)
GOTO1 (NEXT CALC)
N14IF[#24 GT -258.0987]GOTO15 (X- TEST)
GOTO1 (NEXT CALC)
N15#103=[-1.732051615*#24]-447.04
IF[#25GT#103]GOTO16 (X-,Y- TEST)
GOTO1 NEXT CALC)
N16IF[#25 GT -223.52]GOTO17 (Y- TEST)
GOTO1 (NEXT CALC)
N17#104=[1.732051615*#24]-447.04
IF[#25 GT #104]GOTO18 (X+,Y- TEST)
GOTO1 (NEXT CALC)
N18G1X#24Y#25Z#26 (MACHINE MOVEMENT)
GOTO1 (LOOP)
N19M99
%