I have a map which shows a path people are supposed to take. This path translates to ~190 points(x, y) positions. When someone actually takes the path, it's almost impossible for them to match the original point for point. In addition, the actual points can be greatly more, ~350 points, compared to the defined path.
What I'm trying to see is if the person sort of followed the path. Meaning they were within a given distance. In the case of a single point, lets say they were within 100+- pixels.
I tried to create a rect around an actual point and see if a path point is within it. Since the number of points are different I figure I would create a range of points to check.
Overall, the ultimate goal is to see if the person was within the range of the path the entire time or not.
One problem I get with my current approach is the point isn't always found even though I know it's close enough. I'm pretty sure it has to do with the range I'm looking in. The other issue which I haven't been able to work through is the different number of points.
In the following image the original path is black and the actual path is red.
const int expandBy = 120;
const int inflateBy = expandBy / 2;
const int range = 5;
for (int i = 0; i < actualPoints.Length; i++)
{
bool found = false;
var pt = actualPoints[i];
var actualRect = new CCRect(pt.X - inflateBy, pt.Y - inflateBy, expandBy, expandBy);
var upperRange = range * 2;
var lowerRange = i - range;
if (lowerRange < 0)
lowerRange = 0;
var points = path.Skip(lowerRange).Take(upperRange);
foreach (var pts1 in points)
{
if (!actualRect.ContainsPoint(pts1))
{
drawNode.DrawRect(actualRect, CCColor4B.Green);
}
else
{
found = true;
break;
}
}
if (!found)
return false;
}
return true;