Skip to main content

splitGridPointsByToeJoint.m


% This function is part of the NMSM Pipeline, see file for full license.
%
%
%
% (Array of double, Array of double, Array of double)
% -> (Array of double, Array of double)
% Separates included spring marker points into hindfoot and toes portions.


function [insideToes, insideHindfoot] = splitGridPointsByToeJoint( ...
insidePoints, medialPt, lateralPt)
insideToes = [];
insideHindfoot = [];
for i=1:length(insidePoints)
if isAboveToeJoint(medialPt, lateralPt, insidePoints(i, :))
insideHindfoot(end+1, :) = insidePoints(i, :);
else
insideToes(end+1, :) = insidePoints(i, :);
end
end
end

function out = isAboveToeJoint(medialPt, lateralPt, springPt)
lineX = linspace(medialPt(2), lateralPt(2));
lineY = linspace(medialPt(1), lateralPt(1));
springLineY = linspace(springPt(2), 1);
springLineX = ones(1,length(springLineY)) * springPt(1);
out = checkIntersection(lineX, lineY, springLineX, springLineY);
end