rem C_3Pt.cdl rem Copy Right by International Technology Transfer Corp. rem revision 1.0-7/30/99 rem ******************************************************************** rem Circle through 3 points rem ******************************************************************* clear defopt = 2 array mtx[9] array mtx1[9] acc = 0.00001 :start getpos "Indicate First Point",defopt on (@key + 3) goto exit, start, defopt=@key x1 = @xworld y1 = @yworld z1 = @zworld :second getpos "Indicate Second Point",defopt on (@key + 3) goto exit, start, second, defopt=@key x2 = @xworld y2 = @yworld z2 = @zworld :third getpos "Indicate Third Point",defopt on (@key + 3) goto exit, second, third, defopt=@key x3 = @xworld y3 = @yworld z3 = @zworld rem *********************************************************************** rem Define View rem *********************************************************************** dx=x2-x1 dy=y2-y1 dz=z2-z1 r=sqrt(dx * dx + dy * dy + dz * dz) if (r@lastvw) goto loop2 getview vnum,mtx1 if (mtx[0]!=mtx1[0] || mtx[1]!=mtx1[1] || mtx[2]!=mtx1[2]) goto loop2 if (mtx[3]!=mtx1[3] || mtx[4]!=mtx1[4] || mtx[5]!=mtx1[5]) goto loop2 if (mtx[6]!=mtx1[6] || mtx[7]!=mtx1[7] || mtx[8]!=mtx1[8]) goto loop2 goto loop1 :loop2 call xfmwv,mtx,x1,y1,z1,vx1,vy1,vz1 call xfmwv,mtx,x2,y2,z2,vx2,vy2,vz2 call xfmwv,mtx,x3,y3,z3,vx3,vy3,vz3 rem *********************************************************************** rem calculation rem vxc = ( a * (vy1-vy3) - b * (vy1-vy2) ) / ( 2 * denom ) rem vyc = ( - a * (vx1-vx3) + b * (vx1-vx2) ) / ( 2 * denom ) rem a = vx1*vx1 - vx2*vx2 + vy1*vy1 - vy2*vy2 rem b = vx1*vx1 - vx3*vx3 + vy1*vy1 - vy3*vy3 rem denom = (vx1 - vx2)*(vy1 - vy3) - (vx1 - vx3)*(vy1 - vy2) rem *********************************************************************** a = vx1*vx1 - vx2*vx2 + vy1*vy1 - vy2*vy2 b = vx1*vx1 - vx3*vx3 + vy1*vy1 - vy3*vy3 denom = (vx1 - vx2)*(vy1 - vy3) - (vx1 - vx3)*(vy1 - vy2) vxc = ( a * (vy1-vy3) - b * (vy1-vy2) ) / ( 2 * denom ) vyc = ( - a * (vx1-vx3) + b * (vx1-vx2) ) / ( 2 * denom ) rad = sqrt((vx1 - vxc) * (vx1 - vxc) + (vy1 - vyc) * (vy1 - vyc)) view vnum,mtx[0],mtx[1],mtx[2],mtx[3],mtx[4],mtx[5],mtx[6],mtx[7],mtx[8] circle vxc,vyc,vz1,rad,vnum redraw :exit clear mtx clear mtx1