Skip to main content

makeNormalizedGrid.m


% This function is part of the NMSM Pipeline, see file for full license.
%
% Makes a grid of points in a normalized array for placing spring markers.
% The points are made in a reversed order if this is a left foot to ensure
% symmetry of stiffness coefficients when optimizing multiple feet.
%
% (struct, struct) -> (struct)
% Makes a grid of points in a normalized array for placing spring markers.


function points = makeNormalizedGrid(cellsWide, cellsLong, isLeftFoot)
points = zeros(cellsWide * cellsLong, 2);
for i=1:cellsWide
i_side = i;
% If this is a left foot, markers are added in reverse order to ensure
% symmetry of stiffness coefficients
if isLeftFoot
i_side = cellsWide + 1 - i_side;
end
for j=1:cellsLong
x = (i_side)/(cellsWide) - (1/(2*cellsWide));
y = (j-1)/(cellsLong-1);
points((i-1)*cellsLong + j, :) = [x y];
end
end
end