Changeset 171 for trunk/Packages/Common/UGeometryClasses.pas
- Timestamp:
- Nov 23, 2017, 7:05:37 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Packages/Common/UGeometryClasses.pas
r170 r171 26 26 function PointsToRect(const P1, P2: TPoint): TRect; 27 27 function PointInRect(const P: TPoint; aRect: TRect): Boolean; 28 function PtInPoly(const Points: array of TPoint; Pos: TPoint): Boolean; 28 29 function HalfDistancePoint(const P1, P2: TPoint): TPoint; 29 30 function NormalizeAngle(const Angle: Double): Double; … … 172 173 end; 173 174 175 function PtInPoly(const Points: array of TPoint; Pos: TPoint): Boolean; 176 var 177 Count, K, J : Integer; 178 begin 179 Result := False; 180 Count := Length(Points) ; 181 J := Count - 1; 182 for K := 0 to Count - 1 do begin 183 if ((Points[K].Y <= Pos.Y) and (Pos.Y < Points[J].Y)) or 184 ((Points[J].Y <= Pos.Y) and (Pos.Y < Points[K].Y)) then 185 begin 186 if (Pos.X < (Points[j].X - Points[K].X) * 187 (Pos.Y - Points[K].Y) / 188 (Points[j].Y - Points[K].Y) + Points[K].X) then 189 Result := not Result; 190 end; 191 J := K; 192 end; 193 end; 174 194 175 195 end.
Note:
See TracChangeset
for help on using the changeset viewer.