Skip to content
Snippets Groups Projects
Commit 041d1fd0 authored by Mark Winter's avatar Mark Winter
Browse files

GetNearestTrackHull not returning correct hash index when searching forward within a track.

parent c36bf503
No related branches found
No related tags found
No related merge requests found
% hull = GetNearestTrackHull(trackID, time, searchDir)
% [hull hullTime] = GetNearestTrackHull(trackID, time, searchDir)
% Search track for a non-zero hull nearest to the specified time, searchDir
% beack in time if searchDir < 0 or forward if searchDir > 0. Returns 0 if
% no hull exists in specified direction.
function hull = GetNearestTrackHull(trackID, time, searchDir)
global CellTracks
function [hull hullTime] = GetNearestTrackHull(trackID, time, searchDir)
global CellTracks CellHulls
hull = 0;
hullTime = 0;
hash = time - CellTracks(trackID).startTime + 1;
if ( hash < 1 && (searchDir >= 0) )
hull = CellTracks(trackID).hulls(1);
hullTime = CellHulls(hull).time;
return;
end
if ( (hash > length(CellTracks(trackID).hulls)) && ((searchDir < 0)) )
hull = CellTracks(trackID).hulls(end);
hullTime = CellHulls(hull).time;
return;
end
......@@ -26,7 +29,7 @@ function hull = GetNearestTrackHull(trackID, time, searchDir)
hull = CellTracks(trackID).hulls(hash);
if ( hull == 0 )
if ( searchDir >= 0 )
hidx = find(CellTracks(trackID).hulls(hash:end), 1, 'first');
hidx = find(CellTracks(trackID).hulls(hash:end), 1, 'first') + (hash - 1);
else
hidx = find(CellTracks(trackID).hulls(1:hash), 1, 'last');
end
......@@ -36,5 +39,6 @@ function hull = GetNearestTrackHull(trackID, time, searchDir)
end
hull = CellTracks(trackID).hulls(hidx);
hullTime = CellHulls(hull).time;
end
end
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment