% This function is part of the NMSM Pipeline, see file for full license.
%
%
%
% (Array of double, logical) -> (Array of double, Array of double)
% Separates spring marker points into those inside and outside the shoe.
function [insidePoints, outsidePoints] = splitNormalizedGridPoints( ...
points, isLeftFoot)
shoeCurve = load(fullfile(fileparts(mfilename('fullpath')), ...
"shoeCurve.mat")).shoeCurve;
insidePoints = [];
outsidePoints = [];
for i=1:size(points, 1)
% If this is a left foot, flip points across the vertical centerline
if(isLeftFoot)
points(i,1) = 1 - points(i,1);
end
if(isInShoeOutline(points(i,1), points(i,2), shoeCurve.x, shoeCurve.y))
insidePoints(end+1, :) = points(i, :);
else
outsidePoints(end+1, :) = points(i, :);
end
end
end
function isInShoe = isInShoeOutline(normalizedX, normalizedY, curveX, ...
curveY)
try
lineX = normalizedX:abs(normalizedX-1)/100:1;
lineY = ones(1,length(lineX)) * normalizedY;
isInShoe = checkIntersection(curveX, curveY, lineX, lineY);
if(isInShoe)
lineX = 0:abs(normalizedX)/100:normalizedX;
lineY = ones(1,length(lineX)) * normalizedY;
isInShoe = checkIntersection(curveX, curveY, lineX, lineY);
end
if(isInShoe)
lineY = normalizedY:abs(normalizedY-1)/100:1;
lineX = ones(1,length(lineY)) * normalizedX;
isInShoe = checkIntersection(curveX, curveY, lineX, lineY);
end
if(isInShoe)
lineY = 0:abs(normalizedY)/100:normalizedY;
lineX = ones(1,length(lineY)) * normalizedX;
isInShoe = checkIntersection(curveX, curveY, lineX, lineY);
end
catch
isInShoe = false;
end
end