rem D_2Ln.cdl rem Copy Right by International Technology Transfer Corp. rem revision 1.0-7/30/99 rem ******************************************************************** rem Distance between two lines rem 1. select 1st line rem 2. select 2nd line rem 3. Calculate distance rem ******************************************************************** clear acc = 0.0001 :start getent "Select First Line",enttype on (@key + 3) goto exit,start,start, if (enttype!=2) goto start x1 = @fltdat[0] y1 = @fltdat[1] z1 = @fltdat[2] x2 = @fltdat[3] y2 = @fltdat[4] z2 = @fltdat[5] f1 = x2 - x1 g1 = y2 - y1 h1 = z2 - z1 :second getent "Select Second Line",enttype on (@key + 3) goto exit, start, second, if (enttype!=2) goto second x3 = @fltdat[0] y3 = @fltdat[1] z3 = @fltdat[2] x4 = @fltdat[3] y4 = @fltdat[4] z4 = @fltdat[5] f2 = x4 - x3 g2 = y4 - y3 h2 = z4 - z3 rem *********************************************************************** rem Dist = abs(bunshi) / bunbo rem rem | x3 - x1 y3 - y1 z3 - z1 | rem bunshi = | f1 g1 h1 | rem | f2 g2 h2 | rem rem bunbo = sqrt(fg*fg + gh*gh + hf*hf) rem rem fg = f1*g2 - f2*g1 , gh = g1*h2 - g2*h1 , hf = h1*f2 - h2*f1 rem *********************************************************************** fg = f1 * g2 - f2 * g1 gh = g1 * h2 - g2 * h1 hf = h1 * f2 - h2 * f1 bunbo = fg * fg + gh * gh + hf * hf rem If pararel, f1:f2 = g1:g2 = h1:h2 and bunbo becomes 0 if (bunbo