Board Thread:Program Announcements/@comment-25017421-20140603081447/@comment-5334617-20141126022928

Another speedup: for the code:

MAG(0) = SQR(POW(VEC(0,0),2) + POW(VEC(1,0),2) + POW(VEC(2,0),2)) MAG(1) = SQR(POW(VEC(0,1),2) + POW(VEC(1,1),2) + POW(VEC(2,1),2)) IF !MAG(0) THEN MAG(0)=1 IF !MAG(1) THEN MAG(1)=1 FOR G=0 TO 1 FOR H=0 TO 2 VEC(H,G) = VEC(H,G) / MAG(G) NEXT NEXT NORMAL(0) = VEC(1,0) * VEC(2,1) - VEC(2,0) * VEC(1,1) NORMAL(1) = VEC(2,0) * VEC(0,1) - VEC(0,0) * VEC(2,1) NORMAL(2) = VEC(0,0) * VEC(1,1) - VEC(1,0) * VEC(0,1)

you should be able to replace it with

NORMAL(0) = VEC(1,0) * VEC(2,1) - VEC(2,0) * VEC(1,1) NORMAL(1) = VEC(2,0) * VEC(0,1) - VEC(0,0) * VEC(2,1) NORMAL(2) = VEC(0,0) * VEC(1,1) - VEC(1,0) * VEC(0,1) MAG = SQR(POW(NORMAL(0),2) + POW(NORMAL(1),2) + POW(NORMAL(2),2)) IF !MAG THEN MAG=1 FOR H=0 TO 2 NORMAL(H) = NORMAL(H) / MAG NEXT

which will be faster, and have less rounding error. Instead of normalizing two vectors, and taking the cross product, this code takes the cross product, then normalizes the result. This also does away with the  array.