Type TPoint = Record X, Y: Integer; End; Function min(a, b: Integer): Integer; Begin min := a; if b < a Then min := b End; Function max(a, b: Integer): Integer; Begin max := a; if b > a Then max := b End; Function isInside(Const a: Array Of TPoint; b: TPoint; n: Integer): Boolean; Var i, j, Count: Word; T: Double; Begin Count := 0; For i := 0 To Pred(n) Do Begin j := (i+1) mod n; If a[i].Y = a[j].Y Then Continue; If (a[i].Y > b.Y) and (a[j].Y > b.Y) Then Continue; If (a[i].Y < b.Y) and (a[j].Y < b.Y) Then Continue; If (max(a[i].Y, a[j].Y) = b.Y) Then Inc(Count) Else Begin If min(a[i].Y, a[j].Y) = b.y Then Continue Else Begin T := (b.Y - a[i].Y) / (a[j].Y - a[i].Y); If a[i].X + T * (a[j].X - a[i].X) >= b.X Then Inc(Count) End End; End; IsInside := ((Count and $0001) <> 0) End; Function PointInSidebar(Const SideBar: Array Of TPoint; p: TPoint; Count: Integer): Boolean; Var x1,y1,x2,y2: Double; x0, y0, sum, divisor: Double; i: integer; Begin sum := 0; y0 := p.y; x0 := p.x; For i := 0 to Pred(count-1) do Begin x1:=sidebar[i].x; y1:=sidebar[i].y; x2:=sidebar[i+1].x; y2:=sidebar[i+1].y; divisor:=y1*x2-x1*y2-y0*x2+y0*x1+x0*y2-x0*y1; divisor := divisor + 1.0E-10; Sum := sum + ( -arctan( (-x2*x1+x1*x0+y0*y1-x2*x0+x2*x2-y2*y0+y2*y2-y1*y2 )/divisor)+ arctan( (-x1*x1+x2*x1+x1*x0+y0*y1+y1*y2-x2*x0-y1*y1-y2*y0 )/divisor) ); End; x1:=sidebar[count-1].x; y1:=sidebar[count-1].y; x2:=sidebar[0].x; y2:=sidebar[0].y; divisor:=y1*x2-x1*y2-y0*x2+y0*x1+x0*y2-x0*y1; divisor := divisor + 1.0E-10; Sum := sum + ( -arctan((-x2*x1+x1*x0+y0*y1-x2*x0+x2*x2-y2*y0+y2*y2-y1*y2)/divisor)+ arctan((-x1*x1+x2*x1+x1*x0+y0*y1+y1*y2-x2*x0-y1*y1-y2*y0)/divisor) ); pointinsidebar := not (abs(Sum) < 0.0001) End; Const arr: Array[0 .. 3] Of TPoint = (* ( {First} (X:3;Y:3), (X:7;Y:10), (X:12;Y:6), (X:9;Y:7) ); *) (* ( (X:12;Y:8), (X:17;Y:14), (X:17;Y:11), (X:21;Y:7) ); *) ( (X:1;Y:2), (X:1;Y:4), (X:3;Y:4), (X:3;Y:2) ); Const (* {First} Check1: TPoint = (X:4; Y:8); Check2: TPoint = (X:7; Y:8); Check3: TPoint = (X:7; Y:5); Check4: TPoint = (X:9; Y:5); *) (* {Second} Check1: TPoint = (X:13; Y:12); Check2: TPoint = (X:16; Y:10); Check3: TPoint = (X:18; Y:11); Check4: TPoint = (X:19; Y:8); *) Check1: TPoint = (X:1; Y:3); Var b: Boolean; Begin b := PointInSidebar(arr, Check1, 4); { b := PointInSidebar(arr, Check2, 4); b := PointInSidebar(arr, Check3, 4); b := PointInSidebar(arr, Check4, 4); } End.