Sign in Join
Wiki copytemporary

Geometry in Pascal/de: what changed

Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
1-## Testen, ob ein Punkt in einem Polygon liegt
2-
3-``` pascal
4-// Die Funktion gibt den Wert True zurück, wenn der Punkt x,y innerhalb eines Polygons liegt.
5-// Die Funktion gibt den Wert False zurück, wenn der Punkt x,y nicht in einem Polygon liegt.
6-//
7-// Der Original C-Code: http://www.visibone.com/inpoly/inpoly.c.txt
8-//
9-// Übersetzng von C nach Pascal: Felipe Monteiro de Carvalho
10-//
11-// Lizenz: Public Domain
12-
13-function IsPointInPolygon(AX, AY: Integer; APolygon: array of TPoint): Boolean;
14-var
15- xnew, ynew,
16- xold, yold,
17- x1, y1,
18- x2, y2: Cardinal;
19- i, npoints: Integer;
20- inside: Integer = 0;
21-
22-begin
23- Result := False;
24-
25- npoints := Length(APolygon);
26-
27- if (npoints < 3) then Exit;
28-
29- xold := APolygon[npoints-1].X;
30- yold := APolygon[npoints-1].Y;
31-
32- for i := 0 to npoints - 1 do begin
33- xnew := APolygon[i].X;
34- ynew := APolygon[i].Y;
1+## Contents
352
36- if (xnew > xold) then begin
37- x1 := xold;
38- x2 := xnew;
39- y1 := yold;
40- y2 := ynew;
41- end else begin
42- x1 := xnew;
43- x2 := xold;
44- y1 := ynew;
45- y2 := yold;
46- end;
3+ * 1 Testen, ob ein Punkt in einem Polygon liegt
4+ * 2 Siehe auch
475
48- if (((xnew < AX) = (AX <= xold)) and // Die Ecke ist am linken Ende "offen"
49- ((AY - y1) * (x2 - x1) < (y2 - y1) * (AX - x1))) then
6+## Testen, ob ein Punkt in einem Polygon liegt
7+```
8+// Die Funktion gibt den Wert True zurück, wenn der Punkt x,y innerhalb eines Polygons liegt.
9+ // Die Funktion gibt den Wert False zurück, wenn der Punkt x,y nicht in einem Polygon liegt.
10+ //
11+ // Der Original C-Code: http://www.visibone.com/inpoly/inpoly.c.txt
12+ //
13+ // Übersetzng von C nach Pascal: Felipe Monteiro de Carvalho
14+ //
15+ // Lizenz: Public Domain
16+
17+ function IsPointInPolygon(AX, AY: Integer; APolygon: array of TPoint): Boolean;
18+ var
19+ xnew, ynew,
20+ xold, yold,
21+ x1, y1,
22+ x2, y2: Cardinal;
23+ i, npoints: Integer;
24+ inside: Integer = 0;
25+
5026 begin
51- inside := not inside;
27+ Result := False;
28+
29+ npoints := Length(APolygon);
30+
31+ if (npoints < 3) then Exit;
32+
33+ xold := APolygon[npoints-1].X;
34+ yold := APolygon[npoints-1].Y;
35+
36+ for i := 0 to npoints - 1 do begin
37+ xnew := APolygon[i].X;
38+ ynew := APolygon[i].Y;
39+
40+ if (xnew > xold) then begin
41+ x1 := xold;
42+ x2 := xnew;
43+ y1 := yold;
44+ y2 := ynew;
45+ end else begin
46+ x1 := xnew;
47+ x2 := xold;
48+ y1 := ynew;
49+ y2 := yold;
50+ end;
51+
52+ if (((xnew < AX) = (AX <= xold)) and // Die Ecke ist am linken Ende "offen"
53+ ((AY - y1) * (x2 - x1) < (y2 - y1) * (AX - x1))) then
54+ begin
55+ inside := not inside;
56+ end;
57+
58+ xold := xnew;
59+ yold := ynew;
60+
61+ end;
62+
63+ Result := inside <> 0;
5264 end;
53-
54- xold := xnew;
55- yold := ynew;
56-
57- end;
58-
59- Result := inside <> 0;
60-end;
6165```
6266
6367## Siehe auch
6468
65-- [A Point about Polygons](http://www.visibone.com/inpoly/) (Englisch)
69+ * [A Point about Polygons](<http://www.visibone.com/inpoly/>) (Englisch)
6670
6771---
68-*From the Free Pascal wiki, page "Geometry in Pascal/de", as it stood on 2020-08-22 after a change by Kai Burghardt, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*
72+*From the Free Pascal wiki, page "Geometry in Pascal/de", as the Internet Archive kept it on 2023-06-04. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*

Back to history