uses Math;var NPoints:Array of TPoint; //图形A的点集合 MPoints:Array of TPoint; //图形B的点集合procedure CalcNum(N1,N2:TPoint; M1:TPoint; Var TopNum,BotNum:Integer);var TmpInt:Integer;begin //N1,N2为A图线段,M1为B图某个点 //从Y方向看,M1在线段上侧,则Inc(BotNum),在线段下侧,则Inc(TopNum) if N1.X=N2.X Then Exit; if Sign(N1.X-M1.X) <> Sign(M1.X-N2.X) then Exit; TmpInt := Sign((N2.Y-N1.Y)/(N2.X-N1.X)*(M1.X-N1.X) - M1.Y); if TmpInt>0 then Inc(BotNum) else if TmpInt<0 then Inc(TopNum);end;procedure TForm1.Button1Click(Sender: TObject);var N,M:Integer; TopNum,BotNum:Integer; XiangJiao,MinN:Boolean;begin MinN:=True;//M是否在N内部 XiangJiao:=False;//是否相交 for M:=Low(MPoints) to High(MPoints) do begin TopNum:=0; BotNum:=0; For N:=Low(NPoints) to High(NPoints) do begin if N=High(High(NPoints)) then CalcNum(NPoints[N],NPoints[0], MPoints[M], TopNum,BotNum) else CalcNum(NPoints[N],NPoints[N+1], MPoints[M], TopNum,BotNum); end; if ((TopNum Mod 2)=1) and ((BotNum Mod 2)=1) then XiangJiao:=True else MinN:=False; end;end;