I\'m trying to implement Jarvis\' algorithm for finding the convex hull of a set of points, but for some reason it doesn\'t work. This is my implementation:
proc
The loop adds using this line of code:
aHull.Add(vPointOnHull);
vPointOnHull
is only assigned in these lines:
vPointOnHull := Self.LeftMostPoint;
vPointOnHull := vEndpoint;
You already explained that LeftMostPoint
is added correctly, so the repeat must come from vEndPoint
, which is assigned in these lines:
vEndpoint := Self.Point[0];
vEndpoint := Self.Point[I];
So I guess the last assignment (which is in the below if statement), is never reached.
if Orientation(vPointOnHull,vEndpoint,Self.Point[I]) = LeftHandSide then
vEndpoint := Self.Point[I];
--jeroen