1function H = bp_hinges(tri)
2% BP_HINGES Hinges across the interior edges of a triangle mesh.
3% H = bp_hinges(tri) returns rows [i j k l] for sys.hinges (append a
4% stiffness column kh): j-k is an edge shared by two triangles, and i and
5% l are the third beads of those triangles. A hinge resists changes of the
6% angle between its two triangles from their angle at the rest positions,
7% so any rest shape (flat, domed, bell-shaped) is free of stress.
8t = tri;
9% each triangle edge, sorted, with the opposite bead
10E3 = [sort(t(:, [1 2]), 2), t(:, 3); sort(t(:, [2 3]), 2), t(:, 1); sort(t(:, [3 1]), 2), t(:, 2)];
11[~, ord] = sortrows(E3(:, 1:2));
12E3 = E3(ord, :);
13pair = find(all(E3(1:end-1, 1:2) == E3(2:end, 1:2), 2));
14H = [E3(pair, 3), E3(pair, 1), E3(pair, 2), E3(pair + 1, 3)];
15end