Tu avais posté ta solution, et j'avais pas vu que tu cherchais toujours une solution

(je pensais que tu avais ton compte avec la fonction PtInRegion)
Je te poste donc mon algo des droites en version optimisée
(donc si t'as des questions je répond sans problème)
Code : Tout sélectionner
Structure Pts
Pt.Point[0]
EndStructure
Procedure.l PointInPolygon(*Polygon.Pts, nPoints.l, x.l, y.l)
Protected InPolygon.l, in.l, i.l
Protected x1.l, x2.l, y1.l, y2.l
If *Polygon And nPoints >= 3
x1 = *Polygon\Pt[0]\x - x
y1 = *Polygon\Pt[0]\y - y
Repeat
i + 1
If i = nPoints
i = 0
EndIf
x2 = *Polygon\Pt[i]\x - x
y2 = *Polygon\Pt[i]\y - y
If (y1 ! y2) & $80000000
in = ( (x1 * y2) - (x2 * y1) ) / (y2 - y1)
EndIf
If in > 0
InPolygon ! #True
in = 0
EndIf
x1 = x2
y1 = y2
Until i = 0
EndIf
ProcedureReturn InPolygon
EndProcedure
;-exemple
If OpenWindow(0, 0, 0, 600, 400, #PB_Window_SystemMenu|#PB_Window_ScreenCentered, "Algo des droites")
CreateGadgetList( WindowID(0) )
CreateImage(0, 320, 240)
ImageGadget(0, 140, 80, 320, 240, UseImage(0))
ButtonGadget(1, 10, 10, 120, 20, "Ajouter un point")
ButtonGadget(2, 10, 40, 120, 20, "Dessiner le polygône")
ButtonGadget(3, 10, 70, 120, 20, "Remise à zéro")
DisableGadget(2, 1)
CreateStatusBar(0, WindowID(0))
AddStatusBarField(600)
Dim Polygone.Point(0)
NewList Points.Point()
Repeat
Event = WaitWindowEvent()
If Event = #PB_Event_Gadget
Gadget = EventGadgetID()
Select Gadget
Case 0
If Ajoute
AddElement( Points() )
Points()\x = WindowMouseX() - 140
Points()\y = WindowMouseY() - 80
If StartDrawing( ImageOutput() )
Plot(Points()\x, Points()\y, $00FFFF)
StopDrawing()
EndIf
SetGadgetState(0, ImageID())
If CountList( Points() ) >= 3
DisableGadget(2, #False)
EndIf
Ajoute = #False
EndIf
Case 1
StatusBarText(0, 0, "Cliquez sur l'image pour ajouter le point")
Ajoute = #True
Case 2
n = CountList( Points() )
Dim Polygone.Point(n - 1)
i = 0
ForEach Points()
Polygone(i)\x = Points()\x
Polygone(i)\y = Points()\y
i + 1
Next
If StartDrawing( ImageOutput() )
Box(0, 0, 320, 240, $000000)
i = 1
While i <= n
x1 = Polygone(i%n)\x
y1 = Polygone(i%n)\y
x2 = Polygone(i-1)\x
y2 = Polygone(i-1)\y
LineXY(x1, y1, x2, y2, $00FFFF)
i + 1
Wend
StopDrawing()
EndIf
SetGadgetState(0, ImageID())
DisableGadget(2, #True)
Dessine = #True
Case 3
ClearList( Points() )
If StartDrawing( ImageOutput() )
Box(0, 0, 320, 240, $000000)
StopDrawing()
EndIf
SetGadgetState(0, ImageID())
Dessine = #False
DisableGadget(2, #True)
StatusBarText(0, 0, "")
EndSelect
DisableGadget(1, Dessine|Ajoute)
Else
If Dessine
x = WindowMouseX() - 140
y = WindowMouseY() - 80
If x >= 0 And y >= 0 And x <320 And y < 240
If PointInPolygon(Polygone(), n, x, y)
s$ = "Dans le polygône"
Else
s$ = "Hors du polygône"
EndIf
Else
s$ = "Mettez la souris sur l'image"
EndIf
StatusBarText(0, 0, s$)
EndIf
EndIf
Until Event = #PB_Event_CloseWindow
EndIf
