Its been a long time since we have seen any challenges on this board, so I figured what the hell time for another one. The goal is simple, given 2D arrays of points that represent polygons (could be convex or concave) tell if they collide or not.
Method prototype:
[code=delphi]
type
TColPoint = packed record
x, y : single;
end;
function colPoly(const o1x, o1y, o2x, o2y : single; const pts1, pts2 : array of TColPoint) : boolean; inline;
begin
end;
[/code]
Notes:
o1x, o1y - World position of poly 1
o2x, o2y - World position of poly 2
pts1 - Points array for poly 1
pts2 - Points array for poly 2
* Don't assume that pts[length(pts)-1] is the same as pts[0] it may or may not be
Rules:
1) Only use existing FPC/Lazarus/Delphi libraries that ship with the compilers (Math, SysUtils, etc... though they shouldn't be needed)
2) Don't submit someone elses work
UPDATE:
Ok, a quick test harness and a (very bad) example are posted at: http://www.eonclash.com/PGD/testpoly.zip
Bookmarks